Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: speed up CI a bit (hopefully) #9731

Merged
merged 31 commits into from
Jul 14, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
e42e772
disable tracing
gtm-nayan Apr 22, 2023
3f9af22
formatting
gtm-nayan May 10, 2023
45c3265
remove unused endpoint
gtm-nayan May 10, 2023
17b49d0
disable TS loader for playwright
gtm-nayan May 10, 2023
1f91498
fix flake in hash test
gtm-nayan May 10, 2023
74ed328
fix type check
gtm-nayan May 10, 2023
b7055ff
try to surface warnings from pnpm prefixed logs
gtm-nayan May 11, 2023
f263559
well that didn't do what I wanted it to
gtm-nayan May 11, 2023
5839dea
whoops
gtm-nayan May 11, 2023
ce404e8
fix lint
gtm-nayan May 11, 2023
5eddbb3
gitignore slash consistency
gtm-nayan May 11, 2023
8189425
..
gtm-nayan May 11, 2023
1505e77
how did you get there
gtm-nayan May 11, 2023
8973f30
remove expect-error
May 17, 2023
614f2dd
revert tracing change
gtm-nayan May 17, 2023
3249355
use local state
gtm-nayan May 18, 2023
11868fb
add comments
gtm-nayan May 18, 2023
5da35a9
Update packages/kit/test/apps/basics/test/client.test.js
gtm-nayan Jun 28, 2023
5a58cd3
Merge branch 'master' into experiment-time-ci
gtm-nayan Jun 29, 2023
93e5933
lint
gtm-nayan Jun 29, 2023
6965313
Merge branch 'main' into experiment-time-ci
eltigerchino Dec 20, 2023
b6b4075
Merge branch 'main' into experiment-time-ci
Rich-Harris Jan 10, 2024
c14b83f
merge main
benmccann Jul 14, 2024
62f75c2
remove use of undocumented option
benmccann Jul 14, 2024
622ceb3
remove networkidle calls
benmccann Jul 14, 2024
69ecfc2
lint
benmccann Jul 14, 2024
e440bb6
remove new lines
benmccann Jul 14, 2024
b437da5
sveltekit 2 migration fix
benmccann Jul 14, 2024
a8ad7dc
format
benmccann Jul 14, 2024
72a71ef
two more
benmccann Jul 14, 2024
6c5128c
Update packages/kit/test/apps/basics/test/cross-platform/client.test.js
benmccann Jul 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
env:
# we call `pnpm playwright install` instead
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1'
PW_DISABLE_TS_ESM: '1'

# cancel in-progress runs on new commits to same PR (gitub.event.number)
concurrency:
Expand Down Expand Up @@ -60,6 +61,10 @@ jobs:
- run: pnpm install --frozen-lockfile
- run: pnpm playwright install ${{ matrix.e2e-browser }}
- run: pnpm test

- name: Print flaky test report
run: node scripts/print-flaky-test-report.js

- name: Archive test results
if: failure()
shell: bash
Expand Down Expand Up @@ -115,6 +120,10 @@ jobs:
- run: pnpm install --frozen-lockfile
- run: pnpm playwright install ${{ matrix.e2e-browser }}
- run: pnpm test:cross-platform:${{ matrix.mode }}

- name: Print flaky test report
run: node scripts/print-flaky-test-report.js

- name: Archive test results
if: failure()
shell: bash
Expand Down
1 change: 1 addition & 0 deletions packages/kit/test/apps/basics/src/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ declare global {
mounted: number;
fulfil_navigation: (value: any) => void;
promise: Promise<any>;
update_state: number;
Copy link
Member

Choose a reason for hiding this comment

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

maybe state_counter would be a better name?

PUBLIC_DYNAMIC: string;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
}
</script>

<p>Count is {data.count}</p>
<p class="counter">Count is {data.count}</p>
<button on:click={update}>update</button>
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { json } from '@sveltejs/kit';
import { count } from '../state.js';

