Skip to content

Commit

Permalink
test: refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
juliajforesti committed Oct 23, 2024
1 parent d93fd35 commit 05d54fd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
20 changes: 12 additions & 8 deletions apps/meteor/tests/e2e/feature-preview.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ test.describe.serial('feature preview', () => {
test.beforeEach(async ({ page }) => {
poHomeChannel = new HomeChannel(page);
poAccountProfile = new AccountProfile(page);

await page.goto('/account/feature-preview');
});

test('should show "Message" and "Navigation" feature sections', async ({ page }) => {
await page.goto('/account/feature-preview');

await expect(page.getByRole('button', { name: 'Message' })).toBeVisible();
await expect(page.getByRole('button', { name: 'Navigation' })).toBeVisible();
});
Expand Down Expand Up @@ -54,14 +54,18 @@ test.describe.serial('feature preview', () => {
});

test('should be able to toggle "Enhanced navigation" feature', async ({ page }) => {
await page.getByRole('button', { name: 'Navigation' }).click();
const checkbox = poAccountProfile.checkboxByLabelText('Enhanced navigation');
await expect(checkbox).toBeChecked();
await checkbox.click();
await expect(checkbox).not.toBeChecked();
await page.goto('/account/feature-preview');

await poAccountProfile.getAccordionItemByName('Navigation').click();
const newNavigationCheckbox = poAccountProfile.getCheckboxByLabelText('Enhanced navigation');
await expect(newNavigationCheckbox).toBeChecked();
await newNavigationCheckbox.click();
await expect(newNavigationCheckbox).not.toBeChecked();
});

test('should be rendering new UI with "Enhanced navigation"', async () => {
test('should be rendering new UI with "Enhanced navigation"', async ({ page }) => {
await page.goto('/account/feature-preview');

await expect(poHomeChannel.navbar.navbar).toBeVisible();
});

Expand Down
6 changes: 5 additions & 1 deletion apps/meteor/tests/e2e/page-objects/account-profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ export class AccountProfile {
return this.page.locator("role=button[name='Save changes']");
}

checkboxByLabelText(name: string): Locator {
getAccordionItemByName(name: string): Locator {
return this.page.getByRole('button', { name, exact: true });
}

getCheckboxByLabelText(name: string): Locator {
return this.page.locator('label', { has: this.page.getByRole('checkbox', { name }) });
}
}

0 comments on commit 05d54fd

Please sign in to comment.