Skip to content

Commit

Permalink
Fix deprecated usage of isFalsy() / isTruthy() methods in E2E tes…
Browse files Browse the repository at this point in the history
…ts (#3294)

* Replace deprecated usage of falsy/truthy methods

* Change files
  • Loading branch information
lawrencewin authored Dec 8, 2023
1 parent d1ece00 commit a564cf4
Show file tree
Hide file tree
Showing 51 changed files with 382 additions and 132 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ describe('Activity Indicator Testing Initialization', () => {
it('Navigate to Activity Indicator test page', async () => {
expect(await ActivityIndicatorPageObject.navigateToPageAndLoadTests()).toBeTrue();

expect(await ActivityIndicatorPageObject.didAssertPopup()).toBeFalsy(ActivityIndicatorPageObject.ERRORMESSAGE_ASSERT);
expect(await ActivityIndicatorPageObject.didAssertPopup())
.withContext(ActivityIndicatorPageObject.ERRORMESSAGE_ASSERT)
.toBeFalsy();
});
});
4 changes: 3 additions & 1 deletion apps/E2E/src/Avatar/specs/Avatar.spec.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ describe('Avatar Testing Initialization', () => {
it('Click and navigate to Avatar test page', async () => {
expect(await AvatarPageObject.navigateToPageAndLoadTests()).toBeTrue();

await expect(await AvatarPageObject.didAssertPopup()).toBeFalsy(AvatarPageObject.ERRORMESSAGE_ASSERT);
await expect(await AvatarPageObject.didAssertPopup())
.withContext(AvatarPageObject.ERRORMESSAGE_ASSERT)
.toBeFalsy();
});
});
4 changes: 3 additions & 1 deletion apps/E2E/src/Avatar/specs/Avatar.spec.win.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ describe('Avatar Testing Initialization', () => {
/* Expand E2E section */
expect(await AvatarPageObject.enableE2ETesterMode()).toBeTrue();

await expect(await AvatarPageObject.didAssertPopup()).toBeFalsy(AvatarPageObject.ERRORMESSAGE_ASSERT);
await expect(await AvatarPageObject.didAssertPopup())
.withContext(AvatarPageObject.ERRORMESSAGE_ASSERT)
.toBeFalsy();
});
});

Expand Down
4 changes: 3 additions & 1 deletion apps/E2E/src/Badge/specs/Badge.spec.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ describe('Badge Testing Initialization', () => {
/* Expand E2E section */
expect(await BasicBadgePageObject.enableE2ETesterMode()).toBeTrue();

await expect(await BasicBadgePageObject.didAssertPopup()).toBeFalsy(BasicBadgePageObject.ERRORMESSAGE_ASSERT);
await expect(await BasicBadgePageObject.didAssertPopup())
.withContext(BasicBadgePageObject.ERRORMESSAGE_ASSERT)
.toBeFalsy();
});
});
4 changes: 3 additions & 1 deletion apps/E2E/src/Badge/specs/Badge.spec.win.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ describe('Badge Testing Initialization', () => {
it('Click and navigate to Badge test page', async () => {
expect(await BasicBadgePageObject.navigateToPageAndLoadTests()).toBeTrue();

await expect(await BasicBadgePageObject.didAssertPopup()).toBeFalsy(BasicBadgePageObject.ERRORMESSAGE_ASSERT);
await expect(await BasicBadgePageObject.didAssertPopup())
.withContext(BasicBadgePageObject.ERRORMESSAGE_ASSERT)
.toBeFalsy();
});
});
16 changes: 12 additions & 4 deletions apps/E2E/src/ButtonLegacy/specs/ButtonLegacy.spec.win.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ describe('Button Legacy Testing Initialization', () => {
/* Expand E2E section */
expect(await ButtonLegacyPageObject.enableE2ETesterMode()).toBeTrue();

await expect(await ButtonLegacyPageObject.didAssertPopup()).toBeFalsy(ButtonLegacyPageObject.ERRORMESSAGE_ASSERT);
await expect(await ButtonLegacyPageObject.didAssertPopup())
.withContext(ButtonLegacyPageObject.ERRORMESSAGE_ASSERT)
.toBeFalsy();
});
});

