bcquality/microsoft/knowledge/testing/use-testpage-editable-to-verify-field-editability.bad.al
Michael Dieringer e538664a50 Address Jesper Schulz-Wedde's review on PR #158
- use-generateguid-for-unique-test-fixture-values.md: GenerateGUID()
  is a Code[10] number-series value, not a real GUID; truncating it
  with CopyStr for a shorter field cuts off the changing digits. Point
  to GenerateRandomCode/GenerateRandomCodeWithLength/GenerateRandomXMLText
  instead, which verify uniqueness against the actual table.
- Split use-testpage-visible-enabled-to-verify-field-ui-state.md: drop
  its editability claim (the sample opens with OpenView() and asserts
  Enabled(), which verifies enabled state, not editability — Editable()
  and Enabled() are distinct TestField methods). New companion article
  use-testpage-editable-to-verify-field-editability.md covers Editable()
  with OpenEdit() specifically.
- Wire GenerateGUID/CopyStr and TestPage Visible/Enabled/Editable cues
  into al-testing-review.md, and the Item Ledger Entry/Last Shipping No.
  posting cue into al-data-modeling-review.md.

The Item Ledger Entry article itself was independently verified against
current BCApps source and needs no changes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-21 22:34:40 +02:00

27 lines
935 B
AL

codeunit 50134 "Sample Customer Type Edit Test"
{
Subtype = Test;
[Test]
procedure CustomerTypeFieldNotEditable_WhenLocked()
var
Assert: Codeunit Assert;
CustomerType: Record "Customer Type";
CustomerTypeCard: TestPage "Customer Type Card";
begin
// [GIVEN] a customer type record whose Locked flag is set
CustomerType.Init();
CustomerType.Locked := true;
CustomerType.Insert(true);
// [WHEN] the page is opened in VIEW mode — editability logic that only
// applies in edit mode is not exercised the same way
CustomerTypeCard.OpenView();
CustomerTypeCard.GoToRecord(CustomerType);
// [THEN] wrong function: Enabled() does not verify editability
Assert.IsFalse(CustomerTypeCard.Description.Enabled(), 'Description should not be editable while Locked is set.');
CustomerTypeCard.Close();
end;
}