Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions src/Apps/W1/APIV1/test/src/APIV1AutomationRSPackage.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ codeunit 139731 "APIV1 - Automation RS Package"
LibraryGraphMgt: Codeunit "Library - Graph Mgt";
LibraryUtility: Codeunit "Library - Utility";
Assert: Codeunit "Assert";
IsInitialized: Boolean;
SamplePackageFile: Text;
PackageCodeTxt: Label 'code', Locked = true;
ActionImportTxt: Label 'Microsoft.NAV.import';
Expand All @@ -31,15 +30,11 @@ codeunit 139731 "APIV1 - Automation RS Package"
TenantConfigPackageFile: Record "Tenant Config. Package File";
begin
LibraryGraphMgt.SetLicenseSafeWorkDate();
TenantConfigPackageFile.DELETEALL(TRUE);

IF IsInitialized THEN
EXIT;

LibraryGraphMgt.SetAuthenticationProvider(
Enum::"API Test Authentication"::"Microsoft Test Environment");
TenantConfigPackageFile.DELETEALL(TRUE);

SamplePackageFile := GenerateSamplePackageFile();
IsInitialized := TRUE;
end;

[Test]
Expand Down Expand Up @@ -146,11 +141,12 @@ codeunit 139731 "APIV1 - Automation RS Package"
StartTime := CURRENTDATETIME();

REPEAT
SelectLatestVersion();
ConfigPackage.FIND();
UNTIL (NOT IsImportPending(ConfigPackage)) OR
(CURRENTDATETIME() - StartTime > 180000);

Assert.AreEqual(ConfigPackage."Import Status", ConfigPackage."Import Status"::Completed, 'Import Status should be completed.');
Assert.AreEqual(ConfigPackage."Import Status"::Completed, ConfigPackage."Import Status", 'Import Status should be completed.');

// clean up after the test
LibraryRapidStart.CleanUp(ConfigPackage.Code);
Expand Down Expand Up @@ -194,11 +190,12 @@ codeunit 139731 "APIV1 - Automation RS Package"
StartTime := CURRENTDATETIME();

REPEAT
SelectLatestVersion();
ConfigPackage.FIND();
UNTIL (NOT IsImportPending(ConfigPackage)) OR
(CURRENTDATETIME() - StartTime > 180000);

Assert.AreEqual(ConfigPackage."Import Status", ConfigPackage."Import Status"::Error, 'Import Status should be error.');
Assert.AreEqual(ConfigPackage."Import Status"::Error, ConfigPackage."Import Status", 'Import Status should be error.');

// clean up after the test
LibraryRapidStart.CleanUp(ConfigPackage.Code);
Expand Down Expand Up @@ -244,11 +241,12 @@ codeunit 139731 "APIV1 - Automation RS Package"
StartTime := CURRENTDATETIME();

REPEAT
SelectLatestVersion();
ConfigPackage.FIND();
UNTIL (NOT IsApplyPending(ConfigPackage)) OR
(CURRENTDATETIME() - StartTime > 180000);

Assert.AreEqual(ConfigPackage."Apply Status", ConfigPackage."Apply Status"::Completed, 'Apply Status should be completed.');
Assert.AreEqual(ConfigPackage."Apply Status"::Completed, ConfigPackage."Apply Status", 'Apply Status should be completed.');
Assert.AreEqual(0, ConfigPackage."No. of Errors", 'There should be no errors.');

// clean up after the test
Expand Down Expand Up @@ -332,7 +330,7 @@ codeunit 139731 "APIV1 - Automation RS Package"

local procedure IsApplyPending(var ConfigPackage: Record "Config. Package"): Boolean
begin
EXIT(ConfigPackage."Apply Status" IN [ConfigPackage."Import Status"::Scheduled, ConfigPackage."Apply Status"::InProgress]);
EXIT(ConfigPackage."Apply Status" IN [ConfigPackage."Apply Status"::Scheduled, ConfigPackage."Apply Status"::InProgress]);
end;