Expand Down Expand Up @@ -72,7 +74,9 @@ describe('Button Legacy Functional Testing', () => {
await ButtonLegacyPageObject.didOnClickCallbackFire('Clicking on the primary button failed to fire the onClick() callback.'),
).toBeTruthy();

await expect(await ButtonLegacyPageObject.didAssertPopup()).toBeFalsy(ButtonLegacyPageObject.ERRORMESSAGE_ASSERT);
await expect(await ButtonLegacyPageObject.didAssertPopup())
.withContext(ButtonLegacyPageObject.ERRORMESSAGE_ASSERT)
.toBeFalsy();
});

it('Type "Enter" on primary button. Validate onClick() callback was fired.', async () => {
Expand All @@ -82,7 +86,9 @@ describe('Button Legacy Functional Testing', () => {
"Pressing the 'Enter' key on the primary button failed to fire the onClick() callback.",
),
).toBeTruthy();
await expect(await ButtonLegacyPageObject.didAssertPopup()).toBeFalsy(ButtonLegacyPageObject.ERRORMESSAGE_ASSERT);
await expect(await ButtonLegacyPageObject.didAssertPopup())
.withContext(ButtonLegacyPageObject.ERRORMESSAGE_ASSERT)
.toBeFalsy();
});

it('Type "Space" on primary button. Validate onClick() callback was fired.', async () => {
Expand All @@ -93,6 +99,8 @@ describe('Button Legacy Functional Testing', () => {
),
).toBeTruthy();

await expect(await ButtonLegacyPageObject.didAssertPopup()).toBeFalsy(ButtonLegacyPageObject.ERRORMESSAGE_ASSERT);
await expect(await ButtonLegacyPageObject.didAssertPopup())
.withContext(ButtonLegacyPageObject.ERRORMESSAGE_ASSERT)
.toBeFalsy();
});
});
18 changes: 13 additions & 5 deletions apps/E2E/src/ButtonV1/specs/ButtonV1.spec.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import ButtonV1PageObject from '../pages/ButtonV1PageObject';
// Before testing begins, allow up to 60 seconds for app to open
describe('Button Testing Initialization', () => {
it('Wait for app load', async () => {
expect(await ButtonV1PageObject.waitForInitialPageToDisplay()).toBeTrue();
expect(await ButtonV1PageObject.waitForInitialPageToDisplay()).toBeTrue();
});

it('Click and navigate to Button test page', async () => {
Expand All @@ -14,7 +14,9 @@ describe('Button Testing Initialization', () => {
/* Expand E2E section */
expect(await ButtonV1PageObject.enableE2ETesterMode()).toBeTrue();

await expect(await ButtonV1PageObject.didAssertPopup()).toBeFalsy(ButtonV1PageObject.ERRORMESSAGE_ASSERT);
await expect(await ButtonV1PageObject.didAssertPopup())
.withContext(ButtonV1PageObject.ERRORMESSAGE_ASSERT)
.toBeFalsy();
});
});

Expand All @@ -32,15 +34,19 @@ describe('ButtonV1 Accessibility Testing', () => {
),
).toBeTruthy();

await expect(await ButtonV1PageObject.didAssertPopup()).toBeFalsy(ButtonV1PageObject.ERRORMESSAGE_ASSERT);
await expect(await ButtonV1PageObject.didAssertPopup())
.withContext(ButtonV1PageObject.ERRORMESSAGE_ASSERT)
.toBeFalsy();
});

it('Validate Button Class on Android', async () => {
await expect(
await ButtonV1PageObject.compareAttribute(ButtonV1PageObject._primaryComponent, AndroidAttribute.Class, ANDROID_BUTTON),
).toBeTruthy();

await expect(await ButtonV1PageObject.didAssertPopup()).toBeFalsy(ButtonV1PageObject.ERRORMESSAGE_ASSERT);
await expect(await ButtonV1PageObject.didAssertPopup())
.withContext(ButtonV1PageObject.ERRORMESSAGE_ASSERT)
.toBeFalsy();
});
});

