Skip to content

Commit

Permalink
fix(core): prepend locale for redirected urls in tests (bigcommerce#1374
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jorgemoya authored Sep 16, 2024
1 parent be4eaf8 commit 1f76f61
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .changeset/clever-fans-tickle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@bigcommerce/catalyst-core": patch
---

Prepend locale for redirected urls in tests.
More info: https://github.com/amannn/next-intl/issues/1335
4 changes: 3 additions & 1 deletion core/tests/fixtures/utils/account/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ export class Account {
await this.page.getByLabel('Email').fill(this.email);
await this.page.getByLabel('Password').fill(this.password);
await this.page.getByRole('button', { name: 'Log in' }).click();
await this.page.waitForURL('/account/');
// Prepending locale to URL as a workaround for issue in next-intl
// More info: https://github.com/amannn/next-intl/issues/1335
await this.page.waitForURL('/en/account/');
}

async logout() {
Expand Down
4 changes: 3 additions & 1 deletion core/tests/ui/e2e/account.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ test('My Account tabs are displayed and clickable', async ({ page, account }) =>

await customer.login();

await expect(page).toHaveURL('/account/');
// Prepending locale to URL as a workaround for issue in next-intl
// More info: https://github.com/amannn/next-intl/issues/1335
await expect(page).toHaveURL('/en/account/');
await expect(page.getByRole('link', { name: 'Addresses' })).toBeVisible();
await expect(page.getByRole('link', { name: 'Account settings' })).toBeVisible();

Expand Down
4 changes: 3 additions & 1 deletion core/tests/ui/e2e/login.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ test('Account login and logout', async ({ page, account }) => {
await page.getByLabel('Password').fill(customer.password);
await page.getByRole('button', { name: 'Log in' }).click();

await page.waitForURL('/account/');
await page.waitForURL('/en/account/');

await expect(page.getByRole('heading', { name: 'My Account' })).toBeVisible();

await customer.logout();

// Prepending locale to URL as a workaround for issue in next-intl
// More info: https://github.com/amannn/next-intl/issues/1335
await page.waitForURL('/en/login/');

await expect(page.getByRole('heading', { name: 'Log in' })).toBeVisible();
Expand Down

0 comments on commit 1f76f61

Please sign in to comment.