Skip to content

Commit

Permalink
Ugh need await in every expect 🤦‍♂️🤦‍♂️🤦‍♂️
Browse files Browse the repository at this point in the history
  • Loading branch information
cheeaun committed Feb 27, 2022
1 parent 033aece commit d2c2783
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions e2e-test/localisation.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ test.describe('Localization', () => {
const page = await context.newPage();
await page.goto(baseURL);
const selector = page.locator('.locale-selector');
expect(selector).toBeVisible();
await expect(selector).toBeVisible();

const enLink = page.locator('a[hreflang="en"]');
expect(enLink).toHaveClass(/selected/i);
const zhcnLink = page.locator('a[hreflang="zh-CN"]');
expect(zhcnLink).not.toHaveClass(/selected/i);
const enLink = selector.locator('a[hreflang="en"]');
await expect(enLink).toHaveClass(/selected/i);
const zhcnLink = selector.locator('a[hreflang="zh-CN"]');
await expect(zhcnLink).not.toHaveClass(/selected/i);
});

test('Load Chinese if Chinese locale', async ({ browser, baseURL }) => {
Expand All @@ -23,12 +23,12 @@ test.describe('Localization', () => {
const page = await context.newPage();
await page.goto(baseURL);
const selector = page.locator('.locale-selector');
expect(selector).toBeVisible();
await expect(selector).toBeVisible();

const zhcnLink = page.locator('a[hreflang="zh-CN"]');
expect(zhcnLink).toHaveClass(/selected/i);
const enLink = page.locator('a[hreflang="en"]');
expect(enLink).not.toHaveClass(/selected/i);
const zhcnLink = selector.locator('a[hreflang="zh-CN"]');
await expect(zhcnLink).toHaveClass(/selected/i);
const enLink = selector.locator('a[hreflang="en"]');
await expect(enLink).not.toHaveClass(/selected/i);
});

test('Load English if for other locale', async ({ browser, baseURL }) => {
Expand All @@ -38,11 +38,11 @@ test.describe('Localization', () => {
const page = await context.newPage();
await page.goto(baseURL);
const selector = page.locator('.locale-selector');
expect(selector).toBeVisible();
await expect(selector).toBeVisible();

const enLink = page.locator('a[hreflang="en"]');
expect(enLink).toHaveClass(/selected/i);
const zhcnLink = page.locator('a[hreflang="zh-CN"]');
expect(zhcnLink).not.toHaveClass(/selected/i);
const enLink = selector.locator('a[hreflang="en"]');
await expect(enLink).toHaveClass(/selected/i);
const zhcnLink = selector.locator('a[hreflang="zh-CN"]');
await expect(zhcnLink).not.toHaveClass(/selected/i);
});
});

0 comments on commit d2c2783

Please sign in to comment.