Expand All @@ -55,7 +61,9 @@ describe('ButtonV1 Functional Testing', () => {
await expect(
await ButtonV1PageObject.waitForOnClickCallbackToFire(`The primary button failed to fire an onClick callback with a mouse click.`),
).toBeTruthy();
await expect(await ButtonV1PageObject.didAssertPopup()).toBeFalsy(ButtonV1PageObject.ERRORMESSAGE_ASSERT);
await expect(await ButtonV1PageObject.didAssertPopup())
.withContext(ButtonV1PageObject.ERRORMESSAGE_ASSERT)
.toBeFalsy();

await ButtonV1PageObject.click(ButtonV1PageObject._primaryComponent); // Reset Button State
});
Expand Down
16 changes: 12 additions & 4 deletions apps/E2E/src/ButtonV1/specs/ButtonV1.spec.win.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ describe('ButtonV1 Testing Initialization', () => {
/* Expand E2E section */
expect(await ButtonV1PageObject.enableE2ETesterMode()).toBeTrue();

await expect(await ButtonV1PageObject.didAssertPopup()).toBeFalsy(ButtonV1PageObject.ERRORMESSAGE_ASSERT); // Ensure no asserts popped up
await expect(await ButtonV1PageObject.didAssertPopup())
.withContext(ButtonV1PageObject.ERRORMESSAGE_ASSERT)
.toBeFalsy(); // Ensure no asserts popped up
});
});

Expand Down Expand Up @@ -67,7 +69,9 @@ describe('ButtonV1 Functional Testing', () => {
await ButtonV1PageObject.waitForOnClickCallbackToFire(`The primary button failed to fire an onClick callback with a mouse click.`),
).toBeTruthy();

await expect(await ButtonV1PageObject.didAssertPopup()).toBeFalsy(ButtonV1PageObject.ERRORMESSAGE_ASSERT);
await expect(await ButtonV1PageObject.didAssertPopup())
.withContext(ButtonV1PageObject.ERRORMESSAGE_ASSERT)
.toBeFalsy();
});

it('Type "Enter" on primary button. Validate onClick() callback was fired.', async () => {
Expand All @@ -78,7 +82,9 @@ describe('ButtonV1 Functional Testing', () => {
),
).toBeTruthy();

await expect(await ButtonV1PageObject.didAssertPopup()).toBeFalsy(ButtonV1PageObject.ERRORMESSAGE_ASSERT);
await expect(await ButtonV1PageObject.didAssertPopup())
.withContext(ButtonV1PageObject.ERRORMESSAGE_ASSERT)
.toBeFalsy();
});

it('Type "Space" on primary button. Validate onClick() callback was fired.', async () => {
Expand All @@ -88,6 +94,8 @@ describe('ButtonV1 Functional Testing', () => {
await ButtonV1PageObject.waitForOnClickCallbackToFire(`The primary button failed to fire an onClick callback with a space keypress.`),
).toBeTruthy();

await expect(await ButtonV1PageObject.didAssertPopup()).toBeFalsy(ButtonV1PageObject.ERRORMESSAGE_ASSERT);
await expect(await ButtonV1PageObject.didAssertPopup())
.withContext(ButtonV1PageObject.ERRORMESSAGE_ASSERT)
.toBeFalsy();
});
});
8 changes: 6 additions & 2 deletions apps/E2E/src/Callout/specs/Callout.spec.win.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ describe('Callout Testing Initialization', () => {
/* Expand E2E section */
expect(await CalloutPageObject.enableE2ETesterMode()).toBeTrue();

await expect(await CalloutPageObject.didAssertPopup()).toBeFalsy(CalloutPageObject.ERRORMESSAGE_ASSERT); // Ensure no asserts popped up
await expect(await CalloutPageObject.didAssertPopup())
.withContext(CalloutPageObject.ERRORMESSAGE_ASSERT)
.toBeFalsy(); // Ensure no asserts popped up
});
});

