-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Save an image in test server public directory * Rename e2e tests with consistent naming scheme * server.js: Support POST requests with JSON body * Define FUDGE factor for assertions * Define e2e tests: images * Define e2e test: static * Define e2e test: cpu * Define e2e tests: scripts * Define e2e test: iframe * Define e2e tests: react * Remove accidentally copy-pasted comments :sweat-smile: * Add "Vary: *" header to express responses to convince Safari not to cache * Refactor: Don't use module type scripts * Express server can load files from node_modules * React tests shouldn't depend on internet connection * Group e2e test spec and html files * fixup! Define e2e test: static * Bugfix: waitForLoadingImages cannot report a time before window.onload * Update tests with new results * Define e2e test cases: composition * Define e2e tests: invisible * Define e2e tests: error * fixup! df3aaab * Define e2e tests: interaction * fixup! Define e2e test cases: composition * fixup! Define e2e tests: error * fixup! Bugfix: waitForLoadingImages cannot report a time before window.onload * Mark two additional known test failures * Playwright: Set local default to three workers and one retry * We don't need to upload any playwright artifacts * Run express service via playwright config! Co-authored-by: Andrew Hyndman <ahyndman@dropbox.com>
- Loading branch information
Showing
76 changed files
with
1,281 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import {test, expect} from '@playwright/test'; | ||
|
||
import {FUDGE} from '../../util/constants'; | ||
import {getEntries} from '../../util/entries'; | ||
|
||
const PAGELOAD_DELAY = 200; | ||
const AJAX_DELAY = 500; // see text-mutation.html | ||
|
||
test.describe('TTVC', () => { | ||
test('a mutation triggered after an AJAX request', async ({page}) => { | ||
test.fail(); // ttvc should wait until all AJAX requests have resolved before measuring | ||
await page.goto(`http://localhost:3000/test/ajax1?delay=${PAGELOAD_DELAY}`, { | ||
waitUntil: 'networkidle', | ||
}); | ||
|
||
const entries = await getEntries(page); | ||
|
||
expect(entries.length).toBe(1); | ||
expect(entries[0]).toBeGreaterThanOrEqual(PAGELOAD_DELAY + AJAX_DELAY); | ||
expect(entries[0]).toBeLessThanOrEqual(PAGELOAD_DELAY + AJAX_DELAY + FUDGE); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import {test, expect} from '@playwright/test'; | ||
|
||
import {FUDGE} from '../../util/constants'; | ||
import {getEntries} from '../../util/entries'; | ||
|
||
const PAGELOAD_DELAY = 200; | ||
const AJAX_DELAY = 500; // see text-mutation.html | ||
|
||
test.describe('TTVC', () => { | ||
test('a text-only mutation triggered after AJAX', async ({page}) => { | ||
test.fail(); // ttvc should not require mutations to mark a timestamp | ||
await page.goto(`http://localhost:3000/test/ajax2?delay=${PAGELOAD_DELAY}`, { | ||
waitUntil: 'networkidle', | ||
}); | ||
|
||
const entries = await getEntries(page); | ||
|
||
expect(entries.length).toBe(1); | ||
expect(entries[0]).toBeGreaterThanOrEqual(PAGELOAD_DELAY + AJAX_DELAY); | ||
expect(entries[0]).toBeLessThanOrEqual(PAGELOAD_DELAY + AJAX_DELAY + FUDGE); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<head> | ||
<script src="/dist/index.min.js"></script> | ||
<script src="/analytics.js"></script> | ||
</head> | ||
|
||
<body> | ||
<h1 id="h1">Hello</h1> | ||
|
||
<script> | ||
fetch('/api?delay=500', { | ||
headers: {'content-type': 'application/json'}, | ||
method: 'POST', | ||
body: JSON.stringify({name: 'jack'}), | ||
}) | ||
.then((res) => res.json()) | ||
.then((json) => { | ||
h1.textContent = `Hello ${json.name}!`; | ||
}); | ||
</script> | ||
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import {test, expect} from '@playwright/test'; | ||
|
||
import {FUDGE} from '../../util/constants'; | ||
import {getEntries, entryCountIs} from '../../util/entries'; | ||
|
||
const PAGELOAD_DELAY = 200; | ||
const AJAX_DELAY = 500; // see text-mutation.html | ||
|
||
test.describe('TTVC', () => { | ||
test('a mutation triggered after an AJAX request', async ({page}) => { | ||
test.fail(); // ttvc should wait until all AJAX requests have resolved before measuring | ||
await page.goto(`http://localhost:3000/test/ajax3?delay=${PAGELOAD_DELAY}`, { | ||
waitUntil: 'networkidle', | ||
}); | ||
|
||
const entries = await getEntries(page); | ||
|
||
expect(entries.length).toBe(1); | ||
expect(entries[0]).toBeGreaterThanOrEqual(PAGELOAD_DELAY + AJAX_DELAY); | ||
expect(entries[0]).toBeLessThanOrEqual(PAGELOAD_DELAY + AJAX_DELAY + FUDGE); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<head> | ||
<script src="/dist/index.min.js"></script> | ||
<script src="/analytics.js"></script> | ||
<script async src="/stub.js?delay=2000"></script> | ||
</head> | ||
|
||
<body> | ||
<h1 id="h1">Hello world!</h1> | ||
|
||
<script> | ||
const asyncScript = document.createElement('script'); | ||
asyncScript.src = '/mutation.js?delay=500'; | ||
|
||
fetch('/api?delay=500') | ||
.then((res) => res.text()) | ||
.then(() => document.head.appendChild(asyncScript)); | ||
</script> | ||
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import {test, expect} from '@playwright/test'; | ||
|
||
import {FUDGE} from '../../util/constants'; | ||
import {getEntries} from '../../util/entries'; | ||
|
||
const PAGELOAD_DELAY = 200; | ||
const AJAX_DELAY = 500; | ||
const SCRIPT_DELAY = 500; | ||
|
||
test.describe('TTVC', () => { | ||
test('ajax request > script load > mutation + background lazyloaded script', async ({page}) => { | ||
await page.goto(`http://localhost:3000/test/composition1?delay=${PAGELOAD_DELAY}`, { | ||
waitUntil: 'networkidle', | ||
}); | ||
|
||
const entries = await getEntries(page); | ||
expect(entries.length).toBe(1); | ||
|
||
const expectedTtvc = PAGELOAD_DELAY + AJAX_DELAY + SCRIPT_DELAY; | ||
expect(entries[0]).toBeGreaterThanOrEqual(expectedTtvc); | ||
expect(entries[0]).toBeLessThanOrEqual(expectedTtvc + FUDGE); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<head> | ||
<script src="/dist/index.min.js"></script> | ||
<script src="/analytics.js"></script> | ||
<script async src="/stub.js?delay=3000"></script> | ||
</head> | ||
|
||
<body> | ||
<h1 id="h1">Hello world!</h1> | ||
|
||
<script src="/busy.js?delay=500"></script> | ||
<script> | ||
const asyncScript = document.createElement('script'); | ||
asyncScript.src = '/mutation.js?delay=500'; | ||
|
||
fetch('/api?delay=500') | ||
.then((res) => res.text()) | ||
.then(() => { | ||
busy(200); | ||
document.head.appendChild(asyncScript); | ||
}); | ||
</script> | ||
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import {test, expect} from '@playwright/test'; | ||
|
||
import {FUDGE} from '../../util/constants'; | ||
import {getEntries} from '../../util/entries'; | ||
|
||
const PAGELOAD_DELAY = 200; | ||
const AJAX_DELAY = 500; | ||
const CPU_DELAY = 200; | ||
const SCRIPT_DELAY = 500; | ||
|
||
test.describe('TTVC', () => { | ||
test('script load > ajax request > CPU work > script load > mutation + background lazyloaded script', async ({ | ||
page, | ||
}) => { | ||
await page.goto(`http://localhost:3000/test/composition2?delay=${PAGELOAD_DELAY}`, { | ||
waitUntil: 'networkidle', | ||
}); | ||
|
||
const entries = await getEntries(page); | ||
expect(entries.length).toBe(1); | ||
|
||
const expectedTtvc = PAGELOAD_DELAY + SCRIPT_DELAY + AJAX_DELAY + CPU_DELAY + SCRIPT_DELAY; | ||
expect(entries[0]).toBeGreaterThanOrEqual(expectedTtvc); | ||
expect(entries[0]).toBeLessThanOrEqual(expectedTtvc + FUDGE); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<head> | ||
<script src="/dist/index.min.js"></script> | ||
<script src="/analytics.js"></script> | ||
</head> | ||
|
||
<body> | ||
<h1 id="h1">Hello world!</h1> | ||
|
||
<script src="/busy.js?delay=500"></script> | ||
<script> | ||
const asyncScript = document.createElement('script'); | ||
asyncScript.src = '/mutation.js?delay=500'; | ||
|
||
fetch('/api?delay=500') | ||
.then((res) => res.text()) | ||
.then(() => { | ||
busy(1000); | ||
document.head.appendChild(asyncScript); | ||
}); | ||
</script> | ||
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import {test, expect} from '@playwright/test'; | ||
|
||
import {FUDGE} from '../../util/constants'; | ||
import {getEntries} from '../../util/entries'; | ||
|
||
const PAGELOAD_DELAY = 200; | ||
const AJAX_DELAY = 500; | ||
const CPU_DELAY = 1000; | ||
const SCRIPT_DELAY = 500; | ||
|
||
test.describe('TTVC', () => { | ||
test('script load > ajax request > CPU work > script load > mutation', async ({page}) => { | ||
test.fail(); // ttvc is computed too early | ||
await page.goto(`http://localhost:3000/test/composition3?delay=${PAGELOAD_DELAY}`, { | ||
waitUntil: 'networkidle', | ||
}); | ||
|
||
const entries = await getEntries(page); | ||
expect(entries.length).toBe(1); | ||
|
||
const expectedTtvc = PAGELOAD_DELAY + SCRIPT_DELAY + AJAX_DELAY + CPU_DELAY + SCRIPT_DELAY; | ||
expect(entries[0]).toBeGreaterThanOrEqual(expectedTtvc); | ||
expect(entries[0]).toBeLessThanOrEqual(expectedTtvc + FUDGE); | ||
}); | ||
}); |
Oops, something went wrong.