-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: update package-lock.json * fix: config UI is up to date with IDB * chore: apply self suggestions from code review * chore: fix build and lint * test: add video e2e tests * chore: actually commit the video test file * chore: fix test name and comment
- Loading branch information
Showing
4 changed files
with
63 additions
and
1 deletion.
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
Binary file added
BIN
+4.35 MB
test-e2e/fixtures/data/bafybeie4vcqkutumw7s26ob2bwqwqi44m6lrssjmiirlhrzhs2akdqmkw4.car
Binary file not shown.
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,48 @@ | ||
import { testPathRouting as test, expect } from './fixtures/config-test-fixtures.js' | ||
import { setConfig } from './fixtures/set-sw-config.js' | ||
import { waitForServiceWorker } from './fixtures/wait-for-service-worker' | ||
import type { ConfigDbWithoutPrivateFields } from '../src/lib/config-db.js' | ||
|
||
const cid = 'bafybeie4vcqkutumw7s26ob2bwqwqi44m6lrssjmiirlhrzhs2akdqmkw4' // big buck bunny webm trimmed to 15 seconds with `ffmpeg -i bigbuckbunny.webm -ss 00:00 -t 00:15 -c:a copy -c:v copy bigbuckbunny-mini.webm` | ||
test.describe('video', () => { | ||
const testConfig: Partial<ConfigDbWithoutPrivateFields> = { | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
gateways: [process.env.KUBO_GATEWAY!], | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
routers: [process.env.KUBO_GATEWAY!], | ||
debug: '*,*:trace', | ||
enableWss: true, | ||
enableWebTransport: false, | ||
enableRecursiveGateways: true, | ||
enableGatewayProviders: false | ||
} | ||
|
||
/** | ||
* We want to load the video fixture and ensure it starts playing. | ||
*/ | ||
test('starts playing automatically', async ({ page, protocol, rootDomain }) => { | ||
await page.goto(`${protocol}//${rootDomain}`) | ||
await setConfig({ page, config: testConfig }) | ||
await waitForServiceWorker(page) | ||
const response = await page.goto(`${protocol}//${rootDomain}/ipfs/${cid}`, { waitUntil: 'commit' }) | ||
const start = performance.now() | ||
|
||
expect(response?.status()).toBe(200) | ||
|
||
// expect a video player | ||
await page.waitForSelector('video') | ||
const video = await page.$('video') | ||
if (video == null) { | ||
throw new Error('video element not found') | ||
} | ||
|
||
// continuously check if the video is playing | ||
await page.waitForFunction((video) => { | ||
return video.currentTime > 0 && !video.paused && !video.ended && video.readyState > 2 | ||
}, video) | ||
const end = performance.now() | ||
|
||
const timeToPlay = end - start | ||
expect(timeToPlay).toBeLessThan(10000) | ||
}) | ||
}) |