Skip to content
Open
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
1 change: 1 addition & 0 deletions .github/AL-Go-Settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"repoVersion": "30.0",
"memoryLimit": "16G",
"numberOfTenantsForTesting": 4,
"enableCleanTestCodeunitExecution": true,
"maxTestAppReruns": 2,
"failOn": "newWarning",
"workspaceCompilation": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ namespace Microsoft.ExpenseAgent;

using Microsoft.Finance.SpendRequest;
using System.Telemetry;
using System.Text;

codeunit 7133 "Travel Request Approval"
{
Expand Down Expand Up @@ -318,13 +317,17 @@ codeunit 7133 "Travel Request Approval"
var
ExpenseApprovalSetup: Record "Expense Approval Setup";
ExpenseAgentSetup: Record "Expense Agent Setup";
SelectionFilterManagement: Codeunit SelectionFilterManagement;
RecRef: RecordRef;
AssignedFilter: TextBuilder;
begin
ExpenseApprovalSetup.SetCurrentKey("Approver No.");
ExpenseApprovalSetup.SetRange("Approver No.", ApproverExpenseUserNo);
RecRef.GetTable(ExpenseApprovalSetup);
RequestedForFilter := SelectionFilterManagement.GetSelectionFilter(RecRef, ExpenseApprovalSetup.FieldNo("Expense User No."));
ExpenseApprovalSetup.SetLoadFields("Expense User No.");
// Ranges between setup rows could include expense users without any approval setup.
if ExpenseApprovalSetup.FindSet() then
repeat
AppendSubmitterFilter(AssignedFilter, ExpenseApprovalSetup."Expense User No.");
until ExpenseApprovalSetup.Next() = 0;
RequestedForFilter := AssignedFilter.ToText();

ExpenseAgentSetup.GetRecordOnce();
if ExpenseAgentSetup."Default Approver No." = ApproverExpenseUserNo then
Expand All @@ -337,7 +340,6 @@ codeunit 7133 "Travel Request Approval"
local procedure AppendDefaultSubmitters(var RequestedForFilter: Text)
var
ExpenseUser: Record "Expense User";
SelectionFilterManagement: Codeunit SelectionFilterManagement;
DefaultFilter: TextBuilder;
begin
if RequestedForFilter <> '' then
Expand All @@ -348,14 +350,23 @@ codeunit 7133 "Travel Request Approval"
ExpenseUser.SetLoadFields("No.");
if ExpenseUser.FindSet() then
repeat
if DefaultFilter.Length > 0 then
DefaultFilter.Append('|');
DefaultFilter.Append(SelectionFilterManagement.AddQuotes(ExpenseUser."No."));
AppendSubmitterFilter(DefaultFilter, ExpenseUser."No.");
until ExpenseUser.Next() = 0;

RequestedForFilter := DefaultFilter.ToText();
end;

local procedure AppendSubmitterFilter(var SubmitterFilter: TextBuilder; ExpenseUserNo: Code[20])
var
ExpenseUserFilter: Record "Expense User";
begin
// Serialize an exact value so filter operators in user numbers remain literal.
ExpenseUserFilter.SetRange("No.", ExpenseUserNo);
if SubmitterFilter.Length > 0 then
SubmitterFilter.Append('|');
SubmitterFilter.Append(ExpenseUserFilter.GetFilter("No."));
end;

var
FeatureTelemetry: Codeunit "Feature Telemetry";
ExpenseActivityLogMgt: Codeunit "Expense Activity Log Mgt.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ codeunit 148343 "Expense Activity Log API Test"
LibraryGraphMgt: Codeunit "Library - Graph Mgt";
LibraryTestInitialize: Codeunit "Library - Test Initialize";
LibrarySetupStorage: Codeunit "Library - Setup Storage";
APITestAuthHelper: Codeunit "Expense API Test Auth Helper";
IsInitialized: Boolean;
ServiceNameTok: Label 'expenseActivityLogEntries', Locked = true;
ExpenseReportsServiceNameTok: Label 'expenseReports', Locked = true;
Expand Down Expand Up @@ -477,19 +476,23 @@ codeunit 148343 "Expense Activity Log API Test"
RequestBody.WriteTo(RequestText);
ReportURL := LibraryGraphMgt.CreateTargetURLWithSubpage(
Format(SubmitterExpenseUser.SystemId), Page::"Expense Users API", ExpenseUsersServiceNameTok, ExpenseReportsServiceNameTok);
ReportURL += '(' + LibraryGraphMgt.StripBrackets(Format(ExpenseReportHeader.SystemId)) + ')';
ReportURL := LibraryGraphMgt.AppendPathToTargetURL(
ReportURL, '(' + LibraryGraphMgt.StripBrackets(Format(ExpenseReportHeader.SystemId)) + ')');
Commit();

// [WHEN] The standard submission action is requested through the submitting user.
LibraryGraphMgt.PostToWebServiceAndCheckResponseCode(ReportURL + '/' + SubmitWithCommentActionTok, RequestText, ResponseText, 200);
Clear(ResponseText);
LibraryGraphMgt.PostToWebServiceAndCheckResponseCode(
LibraryGraphMgt.AppendPathToTargetURL(ReportURL, '/' + SubmitWithCommentActionTok), RequestText, ResponseText, 200);

// [THEN] Exactly one structured snapshot is visible without a new callback or capability.
ExpenseActivityLogEntry.SetRange("Subject System ID", ExpenseReportHeader.SystemId);
ExpenseActivityLogEntry.SetRange("Event Type", ExpenseActivityLogEntry."Event Type"::PolicyEvaluated);
Assert.RecordCount(ExpenseActivityLogEntry, 1);
ExpenseActivityLogEntry.FindFirst();
Clear(ResponseText);
LibraryGraphMgt.GetFromWebServiceAndCheckResponseCode(ResponseText, ReportURL + '/' + ServiceNameTok, 200);
LibraryGraphMgt.GetFromWebServiceAndCheckResponseCode(
ResponseText, LibraryGraphMgt.AppendPathToTargetURL(ReportURL, '/' + ServiceNameTok), 200);
VerifyPolicyCategoryCode(ResponseText, ExpenseCategory.Code);
ResponseText := LowerCase(ResponseText);
Assert.AreNotEqual(0, StrPos(ResponseText, '"eventtype":"policyevaluated"'), 'The event type must identify the policy snapshot.');
Expand All @@ -503,7 +506,8 @@ codeunit 148343 "Expense Activity Log API Test"
HistoryURL := LibraryGraphMgt.CreateTargetURLWithSubpage(
Format(SubmitterExpenseUser.SystemId), Page::"Expense Users API", ExpenseUsersServiceNameTok, ServiceNameTok);
Clear(ResponseText);
LibraryGraphMgt.GetFromWebServiceAndCheckResponseCode(ResponseText, HistoryURL + '?$filter=historyActorRole eq ''Submitter''', 200);
LibraryGraphMgt.GetFromWebServiceAndCheckResponseCode(
ResponseText, LibraryGraphMgt.AppendQueryParameterToTargetURL(HistoryURL, '$filter=historyActorRole eq ''Submitter'''), 200);

// [THEN] The real submitter sees the agent snapshot in the complete timeline.
Assert.AreNotEqual(0, StrPos(LowerCase(ResponseText), LowerCase(LibraryGraphMgt.StripBrackets(Format(ExpenseActivityLogEntry.SystemId)))), 'The submitter timeline must contain the snapshot.');
Expand All @@ -512,7 +516,8 @@ codeunit 148343 "Expense Activity Log API Test"
HistoryURL := LibraryGraphMgt.CreateTargetURLWithSubpage(
Format(ApproverExpenseUser.SystemId), Page::"Expense Users API", ExpenseUsersServiceNameTok, ServiceNameTok);
Clear(ResponseText);
LibraryGraphMgt.GetFromWebServiceAndCheckResponseCode(ResponseText, HistoryURL + '?$filter=historyActorRole eq ''Approver''', 200);
LibraryGraphMgt.GetFromWebServiceAndCheckResponseCode(
ResponseText, LibraryGraphMgt.AppendQueryParameterToTargetURL(HistoryURL, '$filter=historyActorRole eq ''Approver'''), 200);

// [THEN] The agent event must not grant approver participation.
Assert.AreEqual(0, StrPos(LowerCase(ResponseText), LowerCase(LibraryGraphMgt.StripBrackets(Format(ExpenseReportHeader.SystemId)))), 'The agent snapshot must not grant approver history access.');
Expand Down Expand Up @@ -804,7 +809,6 @@ codeunit 148343 "Expense Activity Log API Test"
if IsInitialized then
exit;

BindSubscription(APITestAuthHelper);
LibraryTestInitialize.OnBeforeTestSuiteInitialize(Codeunit::"Expense Activity Log API Test");
LibraryERMCountryData.UpdateGeneralLedgerSetup();
if not ExpenseAgentSetup.Get() then begin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ codeunit 148318 "Expense Capabilities API Test"
LibraryExpenseAgent: Codeunit "Library - Expense Agent";
LibraryGraphMgt: Codeunit "Library - Graph Mgt";
LibraryTestInitialize: Codeunit "Library - Test Initialize";
APITestAuthHelper: Codeunit "Expense API Test Auth Helper";
IsInitialized: Boolean;
ServiceNameTok: Label 'expenseCapabilities', Locked = true;
ActivityLogCapabilityNameTok: Label 'activityLog', Locked = true;
Expand Down Expand Up @@ -105,8 +104,6 @@ codeunit 148318 "Expense Capabilities API Test"
TargetURL: Text;
ResponseText: Text;
begin
// Excluded in BCApps CI until authenticated OData execution in a dedicated test company
// with disabled isolation is available; then remove this method's DisabledTest.json entry.
// [SCENARIO] Travel requests are advertised when the supporting APIs are installed.
Initialize();

Expand Down Expand Up @@ -249,7 +246,6 @@ codeunit 148318 "Expense Capabilities API Test"
if IsInitialized then
exit;

BindSubscription(APITestAuthHelper);
LibraryTestInitialize.OnBeforeTestSuiteInitialize(Codeunit::"Expense Capabilities API Test");
IsInitialized := true;
Commit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ codeunit 148349 "Expense PerDiem Locations Test"
LibraryUtility: Codeunit "Library - Utility";
LibraryGraphMgt: Codeunit "Library - Graph Mgt";
LibraryTestInitialize: Codeunit "Library - Test Initialize";
APITestAuthHelper: Codeunit "Expense API Test Auth Helper";
IsInitialized: Boolean;

[Test]
Expand Down Expand Up @@ -83,11 +82,11 @@ codeunit 148349 "Expense PerDiem Locations Test"

local procedure Initialize()
begin
LibraryGraphMgt.SetLicenseSafeWorkDate();
LibraryTestInitialize.OnTestInitialize(Codeunit::"Expense PerDiem Locations Test");
if IsInitialized then
exit;

BindSubscription(APITestAuthHelper);
LibraryTestInitialize.OnBeforeTestSuiteInitialize(Codeunit::"Expense PerDiem Locations Test");
IsInitialized := true;
Commit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ codeunit 148331 "Expense Projects API Test"
LibraryHumanResource: Codeunit "Library - Human Resource";
LibraryGraphMgt: Codeunit "Library - Graph Mgt";
LibraryTestInitialize: Codeunit "Library - Test Initialize";
APITestAuthHelper: Codeunit "Expense API Test Auth Helper";
IsInitialized: Boolean;
ExpenseUsersServiceNameTok: Label 'expenseUsers', Locked = true;
ProjectsServiceNameTok: Label 'expenseProjects', Locked = true;
Expand Down Expand Up @@ -724,7 +723,6 @@ codeunit 148331 "Expense Projects API Test"
if IsInitialized then
exit;

BindSubscription(APITestAuthHelper);
LibraryTestInitialize.OnBeforeTestSuiteInitialize(Codeunit::"Expense Projects API Test");
if not ExpenseAgentSetup.Get() then begin
ExpenseAgentSetup.Init();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ codeunit 148315 "Expense Users API Test"
LibraryUtility: Codeunit "Library - Utility";
LibraryGraphMgt: Codeunit "Library - Graph Mgt";
LibraryTestInitialize: Codeunit "Library - Test Initialize";
APITestAuthHelper: Codeunit "Expense API Test Auth Helper";
IsInitialized: Boolean;
ServiceNameTok: Label 'expenseUsers', Locked = true;
EmployeesServiceNameTok: Label 'employees', Locked = true;
Expand Down Expand Up @@ -126,7 +125,6 @@ codeunit 148315 "Expense Users API Test"
if IsInitialized then
exit;

BindSubscription(APITestAuthHelper);
LibraryTestInitialize.OnBeforeTestSuiteInitialize(Codeunit::"Expense Users API Test");
if not ExpenseAgentSetup.Get() then begin
ExpenseAgentSetup.Init();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ codeunit 148348 "Expense VAT Spec. API Test"
Subtype = Test;
TestHttpRequestPolicy = AllowAllOutboundRequests;
TestType = IntegrationTest;
RequiredTestIsolation = Disabled;
TestPermissions = Disabled;

var
Expand All @@ -20,7 +21,6 @@ codeunit 148348 "Expense VAT Spec. API Test"
LibraryERM: Codeunit "Library - ERM";
LibraryGraphMgt: Codeunit "Library - Graph Mgt";
LibraryTestInitialize: Codeunit "Library - Test Initialize";
APITestAuthHelper: Codeunit "Expense API Test Auth Helper";
IsInitialized: Boolean;
ServiceNameTok: Label 'expenseVATSpecifications', Locked = true;

Expand Down Expand Up @@ -90,7 +90,6 @@ codeunit 148348 "Expense VAT Spec. API Test"
if IsInitialized then
exit;

BindSubscription(APITestAuthHelper);
LibraryTestInitialize.OnBeforeTestSuiteInitialize(Codeunit::"Expense VAT Spec. API Test");
LibraryExpense.SetupNumberSeriesInExpenseMgmt();
LibraryERM.CreateVATBusinessPostingGroup(VATBusinessPostingGroup);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ codeunit 148345 "Policies To Evaluate API Test"
LibraryExpense: Codeunit "Library - Expense";
LibraryGraphMgt: Codeunit "Library - Graph Mgt";
LibraryTestInitialize: Codeunit "Library - Test Initialize";
APITestAuthHelper: Codeunit "Expense API Test Auth Helper";
IsInitialized: Boolean;
ExpenseReportLinesServiceNameTok: Label 'expenseReportLines', Locked = true;

Expand Down Expand Up @@ -118,7 +117,6 @@ codeunit 148345 "Policies To Evaluate API Test"
if IsInitialized then
exit;

BindSubscription(APITestAuthHelper);
LibraryTestInitialize.OnBeforeTestSuiteInitialize(Codeunit::"Policies To Evaluate API Test");
LibraryERMCountryData.CreateVATData();
LibraryERMCountryData.UpdateGeneralPostingSetup();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ codeunit 148344 "Policy Evaluations API Test"
LibraryExpense: Codeunit "Library - Expense";
LibraryGraphMgt: Codeunit "Library - Graph Mgt";
LibraryTestInitialize: Codeunit "Library - Test Initialize";
APITestAuthHelper: Codeunit "Expense API Test Auth Helper";
IsInitialized: Boolean;
ServiceNameTok: Label 'expensePolicyEvaluations', Locked = true;
BadRequestResponseErr: Label 'Response code is 400', Locked = true;
Expand Down Expand Up @@ -122,7 +121,6 @@ codeunit 148344 "Policy Evaluations API Test"
if IsInitialized then
exit;

BindSubscription(APITestAuthHelper);
LibraryTestInitialize.OnBeforeTestSuiteInitialize(Codeunit::"Policy Evaluations API Test");
LibraryERMCountryData.CreateVATData();
LibraryERMCountryData.UpdateGeneralPostingSetup();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ using Microsoft.Finance.GeneralLedger.Setup;
using Microsoft.Finance.SpendRequest;
using Microsoft.HumanResources.Employee;

// These HTTP tests remain excluded in Expense_Agent_Tests.DisabledTest.json until the
// authentication prerequisite provides an authenticated OData endpoint and a dedicated
// test company with committed fixtures and disabled test isolation.
// In-process employee filtering, traveler mapping/navigation, lifecycle, date, and scope coverage
Comment thread
t-prda marked this conversation as resolved.
// in "Spend Request Test", and restrictive role coverage in "Expense Permissions Test", remain enabled.
// Only the HTTP scenarios are excluded.
codeunit 148347 "Travel Requests API Test"
{
Subtype = Test;
Expand All @@ -32,7 +26,6 @@ codeunit 148347 "Travel Requests API Test"
LibraryHumanResource: Codeunit "Library - Human Resource";
LibraryRandom: Codeunit "Library - Random";
LibraryTestInitialize: Codeunit "Library - Test Initialize";
APITestAuthHelper: Codeunit "Expense API Test Auth Helper";
IsInitialized: Boolean;
ExpenseUsersServiceNameTok: Label 'expenseUsers', Locked = true;
#if not CLEAN30
Expand Down Expand Up @@ -1292,7 +1285,6 @@ codeunit 148347 "Travel Requests API Test"
if IsInitialized then
exit;

BindSubscription(APITestAuthHelper);
Comment thread
t-prda marked this conversation as resolved.
LibraryTestInitialize.OnBeforeTestSuiteInitialize(Codeunit::"Travel Requests API Test");
if not ExpenseAgentSetup.Get() then begin
ExpenseAgentSetup.Init();
Expand Down
Loading
Loading