export function GET({ setHeaders }) {
export function GET({ setHeaders, cookies }) {
setHeaders({ 'cache-control': 'public, max-age=4', age: '2' });

const count = +(cookies.get('cache-control-bust-count') ?? 0);

return json({ count });
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { json } from '@sveltejs/kit';
import { increment } from '../state.js';

export function GET() {
increment();
export function GET({ cookies }) {
cookies.set('cache-control-bust-count', +(cookies.get('cache-control-bust-count') ?? 0) + 1 + '');

return json({});
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
export let data;

async function update() {
window.update_state += 1;
await fetch('/load/cache-control/default/increment');
invalidate('/load/cache-control/default/count');
await invalidate('/load/cache-control/default/count');
window.update_state += 1;
}
</script>

<p>Count is {data.count}</p>
<p class="counter">Count is {data.count}</p>
<button on:click={update}>update</button>
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { json } from '@sveltejs/kit';
import { count } from '../state.js';

export function GET({ setHeaders }) {
export function GET({ setHeaders, cookies }) {
setHeaders({ 'cache-control': 'public, max-age=4', age: '2' });

const count = +(cookies.get('cache-control-default-count') ?? 0);

return json({ count });
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { json } from '@sveltejs/kit';
import { increment } from '../state.js';

export function GET() {
increment();
export function GET({ cookies }) {
cookies.set(
'cache-control-default-count',
+(cookies.get('cache-control-default-count') ?? 0) + 1 + ''
);

return json({});
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
}
</script>

<p>Count is {data.count}</p>
<p class="counter">Count is {data.count}</p>
<button on:click={update}>update</button>
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { json } from '@sveltejs/kit';
import { count } from '../state.js';

export function GET({ setHeaders }) {
export function GET({ setHeaders, cookies }) {
setHeaders({ 'cache-control': 'public, max-age=4', age: '2' });

const count = +(cookies.get('cache-control-force-count') ?? 0);

return json({ count });
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { json } from '@sveltejs/kit';
import { increment } from '../state.js';

export function GET() {
increment();
export function GET({ cookies }) {
cookies.set(
'cache-control-force-count',
+(cookies.get('cache-control-force-count') ?? 0) + 1 + ''
);

return json({});
}

This file was deleted.

32 changes: 20 additions & 12 deletions packages/kit/test/apps/basics/test/client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,35 +143,43 @@ test.describe('Load', () => {
});

test('load does not call fetch if max-age allows it', async ({ page }) => {
page.addInitScript(`
// update_state is used to ensure we start waiting at the right time
gtm-nayan marked this conversation as resolved.
Show resolved Hide resolved
await page.addInitScript(`
window.now = 0;
window.update_state = 0;
window.performance.now = () => now;
`);

await page.goto('/load/cache-control/default');
await expect(page.getByText('Count is 0')).toBeVisible();
await page.locator('button').click();
await page.waitForLoadState('networkidle');
await expect(page.getByText('Count is 0')).toBeVisible();

await page.evaluate(() => (window.now = 2500));
const button = page.locator('button');
const p = page.locator('p.counter');

await page.locator('button').click();
await expect(page.getByText('Count is 2')).toBeVisible();
await button.click();
await page.waitForFunction('window.update_state === 2');
await expect(p).toHaveText('Count is 0');

await page.evaluate('window.now += 2000');

await button.click();
await page.waitForFunction('window.update_state === 4');
await expect(p).toHaveText('Count is 2');
});

test('load does ignore ttl if fetch cache options says so', async ({ page }) => {
await page.goto('/load/cache-control/force');
await expect(page.getByText('Count is 0')).toBeVisible();
const p = page.locator('p.counter');
await expect(p).toHaveText('Count is 0');
await page.locator('button').click();
await expect(page.getByText('Count is 1')).toBeVisible();
await expect(p).toHaveText('Count is 1');
});

test('load busts cache if non-GET request to resource is made', async ({ page }) => {
await page.goto('/load/cache-control/bust');
await expect(page.getByText('Count is 0')).toBeVisible();
const p = page.locator('p.counter');
await expect(p).toHaveText('Count is 0');
await page.locator('button').click();
await expect(page.getByText('Count is 1')).toBeVisible();
await expect(p).toHaveText('Count is 1');
});

test('__data.json has cache-control: private, no-store', async ({ page, clicknav }) => {
Expand Down
34 changes: 23 additions & 11 deletions packages/kit/test/apps/basics/test/cross-platform/client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ test.describe('a11y', () => {
})
).toBe(1);

await clicknav('[href="/selection/b"]');
await clicknav('[href="/selection/b"]', {
waitUntil: 'networkidle'
Copy link
Member

Choose a reason for hiding this comment

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

why do we need this?

Copy link
Contributor Author

@gtm-nayan gtm-nayan Jun 28, 2023

Choose a reason for hiding this comment

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

IIRC, this was failing in safari when I had turned off tracing because the evaluation was happening before the text was selected/deselected

});

expect(
await page.evaluate(() => {
const selection = getSelection();
Expand All @@ -98,16 +101,21 @@ test.describe('a11y', () => {
});

test('autofocus from previous page is ignored', async ({ page, clicknav }) => {
page.addInitScript(`
await page.addInitScript(`
window.active = null;
window.addEventListener('focusin', () => window.active = document.activeElement);
`);

await page.goto('/accessibility/autofocus/a');
await clicknav('[href="/"]');

expect(await page.evaluate(() => (window.active || {}).nodeName)).toBe('BODY');
expect(await page.evaluate(() => (document.activeElement || {}).nodeName)).toBe('BODY');
expect(
await page.evaluate(
// @ts-expect-error
() => window.active?.nodeName
)
).toBe('BODY');
expect(await page.evaluate(() => document.activeElement?.nodeName)).toBe('BODY');
});
});

Expand Down Expand Up @@ -302,13 +310,12 @@ test.describe('Scrolling', () => {
await page.locator('#scroll-anchor').click();
const originalScrollY = /** @type {number} */ (await page.evaluate(() => scrollY));
await clicknav('#routing-page');
await page.goBack();
await page.waitForLoadState('networkidle');
await page.goBack({ waitUntil: 'networkidle' });

expect(page.url()).toBe(baseURL + '/anchor#last-anchor-2');
expect(await page.evaluate(() => scrollY)).toEqual(originalScrollY);

await page.goBack();
await page.waitForLoadState('networkidle');
await page.goBack({ waitUntil: 'networkidle' });

expect(page.url()).toBe(baseURL + '/anchor');
expect(await page.evaluate(() => scrollY)).toEqual(0);
Expand Down Expand Up @@ -507,7 +514,9 @@ test.describe.serial('Errors', () => {

test.describe('Prefetching', () => {
test('prefetches programmatically', async ({ baseURL, page, app }) => {
await page.goto('/routing/a');
await page.goto('/routing/a', {
waitUntil: 'networkidle'
});

/** @type {string[]} */
let requests = [];
Expand Down Expand Up @@ -632,8 +641,9 @@ test.describe('Routing', () => {
await page.locator('[href="#hash-target"]').click();
await clicknav('[href="/routing/hashes/b"]');

await expect(page.locator('h1')).toHaveText('b');
await page.goBack();
expect(await page.textContent('h1')).toBe('a');
await expect(page.locator('h1')).toHaveText('a');
});

test('replaces state if the data-sveltekit-replacestate router option is specified for the hash link', async ({
Expand Down Expand Up @@ -684,7 +694,9 @@ test.describe('Routing', () => {
});

test('responds to <form method="GET"> submission without reload', async ({ page }) => {
await page.goto('/routing/form-get');
await page.goto('/routing/form-get', {
waitUntil: 'networkidle'
});
expect(await page.textContent('h1')).toBe('...');
expect(await page.textContent('h2')).toBe('enter');
expect(await page.textContent('h3')).toBe('...');
Expand Down
13 changes: 4 additions & 9 deletions packages/kit/test/apps/basics/test/cross-platform/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -738,21 +738,16 @@ test.describe('Routing', () => {
await page.goto('/routing');
await clicknav('[href="/routing/a"]');

await page.goBack();
await page.waitForLoadState('networkidle');
await page.goBack({ waitUntil: 'networkidle' });
Copy link
Member

Choose a reason for hiding this comment

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

don't we override goBack to ensure its safe functioning? if that's not working we should probably fix it in the generic test fixture so that it works everywhere

expect(await page.textContent('h1')).toBe('Great success!');
});

test('focus works if page load has hash', async ({ page, browserName }) => {
await page.goto('/routing/hashes/target#p2');
await page.goto('/routing/hashes/target#p2', { waitUntil: 'networkidle' });

await page.keyboard.press(browserName === 'webkit' ? 'Alt+Tab' : 'Tab');
await page.waitForTimeout(50); // give browser a bit of time to complete the native behavior of the key press
expect(
await page.evaluate(
() => document.activeElement?.textContent || 'ERROR: document.activeElement not set'
)
).toBe('next focus element');

await page.waitForSelector('button:focus');
});

test('focus works when navigating to a hash on the same page', async ({ page, browserName }) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/test/apps/basics/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ test.describe('Load', () => {
}) => {
if (javaScriptEnabled) {
await page.goto('/prerendering/prerendered-endpoint');
await page.click('a', { noWaitAfter: true });
await page.click('a');
} else {
await page.goto('/prerendering/prerendered-endpoint/from-handle-hook');
}
Expand Down
4 changes: 2 additions & 2 deletions packages/kit/test/apps/embed/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ test.describe('embed', () => {
await page.goto('/embed');

if (javaScriptEnabled) {
expect(await page.textContent('[data-testid="a"]')).toBe('a (browser)');
expect(await page.textContent('[data-testid="b"]')).toBe('b (browser)');
await expect(page.getByTestId('a')).toHaveText('a (browser)');
await expect(page.getByTestId('b')).toHaveText('b (browser)');
} else {
expect(await page.textContent('[data-testid="a"]')).toBe('a (server)');
expect(await page.textContent('[data-testid="b"]')).toBe('b (server)');
Expand Down
15 changes: 11 additions & 4 deletions packages/kit/test/github-flaky-warning-reporter.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { appendFileSync } from 'node:fs';

/**
* @class
* @implements {import('@playwright/test/reporter').Reporter}
Expand All @@ -24,12 +26,17 @@ export default class GithubFlakyWarningReporter {
}

onEnd() {
this._flaky.forEach(({ file, line, title, message }) => {
console.log(`::warning file=${file},line=${line},title=${title}::${message}`);
});
const output = this._flaky
.map(
({ file, line, title, message }) =>
`::warning file=${file},line=${line},title=${title}::${message}\n`
)
.join('');

appendFileSync(new URL('../../../_tmp_flaky_test_output.txt', import.meta.url), output);
}

printsToStdio() {
return true;
return false;
}
}
Loading