local procedure CreateTestPackage(var ConfigPackage: Record "Config. Package")
Expand Down
7 changes: 3 additions & 4 deletions src/Apps/W1/APIV1/test/src/APIV1GLEntriesE2E.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ codeunit 139730 "APIV1 - GLEntries E2E"
var
Assert: Codeunit "Assert";
LibraryERM: Codeunit "Library - ERM";
LibraryVariableStorage: Codeunit "Library - Variable Storage";
LibraryGraphMgt: Codeunit "Library - Graph Mgt";
IsInitialized: Boolean;
JournalTemplateName: Code[10];
ServiceNameTxt: Label 'generalLedgerEntries';

local procedure Initialize()
Expand Down Expand Up @@ -94,7 +94,7 @@ codeunit 139730 "APIV1 - GLEntries E2E"
CreateGeneralJournalBatch(GenJournalBatch);

// Create General Journal Line.
LibraryVariableStorage.Enqueue(GenJournalBatch."Journal Template Name");
JournalTemplateName := GenJournalBatch."Journal Template Name";
GeneralJournal.TRAP();
GeneralJournal.OPENEDIT();
GeneralJournal."Account Type".SETVALUE(GenJournalLine."Account Type"::"G/L Account");
Expand Down Expand Up @@ -124,7 +124,6 @@ codeunit 139730 "APIV1 - GLEntries E2E"

local procedure UpdateAmountOnGenJournalLine(GenJournalBatch: Record "Gen. Journal Batch"; var GeneralJournal: TestPage "General Journal")
begin
LibraryVariableStorage.Enqueue(GenJournalBatch."Journal Template Name");
LibraryERM.UpdateAmountOnGenJournalLine(GenJournalBatch, GeneralJournal);
end;

Expand All @@ -150,7 +149,7 @@ codeunit 139730 "APIV1 - GLEntries E2E"
[ModalPageHandler]
procedure GeneralJournalTemplateHandler(var GeneralJournalTemplateList: TestPage 250)
begin
GeneralJournalTemplateList.FILTER.SETFILTER(Name, LibraryVariableStorage.DequeueText());
GeneralJournalTemplateList.FILTER.SETFILTER(Name, JournalTemplateName);
GeneralJournalTemplateList.OK().INVOKE();
end;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,7 @@ codeunit 139738 "APIV1 - Purchase Inv Lines E2E"
TargetURL: Text;
ResponseText: Text;
InvoiceLineJSON: Text;
LineDescription: Text;
begin
// [SCENARIO] Posting a line with description only will get a type item
// [GIVEN] A post request with description only
Expand All @@ -724,7 +725,8 @@ codeunit 139738 "APIV1 - Purchase Inv Lines E2E"

COMMIT();

InvoiceLineJSON := '{"description":"test"}';
LineDescription := Format(CreateGuid());
InvoiceLineJSON := LibraryGraphMgt.AddPropertytoJSON('', 'description', LineDescription);

// [WHEN] we just POST a blank line
TargetURL := LibraryGraphMgt
Expand All @@ -736,8 +738,10 @@ codeunit 139738 "APIV1 - Purchase Inv Lines E2E"
LibraryGraphMgt.PostToWebService(TargetURL, InvoiceLineJSON, ResponseText);

// [THEN] Line of type Item is created
FindFirstPurchaseLine(PurchaseHeader, PurchaseLine);
PurchaseLine.FINDLAST();
PurchaseLine.SETRANGE("Document Type", PurchaseHeader."Document Type");
PurchaseLine.SETRANGE("Document No.", PurchaseHeader."No.");
PurchaseLine.SETRANGE(Description, LineDescription);
Assert.IsTrue(PurchaseLine.FINDFIRST(), 'Could not find the created purchase invoice line');
Assert.AreEqual('', PurchaseLine."No.", 'No should be blank');
Assert.AreEqual(PurchaseLine.Type, PurchaseLine.Type::Item, 'Wrong type is set');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,7 @@ codeunit 139737 "APIV1 - Sales CrMemo Lines E2E"
TargetURL: Text;
ResponseText: Text;
CreditMemoLineJSON: Text;
LineDescription: Text;
begin
// [SCENARIO] Posting a line with description only will get a type item
// [GIVEN] A post request with description only
Expand All @@ -711,7 +712,8 @@ codeunit 139737 "APIV1 - Sales CrMemo Lines E2E"

COMMIT();

CreditMemoLineJSON := '{"description":"test"}';
LineDescription := Format(CreateGuid());
CreditMemoLineJSON := LibraryGraphMgt.AddPropertytoJSON('', 'description', LineDescription);