Expand Down Expand Up @@ -53,7 +55,9 @@ describe('Callout Functional Testing', () => {
});

it('Open Callout by clicking a button. Validate that the Callout is displayed.', async () => {
await expect(await CalloutPageObject.isCalloutOpen()).toBeTruthy('The callout failed to visibly display.');
await expect(await CalloutPageObject.isCalloutOpen())
.withContext('The callout failed to visibly display.')
.toBeTruthy();
});

afterEach(async () => {
Expand Down
18 changes: 13 additions & 5 deletions apps/E2E/src/CheckboxLegacy/specs/CheckboxLegacy.spec.win.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('Checkbox Legacy Testing Initialization', () => {
/* Expand E2E section */
expect(await CheckboxLegacyPageObject.enableE2ETesterMode()).toBeTrue();

await expect(await CheckboxLegacyPageObject.didAssertPopup()).toBeFalsy(CheckboxLegacyPageObject.ERRORMESSAGE_ASSERT); // Ensure no asserts popped up
await expect(await CheckboxLegacyPageObject.didAssertPopup()).withContext(CheckboxLegacyPageObject.ERRORMESSAGE_ASSERT); // Ensure no asserts popped u.toBeFalsy()p
});
});

Expand Down Expand Up @@ -64,7 +64,9 @@ describe('Checkbox Legacy Functional Testing', () => {

it("Click the primary checkbox. Validate that the Checkbox toggles correctly AND calls the user's onChange() callback.", async () => {
/* Validate the Checkbox is initially toggled OFF */
await expect(await CheckboxLegacyPageObject.isCheckboxChecked()).toBeFalsy('The primary checkbox should initially be toggled off.');
await expect(await CheckboxLegacyPageObject.isCheckboxChecked())
.withContext('The primary checkbox should initially be toggled off.')
.toBeFalsy();

/* Click on the Checkbox to toggle on */
await CheckboxLegacyPageObject.click(CheckboxLegacyPageObject._primaryComponent);
Expand All @@ -85,12 +87,16 @@ describe('Checkbox Legacy Functional Testing', () => {
await CheckboxLegacyPageObject.waitForCheckboxToggle(false, 'The primary checkbox should have been toggled off via click.'),
).toBeTruthy();

await expect(await CheckboxLegacyPageObject.didAssertPopup()).toBeFalsy(CheckboxLegacyPageObject.ERRORMESSAGE_ASSERT);
await expect(await CheckboxLegacyPageObject.didAssertPopup())
.withContext(CheckboxLegacyPageObject.ERRORMESSAGE_ASSERT)
.toBeFalsy();
});

it("Press 'Space' on the primary checkbox. Validate that the Checkbox toggles correctly AND calls the user's onChange() callback.", async () => {
/* Validate the Checkbox is initially toggled OFF */
await expect(await CheckboxLegacyPageObject.isCheckboxChecked()).toBeFalsy('The primary checkbox should initially be toggled off.');
await expect(await CheckboxLegacyPageObject.isCheckboxChecked())
.withContext('The primary checkbox should initially be toggled off.')
.toBeFalsy();

/* Presses the "space bar" to select the Checkbox */
await CheckboxLegacyPageObject.sendKeys(CheckboxLegacyPageObject._primaryComponent, [Keys.SPACE]);
Expand All @@ -110,6 +116,8 @@ describe('Checkbox Legacy Functional Testing', () => {
await CheckboxLegacyPageObject.waitForCheckboxToggle(false, "The primary checkbox should have been toggled off via 'Space' press."),
).toBeTruthy();

await expect(await CheckboxLegacyPageObject.didAssertPopup()).toBeFalsy(CheckboxLegacyPageObject.ERRORMESSAGE_ASSERT);
await expect(await CheckboxLegacyPageObject.didAssertPopup())
.withContext(CheckboxLegacyPageObject.ERRORMESSAGE_ASSERT)
.toBeFalsy();
});
});
12 changes: 9 additions & 3 deletions apps/E2E/src/CheckboxV1/specs/CheckboxV1.spec.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ describe('CheckboxV1 Testing Initialization', () => {
/* Expand E2E section */
expect(await CheckboxV1PageObject.enableE2ETesterMode()).toBeTrue();

await expect(await CheckboxV1PageObject.didAssertPopup()).toBeFalsy(CheckboxV1PageObject.ERRORMESSAGE_ASSERT); // Ensure no asserts popped up
await expect(await CheckboxV1PageObject.didAssertPopup())
.withContext(CheckboxV1PageObject.ERRORMESSAGE_ASSERT)
.toBeFalsy(); // Ensure no asserts popped up
});
});

