Skip to content

Commit

Permalink
fix: env_file playwright tests failing due to animations (#505)
Browse files Browse the repository at this point in the history
  • Loading branch information
bamsargeant authored Dec 15, 2023
1 parent 7058860 commit 7eac90f
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions tests/env_file.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
import { expect, test } from '@playwright/test';
import { expect, test, type Page } from '@playwright/test';

const iframe_selector = 'iframe[src*="webcontainer.io/"]';

async function disableAnimations(page: Page) {
await page.addStyleTag({
content: `
*, *::before, *::after {
animation-duration: 0s !important;
transition-duration: 0s !important;
}
`
});
}

test.describe.configure({ mode: 'parallel' });

test('.env file: no timeout error occurs when switching a tutorials without a .env file to one with it', async ({
Expand All @@ -11,15 +22,18 @@ test('.env file: no timeout error occurs when switching a tutorials without a .e

await page.goto('/tutorial/welcome-to-svelte');

// disable animations to prevent flakiness
await disableAnimations(page);

const iframe_locator = page.frameLocator(iframe_selector);

// wait for the iframe to load
await iframe_locator.getByText('Welcome!').waitFor();

// switch to another tutorial with a .env file
await page.click('header > h1', { delay: 200 });
await page.locator('button', { hasText: 'Part 4: Advanced SvelteKit' }).click({ delay: 200 });
await page.locator('button', { hasText: 'Environment variables' }).click({ delay: 200 });
await page.click('header > button > h1', { delay: 200 });
await page.getByRole('button', { name: 'Part 4: Advanced SvelteKit' }).click({ delay: 200 });
await page.getByRole('button', { name: 'Environment variables' }).click({ delay: 200 });
await page.locator('a', { hasText: '$env/static/private' }).click({ delay: 200 });

// wait for the iframe to load
Expand All @@ -41,15 +55,18 @@ test('.env file: environment variables are available when switching a tutorial w

await page.goto('/tutorial/welcome-to-svelte');

// disable animations to prevent flakiness
await disableAnimations(page);

const iframe_locator = page.frameLocator(iframe_selector);

// wait for the iframe to load
await iframe_locator.getByText('Welcome!').waitFor();

// switch to another tutorial with a .env file
await page.click('header > h1', { delay: 200 });
await page.locator('button', { hasText: 'Part 4: Advanced SvelteKit' }).click({ delay: 200 });
await page.locator('button', { hasText: 'Environment variables' }).click({ delay: 200 });
await page.click('header > button > h1', { delay: 200 });
await page.getByRole('button', { name: 'Part 4: Advanced SvelteKit' }).click({ delay: 200 });
await page.getByRole('button', { name: 'Environment variables' }).click({ delay: 200 });
await page.locator('a', { hasText: '$env/dynamic/private' }).click({ delay: 200 });

// wait for the iframe to load
Expand Down

1 comment on commit 7eac90f

@vercel
Copy link

@vercel vercel bot commented on 7eac90f Dec 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.