// [WHEN] we just POST a blank line
TargetURL := LibraryGraphMgt
Expand All @@ -723,8 +725,10 @@ codeunit 139737 "APIV1 - Sales CrMemo Lines E2E"
LibraryGraphMgt.PostToWebService(TargetURL, CreditMemoLineJSON, ResponseText);

// [THEN] Line of type Item is created
FindFirstSalesLine(SalesHeader, SalesLine);
SalesLine.FINDLAST();
SalesLine.SETRANGE("Document Type", SalesHeader."Document Type");
SalesLine.SETRANGE("Document No.", SalesHeader."No.");
SalesLine.SETRANGE(Description, LineDescription);
Assert.IsTrue(SalesLine.FINDFIRST(), 'Could not find the created credit memo line');
Assert.AreEqual('', SalesLine."No.", 'No should be blank');
Assert.AreEqual(SalesLine.Type, SalesLine.Type::Item, 'Wrong type is set');

Expand Down
10 changes: 7 additions & 3 deletions src/Apps/W1/APIV1/test/src/APIV1SalesInvLinesE2E.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,7 @@ codeunit 139734 "APIV1 - Sales Inv. Lines E2E"
TargetURL: Text;
ResponseText: Text;
InvoiceLineJSON: Text;
LineDescription: Text;
begin
// [SCENARIO] Posting a line with description only will get a type item
// [GIVEN] A post request with description only
Expand All @@ -948,7 +949,8 @@ codeunit 139734 "APIV1 - Sales Inv. Lines E2E"

COMMIT();

InvoiceLineJSON := '{"description":"test"}';
LineDescription := Format(CreateGuid());
InvoiceLineJSON := LibraryGraphMgt.AddPropertytoJSON('', 'description', LineDescription);

// [WHEN] we just POST a blank line
TargetURL := LibraryGraphMgt
Expand All @@ -960,8 +962,10 @@ codeunit 139734 "APIV1 - Sales Inv. Lines E2E"
LibraryGraphMgt.PostToWebService(TargetURL, InvoiceLineJSON, ResponseText);

// [THEN] Line of type Item is created
FindFirstSalesLine(SalesHeader, SalesLine);
SalesLine.FINDLAST();
SalesLine.SETRANGE("Document Type", SalesHeader."Document Type");
SalesLine.SETRANGE("Document No.", SalesHeader."No.");
SalesLine.SETRANGE(Description, LineDescription);
Assert.IsTrue(SalesLine.FINDFIRST(), 'Could not find the created invoice line');
Assert.AreEqual('', SalesLine."No.", 'No should be blank');
Assert.AreEqual(SalesLine.Type, SalesLine.Type::Item, 'Wrong type is set');
VerifyIdsAreBlank(ResponseText);
Expand Down
10 changes: 7 additions & 3 deletions src/Apps/W1/APIV1/test/src/APIV1SalesOrderLinesE2E.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,7 @@ codeunit 139735 "APIV1 - Sales Order Lines E2E"
TargetURL: Text;
ResponseText: Text;
OrderLineJSON: Text;
LineDescription: Text;
begin
// [SCENARIO] Posting a line with description only will get a type item
// [GIVEN] A post request with description only
Expand All @@ -725,7 +726,8 @@ codeunit 139735 "APIV1 - Sales Order Lines E2E"

COMMIT();

OrderLineJSON := '{"description":"test"}';
LineDescription := Format(CreateGuid());
OrderLineJSON := LibraryGraphMgt.AddPropertytoJSON('', 'description', LineDescription);

// [WHEN] we just POST a blank line
TargetURL := LibraryGraphMgt
Expand All @@ -737,8 +739,10 @@ codeunit 139735 "APIV1 - Sales Order Lines E2E"
LibraryGraphMgt.PostToWebService(TargetURL, OrderLineJSON, ResponseText);

// [THEN] Line of type Item is created
FindFirstSalesLine(SalesHeader, SalesLine);
SalesLine.FINDLAST();
SalesLine.SETRANGE("Document Type", SalesHeader."Document Type");
SalesLine.SETRANGE("Document No.", SalesHeader."No.");
SalesLine.SETRANGE(Description, LineDescription);
Assert.IsTrue(SalesLine.FINDFIRST(), 'Could not find the created order line');
Assert.AreEqual('', SalesLine."No.", 'No should be blank');
Assert.AreEqual(SalesLine.Type, SalesLine.Type::Item, 'Wrong type is set');