Expand Down Expand Up @@ -54,7 +56,9 @@ describe('CheckboxV1 Functional Testing', () => {
await CheckboxV1PageObject.click(CheckboxV1PageObject._primaryComponent);

/* Validate the Checkbox is toggled ON */
expect(await CheckboxV1PageObject.didAssertPopup()).toBeFalsy(CheckboxV1PageObject.ERRORMESSAGE_ASSERT);
expect(await CheckboxV1PageObject.didAssertPopup())
.withContext(CheckboxV1PageObject.ERRORMESSAGE_ASSERT)
.toBeFalsy();
await expect(await CheckboxV1PageObject.waitForCheckboxToggleAndroid(true, 'Checkbox should have toggled on.')).toBeTruthy();
expect(await CheckboxV1PageObject.didOnChangeCallbackFire('Callback failed to fire via click.')).toBeTruthy();
expect(await CheckboxV1PageObject.isCheckboxCheckedAndroid()).toBeTruthy();
Expand All @@ -63,7 +67,9 @@ describe('CheckboxV1 Functional Testing', () => {
await CheckboxV1PageObject.click(CheckboxV1PageObject._primaryComponent);

/* Validate the Checkbox is toggled OFF */
expect(await CheckboxV1PageObject.didAssertPopup()).toBeFalsy(CheckboxV1PageObject.ERRORMESSAGE_ASSERT);
expect(await CheckboxV1PageObject.didAssertPopup())
.withContext(CheckboxV1PageObject.ERRORMESSAGE_ASSERT)
.toBeFalsy();
await expect(await CheckboxV1PageObject.waitForCheckboxToggleAndroid(false, 'Checkbox should have toggled off.')).toBeTruthy();
expect(await CheckboxV1PageObject.isCheckboxCheckedAndroid()).toBeFalsy();
});
Expand Down
18 changes: 13 additions & 5 deletions apps/E2E/src/CheckboxV1/specs/CheckboxV1.spec.win.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('CheckboxV1 Testing Initialization', () => {
/* Expand E2E section */
expect(await CheckboxV1PageObject.enableE2ETesterMode()).toBeTrue();

await expect(await CheckboxV1PageObject.didAssertPopup()).toBeFalsy(CheckboxV1PageObject.ERRORMESSAGE_ASSERT); // Ensure no asserts popped up
await expect(await CheckboxV1PageObject.didAssertPopup()).withContext(CheckboxV1PageObject.ERRORMESSAGE_ASSERT); // Ensure no asserts popped u.toBeFalsy()p
});
});

