This commit is contained in:
67
Translation/RequestedTranslationKeys.cs
Normal file
67
Translation/RequestedTranslationKeys.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using Xunit;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using FluentAssertions;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Concurrent;
|
||||
namespace raven_integration
|
||||
{
|
||||
|
||||
public class RequestedLocaleKeys
|
||||
{
|
||||
|
||||
|
||||
|
||||
[Fact]
|
||||
public async void RequestedLocaleKeysWorks()
|
||||
{
|
||||
//First determine if there is a requested key route because it's debug build dependent
|
||||
//And doesn't exists if server was not debug built
|
||||
ApiResponse a = await Util.GetAsync("BuildMode");
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
var BuildMode = a.ObjectResponse["data"]["buildMode"].Value<string>();
|
||||
BuildMode.Should().BeOneOf((new string[] { "DEBUG", "RELEASE" }));
|
||||
|
||||
if (BuildMode == "DEBUG")
|
||||
{
|
||||
|
||||
//Make a "list" of keys to fetch the values for
|
||||
List<string> keys = new List<string>();
|
||||
keys.AddRange(new string[] { "HelpLicense", "ClientName" });
|
||||
dynamic d = new JObject();
|
||||
|
||||
d = JToken.FromObject(keys);
|
||||
|
||||
//Fetch the values to force RAVEN to track at least these two
|
||||
a = await Util.PostAsync("Translation/subset", await Util.GetTokenAsync("CustomerLimited"), d.ToString());
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
Util.ValidateHTTPStatusCode(a, 200);
|
||||
//there should be dozens of keys but at times there might only be a few during development so at least verify there is more than one
|
||||
((JArray)a.ObjectResponse["data"]).Count.Should().Be(2);
|
||||
|
||||
//Now ensure there are at least two keys in the fetched keys array
|
||||
a = await Util.GetAsync("Translation/TranslationKeyCoverage", await Util.GetTokenAsync("CustomerLimited"));
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
Util.ValidateHTTPStatusCode(a, 200);
|
||||
|
||||
var RequestedKeyCount = a.ObjectResponse["data"]["requestedKeyCount"].Value<int>();
|
||||
RequestedKeyCount.Should().BeGreaterOrEqualTo(2);
|
||||
var NotRequestedKeyCount = a.ObjectResponse["data"]["notRequestedKeyCount"].Value<int>();
|
||||
NotRequestedKeyCount.Should().BeGreaterThan(1);//For now at least, once we have this dialed in it will be zero ultimately
|
||||
|
||||
//there should be dozens of keys but at times there might only be a few during development so at least verify there is more than one
|
||||
((JArray)a.ObjectResponse["data"]["requestedKeys"]).Count.Should().Be(RequestedKeyCount);
|
||||
((JArray)a.ObjectResponse["data"]["notRequestedKeys"]).Count.Should().Be(NotRequestedKeyCount);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//==================================================
|
||||
|
||||
}//eoc
|
||||
}//eons
|
||||
181
Translation/Translation.cs
Normal file
181
Translation/Translation.cs
Normal file
@@ -0,0 +1,181 @@
|
||||
using System;
|
||||
using Xunit;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using FluentAssertions;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Concurrent;
|
||||
namespace raven_integration
|
||||
{
|
||||
|
||||
public class Translation
|
||||
{
|
||||
|
||||
/*
|
||||
|
||||
ImportTranslation(ct, ResourceFolderPath, "en"); - id 1
|
||||
ImportTranslation(ct, ResourceFolderPath, "es"); - id 2
|
||||
ImportTranslation(ct, ResourceFolderPath, "fr"); - id 3
|
||||
ImportTranslation(ct, ResourceFolderPath, "de"); - id 4
|
||||
*/
|
||||
|
||||
[Fact]
|
||||
public async void TranslationPickListWorks()
|
||||
{
|
||||
//Get all
|
||||
ApiResponse a = await Util.GetAsync("Translation/picklist", await Util.GetTokenAsync("CustomerLimited"));//lowest level test user because there are no limits on this route except to be authenticated
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
Util.ValidateHTTPStatusCode(a, 200);
|
||||
//there should be at least 4 of them as there are 4 stock translations
|
||||
((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(3);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public async void GetFullTranslationWorks()
|
||||
{
|
||||
//Get all
|
||||
ApiResponse a = await Util.GetAsync("Translation/1", await Util.GetTokenAsync("CustomerLimited"));//lowest level test user because there are no limits on this route except to be authenticated
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
Util.ValidateHTTPStatusCode(a, 200);
|
||||
//there should be dozens of keys but at times there might only be a few during development so at least verify there is more than one
|
||||
((JArray)a.ObjectResponse["data"]["translationItems"]).Count.Should().BeGreaterThan(0);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public async void GetSubsetWorks()
|
||||
{
|
||||
|
||||
|
||||
List<string> keys = new List<string>();
|
||||
keys.AddRange(new string[] { "AddressType", "ClientName", "RateName", "WorkorderService" });
|
||||
dynamic d = new JObject();
|
||||
|
||||
d = JToken.FromObject(keys);
|
||||
|
||||
ApiResponse a = await Util.PostAsync("Translation/subset", await Util.GetTokenAsync("CustomerLimited"), d.ToString());
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
Util.ValidateHTTPStatusCode(a, 200);
|
||||
//there should be dozens of keys but at times there might only be a few during development so at least verify there is more than one
|
||||
((JArray)a.ObjectResponse["data"]).Count.Should().Be(4);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public async void DuplicateUpdateAndDeleteWorks()
|
||||
{
|
||||
/*
|
||||
{
|
||||
"id": 1,
|
||||
"name": "CustomTest1"
|
||||
}
|
||||
*/
|
||||
|
||||
//DUPLICATE
|
||||
dynamic d = new JObject();
|
||||
d.id = 1;
|
||||
d.name = Util.Uniquify("INTEGRATION-TEST-LOCALE");
|
||||
|
||||
ApiResponse a = await Util.PostAsync("Translation/Duplicate", await Util.GetTokenAsync("BizAdminFull"), d.ToString());
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
Util.ValidateHTTPStatusCode(a, 201);
|
||||
//verify the object returned is as expected
|
||||
a.ObjectResponse["data"]["name"].Value<string>().Should().Be(d.name.ToString());
|
||||
a.ObjectResponse["data"]["stock"].Value<bool>().Should().Be(false);
|
||||
a.ObjectResponse["data"]["id"].Value<long>().Should().BeGreaterThan(4);
|
||||
a.ObjectResponse["data"]["concurrencyToken"].Value<uint>().Should().BeGreaterThan(0);
|
||||
((JArray)a.ObjectResponse["data"]["translationItems"]).Count.Should().BeGreaterThan(0);
|
||||
|
||||
long NewId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||
|
||||
//UPDATE
|
||||
//Update translation name
|
||||
|
||||
/*
|
||||
|
||||
{
|
||||
"id": 10,
|
||||
"newText": "What the hell?",
|
||||
"concurrencyToken": 25174
|
||||
}
|
||||
|
||||
*/
|
||||
dynamic d2 = new JObject();
|
||||
d2.id = NewId;
|
||||
d2.newText = Util.Uniquify("INTEGRATION-TEST-LOCALE NAME UPDATE");
|
||||
d2.concurrencyToken = a.ObjectResponse["data"]["concurrencyToken"].Value<uint>();
|
||||
ApiResponse PUTTestResponse = await Util.PutAsync("Translation/UpdateTranslationName", await Util.GetTokenAsync("BizAdminFull"), d2.ToString());
|
||||
Util.ValidateHTTPStatusCode(PUTTestResponse, 200);
|
||||
|
||||
|
||||
ApiResponse checkPUTWorked = await Util.GetAsync("Translation/" + NewId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||
Util.ValidateNoErrorInResponse(checkPUTWorked);
|
||||
checkPUTWorked.ObjectResponse["data"]["name"].Value<string>().Should().Be(d2.newText.ToString());
|
||||
//uint concurrencyToken = PUTTestResponse.ObjectResponse["data"]["concurrencyToken"].Value<uint>();
|
||||
|
||||
|
||||
//Update translation key
|
||||
var FirstTranslationKey = ((JArray)a.ObjectResponse["data"]["translationItems"])[0];
|
||||
long UpdatedTranslationKeyId = FirstTranslationKey["id"].Value<long>();
|
||||
d2.id = UpdatedTranslationKeyId;
|
||||
d2.newText = Util.Uniquify("INTEGRATION-TEST-LOCALEITEM DISPLAY UPDATE");
|
||||
d2.concurrencyToken = FirstTranslationKey["concurrencyToken"].Value<uint>();
|
||||
|
||||
string UpdatedTranslationKey = FirstTranslationKey["key"].Value<string>();
|
||||
|
||||
PUTTestResponse = await Util.PutAsync("Translation/UpdateTranslationItemDisplayText", await Util.GetTokenAsync("BizAdminFull"), d2.ToString());
|
||||
Util.ValidateHTTPStatusCode(PUTTestResponse, 200);
|
||||
|
||||
//create user that is set to new translation so can use getSubset
|
||||
var Login = Util.Uniquify("LOGIN");
|
||||
var Password = Util.Uniquify("PASSWORD");
|
||||
dynamic DUSER = new JObject();
|
||||
DUSER.name = Util.Uniquify("TranslationUpdateSubsetTestUser");
|
||||
|
||||
DUSER.active = true;
|
||||
DUSER.login = Login;
|
||||
DUSER.password = Password;
|
||||
DUSER.roles = 0;//norole (any role can get a subset of translation keys)
|
||||
DUSER.translationId = NewId;
|
||||
DUSER.userType = 3;//non scheduleable
|
||||
//Required by form custom rules
|
||||
DUSER.notes = "notes";
|
||||
DUSER.customFields = Util.UserRequiredCustomFieldsJsonString();
|
||||
a = await Util.PostAsync("User", await Util.GetTokenAsync("manager", "l3tm3in"), DUSER.ToString());
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
long DUSERID = a.ObjectResponse["data"]["id"].Value<long>();
|
||||
|
||||
|
||||
|
||||
List<string> keys = new List<string>();
|
||||
keys.AddRange(new string[] { UpdatedTranslationKey });
|
||||
dynamic d3 = new JObject();
|
||||
|
||||
d3 = JToken.FromObject(keys);
|
||||
|
||||
checkPUTWorked = await Util.PostAsync("Translation/subset", await Util.GetTokenAsync(Login, Password), d3.ToString());
|
||||
Util.ValidateDataReturnResponseOk(checkPUTWorked);
|
||||
Util.ValidateHTTPStatusCode(checkPUTWorked, 200);
|
||||
((JArray)checkPUTWorked.ObjectResponse["data"]).Count.Should().Be(1);
|
||||
var FirstTranslationKeyUpdated = ((JArray)checkPUTWorked.ObjectResponse["data"])[0];
|
||||
|
||||
FirstTranslationKeyUpdated["value"].Value<string>().Should().Be(d2.newText.ToString());
|
||||
|
||||
//DELETE TEMPORARY USER SO CAN DELETE LOCALE
|
||||
a = await Util.DeleteAsync("User/" + DUSERID.ToString(), await Util.GetTokenAsync("manager", "l3tm3in"));
|
||||
Util.ValidateHTTPStatusCode(a, 204);
|
||||
|
||||
//DELETE TEMP LOCALE
|
||||
a = await Util.DeleteAsync("Translation/" + NewId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||
Util.ValidateHTTPStatusCode(a, 204);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//==================================================
|
||||
|
||||
}//eoc
|
||||
}//eons
|
||||
Reference in New Issue
Block a user