Expand Down
10 changes: 7 additions & 3 deletions src/Apps/W1/APIV1/test/src/APIV1SalesQuoteLinesE2E.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,7 @@ codeunit 139736 "APIV1 - Sales Quote Lines E2E"
TargetURL: Text;
ResponseText: Text;
QuoteLineJSON: Text;
LineDescription: Text;
begin
// [SCENARIO] Posting a line with description only will get a type item
// [GIVEN] A post request with description only
Expand All @@ -627,7 +628,8 @@ codeunit 139736 "APIV1 - Sales Quote Lines E2E"

COMMIT();

QuoteLineJSON := '{"description":"test"}';
LineDescription := Format(CreateGuid());
QuoteLineJSON := LibraryGraphMgt.AddPropertytoJSON('', 'description', LineDescription);

// [WHEN] we just POST a blank line
TargetURL := LibraryGraphMgt
Expand All @@ -639,8 +641,10 @@ codeunit 139736 "APIV1 - Sales Quote Lines E2E"
LibraryGraphMgt.PostToWebService(TargetURL, QuoteLineJSON, ResponseText);

// [THEN] Line of type Item is created
FindFirstSalesLine(SalesHeader, SalesLine);
SalesLine.FINDLAST();
SalesLine.SETRANGE("Document Type", SalesHeader."Document Type");
SalesLine.SETRANGE("Document No.", SalesHeader."No.");
SalesLine.SETRANGE(Description, LineDescription);
Assert.IsTrue(SalesLine.FINDFIRST(), 'Could not find the created quote line');
Assert.AreEqual('', SalesLine."No.", 'No should be blank');
Assert.AreEqual(SalesLine.Type, SalesLine.Type::Item, 'Wrong type is set');

Expand Down
1 change: 1 addition & 0 deletions src/Apps/W1/APIV1/test/src/SalesInvoicesE2E.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,7 @@ codeunit 139709 "Sales Invoices E2E"
Initialize();

// [GIVEN] 2 invoices, one posted and one unposted without totals assigned
LibraryApplicationArea.EnableFoundationSetup();
LibraryGraphDocumentTools.CreateDocumentWithDiscountPctPending(
SalesHeader, DiscountPct, SalesHeader."Document Type"::Invoice);
SalesHeader.CALCFIELDS("Recalculate Invoice Disc.");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,52 +1 @@
[
{
"codeunitId": 139734,
"codeunitName": "APIV1 - Sales Inv. Lines E2E",
"method": "TestPostingBlankLineDefaultsToItemType"
},
{
"codeunitId": 139735,
"codeunitName": "APIV1 - Sales Order Lines E2E",
"method": "TestPostingBlankLineDefaultsToItemType"
},
{
"codeunitId": 139736,
"codeunitName": "APIV1 - Sales Quote Lines E2E",
"method": "TestPostingBlankLineDefaultsToItemType"
},
{
"codeunitId": 139737,
"codeunitName": "APIV1 - Sales CrMemo Lines E2E",
"method": "TestPostingBlankLineDefaultsToItemType"
},
{
"codeunitId": 139738,
"codeunitName": "APIV1 - Purchase Inv Lines E2E",
"method": "TestPostingBlankLineDefaultsToItemType"
},
{
"codeunitId": 139731,
"codeunitName": "APIV1 - Automation RS Package",
"method": "TestImportRSPackage"
},
{
"codeunitId": 139731,
"codeunitName": "APIV1 - Automation RS Package",
"method": "TestImportWrongRSPackage"
},
{
"codeunitId": 139731,
"codeunitName": "APIV1 - Automation RS Package",
"method": "TestApplyRSPackage"
},
{
"codeunitId": 139730,
"codeunitName": "APIV1 - GLEntries E2E",
"method": "TestGetGLEntries"
},
{
"codeunitId": 139709,
"codeunitName": "Sales Invoices E2E",
"method": "TestGetInvoicesAppliesDiscountPct"
}
]
[]
Loading