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
Original file line number Diff line number Diff line change
Expand Up @@ -800,8 +800,8 @@ page 190 "Incoming Documents"
UpdateOCRSetupVisibility();

Rec.FilterGroup(0);
if Rec.GetFilter(Processed) <> '' then
SetProcessedDocumentsVisibility(Rec.GetFilter(Processed) = Format(true));
if Rec.GetFilter(Processed) = '' then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Breaking\ Changes}$

This changes the externally observable OnOpenPage behavior of shipped page 190 "Incoming Documents" for callers that pass an Incoming Document record with a non-empty Processed filter into Page.Run/Page.RunModal: SetProcessedDocumentsVisibility is now never invoked for that case, so the caller's data filter is preserved, but the ShowAll/ShowUnprocessed action Enabled state (driven by ShowAllDocsIsEnable) no longer reflects the actual applied filter — it stays at its unprocessed default (ShowAll enabled, ShowUnprocessed disabled) regardless of whether the incoming filter was Processed=true or Processed=false. External extensions that open this page with a custom filter and rely on the previous enabled-state derivation will see inconsistent action availability relative to the data actually shown. Note the new tests (TestIncomingDocsPreserveProcessedFilter/TestIncomingDocsPreserveUnprocessedFilter) explicitly assert this new fixed enabled-state, indicating it may be an accepted trade-off rather than an oversight, but it should be called out explicitly since it is a change in externally visible UI state contract, not just an internal filter fix.

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.32.4

SetProcessedDocumentsVisibility(false);
end;

var
Expand Down Expand Up @@ -937,4 +937,3 @@ page 190 "Incoming Documents"
begin
end;
}

54 changes: 53 additions & 1 deletion src/Layers/W1/Tests/ERM/ERMIncomingDocuments.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -1880,6 +1880,30 @@ codeunit 134400 "ERM Incoming Documents"
IncomingDocument.HyperlinkToDocument(DocumentNo, PostingDate);
end;

[Test]
[HandlerFunctions('IncomingDocumentsProcessedFilterHandler')]
[Scope('OnPrem')]
procedure TestIncomingDocsDefaultToUnprocessed()
begin
VerifyIncomingDocumentsProcessedFilter('', false);
end;

[Test]
[HandlerFunctions('IncomingDocumentsProcessedFilterHandler')]
[Scope('OnPrem')]
procedure TestIncomingDocsPreserveProcessedFilter()
begin
VerifyIncomingDocumentsProcessedFilter(Format(true), true);
end;

[Test]
[HandlerFunctions('IncomingDocumentsProcessedFilterHandler')]
[Scope('OnPrem')]
procedure TestIncomingDocsPreserveUnprocessedFilter()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Testing}$

TestIncomingDocsPreserveUnprocessedFilter does not actually prove that an explicit Processed=false filter is preserved rather than dropped: with the current implementation, both an explicit Processed=false external filter and no filter at all (the default-to-unprocessed path) produce an identical observable result in the handler (Processed=false, one row, ShowAll enabled, ShowUnprocessed disabled). The test therefore cannot distinguish 'filter preserved' from 'filter ignored and default applied,' so it does not add coverage beyond TestIncomingDocsDefaultToUnprocessed for that specific claim. Consider asserting something that only holds if the original filter object survived (for example, verifying no additional filter-group manipulation occurred, or restructuring so the preserved-filter case uses a value that would differ from the default outcome if broken).

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.32.4

begin
VerifyIncomingDocumentsProcessedFilter(Format(false), false);
end;

[Test]
[Scope('OnPrem')]
procedure TestIncomingDocsShouldShowAllDocsOnShowAllAction()
Expand Down Expand Up @@ -2181,6 +2205,24 @@ codeunit 134400 "ERM Incoming Documents"
Assert.AreEqual(DataExchangeTypeHasValue, IncomingDocuments.CreateDocument.Enabled(), 'Editable value unexpected.');
end;

local procedure VerifyIncomingDocumentsProcessedFilter(ProcessedFilter: Text; ExpectedProcessed: Boolean)
var
IncomingDocument: Record "Incoming Document";
begin
IncomingDocument.DeleteAll();
CreateIncomingDocument(IncomingDocument, 'Processed Document', true);
CreateIncomingDocument(IncomingDocument, 'Unprocessed Document', false);

IncomingDocument.Reset();
if ProcessedFilter <> '' then
IncomingDocument.SetFilter(Processed, ProcessedFilter);

LibraryVariableStorage.Clear();
LibraryVariableStorage.Enqueue(ExpectedProcessed);
Page.RunModal(Page::"Incoming Documents", IncomingDocument);
LibraryVariableStorage.AssertEmpty();
end;

local procedure GetIncomeStatementAcc(): Code[20]
var
GLAccount: Record "G/L Account";
Expand Down Expand Up @@ -2732,6 +2774,17 @@ codeunit 134400 "ERM Incoming Documents"
IncomingDocuments.OK().Invoke();
end;

[ModalPageHandler]
[Scope('OnPrem')]
procedure IncomingDocumentsProcessedFilterHandler(var IncomingDocuments: TestPage "Incoming Documents")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Testing}$

IncomingDocumentsProcessedFilterHandler hardcodes its expectations (row count, ShowAll.Enabled(), ShowUnprocessed.Enabled()) instead of having the calling test enqueue those expected values for the handler to dequeue and verify. Per BCQuality testing guidance, the test should own and enqueue the expected interaction state (including the enabled/disabled action states and expected row count) in call order, and the handler should only Dequeue and assert against that queued value — this makes handler/test mismatches explicit rather than baked into the handler, and keeps the three call sites (TestIncomingDocsDefaultToUnprocessed, TestIncomingDocsPreserveProcessedFilter, TestIncomingDocsPreserveUnprocessedFilter) from silently sharing hardcoded assumptions that don't vary per scenario.

Knowledge:

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.32.4

begin
IncomingDocuments.Processed.AssertEquals(LibraryVariableStorage.DequeueBoolean());
Assert.IsFalse(IncomingDocuments.Next(), 'Expected the page to contain one incoming document.');
Assert.IsTrue(IncomingDocuments.ShowAll.Enabled(), 'Expected Show All to be enabled for a filtered view.');
Assert.IsFalse(IncomingDocuments.ShowUnprocessed.Enabled(), 'Expected Show Unprocessed to be disabled for a filtered view.');
IncomingDocuments.OK().Invoke();
end;

[PageHandler]
[Scope('OnPrem')]
procedure IncomingDocumentCardHandler(var IncomingDocumentCard: TestPage "Incoming Document")
Expand Down Expand Up @@ -2870,4 +2923,3 @@ codeunit 134400 "ERM Incoming Documents"
Assert.AreEqual(1, TempBlobList.Count(), NoOfAttachmentsSameErr);
end;
}

Loading