Skip to content

Commit

Permalink
Merge pull request #363 from AmazeeLabs/cleanup-awaits
Browse files Browse the repository at this point in the history
test: add missing awaits, remove extra awaits
  • Loading branch information
Leksat authored Oct 29, 2024
2 parents 030bdd9 + 6661a26 commit d8f899a
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 19 deletions.
10 changes: 5 additions & 5 deletions tests/e2e/specs/drupal/content-hub.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { websiteUrl } from '../../helpers/url';

test.describe('content hub', () => {
test.beforeEach(async ({ page }) => {
page.emulateMedia({ reducedMotion: 'reduce' });
await page.emulateMedia({ reducedMotion: 'reduce' });
});
test('lists pages in alphabetic order', async ({ page }) => {
await page.goto(websiteUrl('/en/content-hub'));
const content = await page.getByRole('main');
const content = page.getByRole('main');
const heading = page.getByRole('heading', {
name: 'Architecture',
level: 5,
Expand All @@ -20,7 +20,7 @@ test.describe('content hub', () => {

test('allows to switch pages', async ({ page }) => {
await page.goto(websiteUrl('/en/content-hub'));
const content = await page.getByRole('main');
const content = page.getByRole('main');

await expect(
content.getByRole('heading', {
Expand All @@ -46,7 +46,7 @@ test.describe('content hub', () => {

test('allows to search for items', async ({ page }) => {
await page.goto(websiteUrl('/en/content-hub'));
const content = await page.getByRole('main');
const content = page.getByRole('main');
await content.getByPlaceholder('Keyword').fill('technologies');
await content.getByRole('button', { name: 'Search' }).click();
await expect(
Expand All @@ -68,7 +68,7 @@ test.describe('content hub', () => {
await page.goto(websiteUrl('/en/content-hub'));
// Change language to German.
await quickActions.changeLanguageTo(SiteLanguage.Deutsch);
const content = await page.getByRole('main');
const content = page.getByRole('main');
await expect(
content.getByRole('heading', {
name: 'Architektur',
Expand Down
7 changes: 5 additions & 2 deletions tests/e2e/specs/drupal/entity-usage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ test.describe('entity-usage', () => {

test('media usage works with inline doc links', async ({ page }) => {
await page.goto(cmsUrl('/admin/content/media'));
page.locator('div.view-content').getByText('Example DOCX document').click();
page.locator('a.tabs__link').getByText('Usage').click();
await page
.locator('div.view-content')
.getByText('Example DOCX document')
.click();
await page.locator('a.tabs__link').getByText('Usage').click();
await expect(
page.locator('table').getByText('Page with links'),
).toBeVisible();
Expand Down
10 changes: 5 additions & 5 deletions tests/e2e/specs/drupal/homepage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { websiteUrl } from '../../helpers/url';
test.describe('the homepage', () => {
test('exists in english', async ({ page }) => {
await page.goto(websiteUrl('/en'));
const content = await page.getByRole('main');
const content = page.getByRole('main');
await expect(
content.getByRole('heading', { name: 'Architecture' }),
).toBeVisible();
Expand All @@ -15,7 +15,7 @@ test.describe('the homepage', () => {
test('exists in german', async ({ page }) => {
const quickActions = new QuickActions(page);
await page.goto(websiteUrl('/en'));
const content = await page.getByRole('main');
const content = page.getByRole('main');
await quickActions.changeLanguageTo(SiteLanguage.Deutsch);
await expect(
content.getByRole('heading', { name: 'Architektur' }),
Expand All @@ -24,12 +24,12 @@ test.describe('the homepage', () => {

test('redirects to root path on direct access', async ({ page }) => {
await page.goto(websiteUrl('/en/architecture'));
await expect(page.url()).toBe(websiteUrl('/en'));
expect(page.url()).toBe(websiteUrl('/en'));
});

test('it redirects to english by default', async ({ page }) => {
await page.goto(websiteUrl('/'));
const content = await page.getByRole('main');
const content = page.getByRole('main');
await expect(
content.getByRole('heading', { name: 'Architecture' }),
).toBeVisible();
Expand All @@ -41,7 +41,7 @@ test.describe('the homepage', () => {
const context = await browser.newContext({ locale: 'de-DE' });
const page = await context.newPage();
await page.goto(websiteUrl('/'));
const content = await page.getByRole('main');
const content = page.getByRole('main');
await expect(
content.getByText('Architektur', { exact: true }),
).toBeVisible();
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/specs/drupal/inquiry.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ test.describe('inquiry (mutation example)', () => {

test('invalid e-mail address', async ({ page }) => {
await page.goto(websiteUrl('/en/inquiry'));
const content = await page.getByRole('main');
const content = page.getByRole('main');
await content.getByPlaceholder('Name').fill('John Doe');
await content.getByPlaceholder('Email').fill('john');
await content.getByPlaceholder('Subject').fill('Lorem ipsum');
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/specs/drupal/notfound.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import { websiteUrl } from '../../helpers/url';
test.describe('not found pages', () => {
test('are english by default', async ({ page }) => {
await page.goto(websiteUrl('/i-dont-exist'));
const content = await page.getByRole('main');
const content = page.getByRole('main');
await expect(
content.getByText('The requested page is currently in the bathroom.'),
).toBeVisible();
});
test('are german if the prefix is there', async ({ page }) => {
await page.goto(websiteUrl('/de/i-dont-exist'));
const content = await page.getByRole('main');
const content = page.getByRole('main');
await expect(
content.getByText('Die Seite die sie gerne hätten is grade nicht da.'),
).toBeVisible();
Expand Down
3 changes: 2 additions & 1 deletion tests/e2e/specs/drupal/preview-editor-sidebar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ test.describe('instant preview - toggle editor sidebar', () => {
test('toggle the preview editor sidebar', async ({ page }) => {
await page.goto(cmsUrl('/admin/content'));
await page.getByRole('link', { name: 'Add content' }).click();
await (await page.locator('.layout-region--node-main'))
await page
.locator('.layout-region--node-main')
.getByLabel('Title', { exact: true })
.fill('Instant preview sidebar test');
await page.locator('#edit-submit').click();
Expand Down
3 changes: 2 additions & 1 deletion tests/e2e/specs/drupal/preview.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ test.describe('instant preview', () => {
test('display an unpublished page in an iframe', async ({ page }) => {
await page.goto(cmsUrl('/admin/content'));
await page.getByRole('link', { name: 'Add content' }).click();
await (await page.locator('.layout-region--node-main'))
await page
.locator('.layout-region--node-main')
.getByLabel('Title', { exact: true })
.fill('Instant preview test');
await page.locator('#edit-submit').click();
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/specs/drupal/redirects.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { websiteUrl } from '../../helpers/url';
test.describe('drupal redirects', () => {
test('are detected', async ({ page }) => {
const response = await page.goto(websiteUrl('/node/1'));
await expect(response?.status()).toBe(200);
await expect(page.url).not.toBe(websiteUrl('/node/1'));
expect(response?.status()).toBe(200);
expect(page.url).not.toBe(websiteUrl('/node/1'));
});
});

0 comments on commit d8f899a

Please sign in to comment.