Expand Down Expand Up @@ -80,7 +80,9 @@ describe('CheckboxV1 Functional Testing', () => {

it("Click the primary checkbox. Validate that the Checkbox toggles correctly AND calls the user's onChange() callback.", async () => {
/* Validate the Checkbox is initially toggled OFF */
await expect(await CheckboxV1PageObject.isCheckboxChecked()).toBeFalsy('The primary checkbox should initially be toggled off.');
await expect(await CheckboxV1PageObject.isCheckboxChecked())
.withContext('The primary checkbox should initially be toggled off.')
.toBeFalsy();

/* Click on the Checkbox to toggle on */
await CheckboxV1PageObject.click(CheckboxV1PageObject._primaryComponent);
Expand All @@ -101,12 +103,16 @@ describe('CheckboxV1 Functional Testing', () => {
await CheckboxV1PageObject.waitForCheckboxToggle(false, 'The primary checkbox should have been toggled off via click.'),
).toBeTruthy();

await expect(await CheckboxV1PageObject.didAssertPopup()).toBeFalsy(CheckboxV1PageObject.ERRORMESSAGE_ASSERT);
await expect(await CheckboxV1PageObject.didAssertPopup())
.withContext(CheckboxV1PageObject.ERRORMESSAGE_ASSERT)
.toBeFalsy();
});

it("Press 'Space' on the primary checkbox. Validate that the Checkbox toggles correctly AND calls the user's onChange() callback.", async () => {
/* Validate the Checkbox is initially toggled OFF */
await expect(await CheckboxV1PageObject.isCheckboxChecked()).toBeFalsy('The primary checkbox should initially be toggled off.');
await expect(await CheckboxV1PageObject.isCheckboxChecked())
.withContext('The primary checkbox should initially be toggled off.')
.toBeFalsy();

/* Presses the "space bar" to select the Checkbox */
await CheckboxV1PageObject.sendKeys(CheckboxV1PageObject._primaryComponent, [Keys.SPACE]);
Expand All @@ -126,6 +132,8 @@ describe('CheckboxV1 Functional Testing', () => {
await CheckboxV1PageObject.waitForCheckboxToggle(false, "The primary checkbox should have been toggled off via 'Space' press."),
).toBeTruthy();

await expect(await CheckboxV1PageObject.didAssertPopup()).toBeFalsy(CheckboxV1PageObject.ERRORMESSAGE_ASSERT);
await expect(await CheckboxV1PageObject.didAssertPopup())
.withContext(CheckboxV1PageObject.ERRORMESSAGE_ASSERT)
.toBeFalsy();
});
});
8 changes: 6 additions & 2 deletions apps/E2E/src/Chip/specs/Chip.spec.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ describe('Chip Testing Initialization', () => {
/* Expand E2E section */
expect(await ChipPageObject.enableE2ETesterMode()).toBeTrue();

await expect(await ChipPageObject.didAssertPopup()).toBeFalsy(ChipPageObject.ERRORMESSAGE_ASSERT);
await expect(await ChipPageObject.didAssertPopup())
.withContext(ChipPageObject.ERRORMESSAGE_ASSERT)
.toBeFalsy();
});
});

Expand All @@ -35,6 +37,8 @@ describe('Chip Functional Testing', () => {
'OnPress callback failing.',
);
await expect(await ChipPageObject.verifyTextContent(CHIP_CALLBACK_TEXT_END_STATE)).toBeTruthy();
await expect(await ChipPageObject.didAssertPopup()).toBeFalsy(ChipPageObject.ERRORMESSAGE_ASSERT);
await expect(await ChipPageObject.didAssertPopup())
.withContext(ChipPageObject.ERRORMESSAGE_ASSERT)
.toBeFalsy();
});
});
4 changes: 3 additions & 1 deletion apps/E2E/src/ColorTokens/specs/ColorTokens.spec.win.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ describe('Color Tokens Testing Initialization', () => {
it('Click and navigate to Color Tokens test page', async () => {
expect(await ColorTokenPageObject.navigateToPageAndLoadTests()).toBeTrue();

await expect(await ColorTokenPageObject.didAssertPopup()).toBeFalsy(ColorTokenPageObject.ERRORMESSAGE_ASSERT); // Ensure no asserts popped up
await expect(await ColorTokenPageObject.didAssertPopup())
.withContext(ColorTokenPageObject.ERRORMESSAGE_ASSERT)
.toBeFalsy(); // Ensure no asserts popped up
});
});
Loading

0 comments on commit a564cf4

Please sign in to comment.