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 30 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
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ jobs:
- run: pnpm playwright install ${{ matrix.e2e-browser }}
- run: pnpm run sync-all
- run: pnpm test:kit
- 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 +117,8 @@ jobs:
- run: pnpm playwright install ${{ matrix.e2e-browser }}
- run: pnpm run sync-all
- 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
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,11 @@
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 + '',
{ path: '/' }
);

return json({});
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
/** @type {import('./$types').PageData} */
export let data;

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

<p>Count is {data.count}</p>
<button on:click={update}>update</button>
<p class="counter">Count is {data.count}</p>
<button on:click={update} data-ticker={ticker}>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,11 @@
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 + '',
{ path: '/' }
);

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,11 @@
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 + '',
{ path: '/' }
);

return json({});
}

This file was deleted.

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

test('load does not call fetch if max-age allows it', async ({ page }) => {
page.addInitScript(`
await page.addInitScript(`
window.now = 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 expect(button).toHaveAttribute('data-ticker', '2');
await expect(p).toHaveText('Count is 0');

await page.evaluate('window.now = 2500');

await button.click();
await expect(button).toHaveAttribute('data-ticker', '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
39 changes: 21 additions & 18 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,8 @@ test.describe('a11y', () => {
})
).toBe(1);

await clicknav('[href="/selection/b"]');
await clicknav('0[href="/selection/b"]');
benmccann marked this conversation as resolved.
Show resolved Hide resolved

expect(
await page.evaluate(() => {
const selection = getSelection();
Expand All @@ -98,16 +99,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 @@ -319,20 +325,18 @@ test.describe('Scrolling', () => {
expect(await page.evaluate(() => scrollY)).toBe(0);
});

test('scroll is restored after hitting the back button', async ({ baseURL, clicknav, page }) => {
test('scroll is restored after hitting the back button', async ({ clicknav, page }) => {
await page.goto('/anchor');
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');
expect(page.url()).toBe(baseURL + '/anchor#last-anchor-2');

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

await page.goBack();
await page.waitForLoadState('networkidle');

expect(page.url()).toBe(baseURL + '/anchor');
await expect(page).toHaveURL('/anchor');
expect(await page.evaluate(() => scrollY)).toEqual(0);
});

Expand Down Expand Up @@ -587,18 +591,15 @@ test.describe('Prefetching', () => {
expect(requests.filter((req) => req.endsWith('.js')).length).toBeGreaterThan(0);
}

expect(requests.includes(`${baseURL}/routing/preloading/preloaded.json`)).toBe(true);
expect(requests).toContain(`${baseURL}/routing/preloading/preloaded.json`);

requests = [];
await app.goto('/routing/preloading/preloaded');
expect(requests).toEqual([]);

try {
await app.preloadData('https://example.com');
throw new Error('Error was not thrown');
} catch (/** @type {any} */ e) {
expect(e.message).toMatch('Attempted to preload a URL that does not belong to this app');
}
await expect(app.preloadData('https://example.com')).rejects.toThrowError(
'Attempted to preload a URL that does not belong to this app'
);
});

test('chooses correct route when hash route is preloaded but regular route is clicked', async ({
Expand Down Expand Up @@ -693,8 +694,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 @@ -746,6 +748,7 @@ test.describe('Routing', () => {

test('responds to <form method="GET"> submission without reload', async ({ page }) => {
await page.goto('/routing/form-get');

expect(await page.textContent('h1')).toBe('...');
expect(await page.textContent('h2')).toBe('enter');
expect(await page.textContent('h3')).toBe('...');
Expand Down
9 changes: 2 additions & 7 deletions packages/kit/test/apps/basics/test/cross-platform/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -747,20 +747,15 @@ test.describe('Routing', () => {
await clicknav('[href="/routing/a"]');

await page.goBack();
await page.waitForLoadState('networkidle');
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.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 @@ -548,7 +548,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
Loading