Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Commit 810ee58

Browse files
committed
fix: change CI to install browsers for tests
1 parent 0c66cdb commit 810ee58

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,7 @@ jobs:
1818
cache: "yarn"
1919
- name: Install dependencies
2020
run: yarn install
21+
- name: Install dependencies for browsers
22+
run: npx playwright install-deps
2123
- name: Run test:examples
2224
run: yarn run test:examples

examples/browser-video-streaming/index.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,18 @@
99
<link rel="icon" href="favicon.ico" />
1010

1111
<script
12-
defer
12+
crossorigin
1313
src="https://cdn.jsdelivr.net/npm/hlsjs-ipfs-loader@0.3.0/dist/index.js"
1414
></script>
15-
<script defer src="https://cdn.jsdelivr.net/npm/hls.js@0.14.17"></script>
15+
<script
16+
crossorigin
17+
src="https://cdn.jsdelivr.net/npm/hls.js@0.14.17"
18+
></script>
1619

1720
<script type="module" defer src="./src/index.js"></script>
1821
</head>
1922
<body>
2023
<video id="video" controls autoplay></video>
24+
<div id="status"></div>
2125
</body>
2226
</html>

examples/browser-video-streaming/src/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import Ipfs from 'ipfs'
44

5-
/* global Hls Ipfs HlsjsIpfsLoader */
5+
/* global Hls HlsjsIpfsLoader */
66
/* eslint-env browser */
77
document.addEventListener('DOMContentLoaded', async () => {
88
const testHash = 'QmdpAidwAsBGptFB3b6A9Pyi5coEbgjHrL3K2Qrsutmj9K'
@@ -13,11 +13,17 @@ document.addEventListener('DOMContentLoaded', async () => {
1313
Hls.DefaultConfig.debug = false
1414
if (Hls.isSupported()) {
1515
const video = document.getElementById('video')
16+
const status = document.getElementById('status')
1617
const hls = new Hls()
1718
hls.config.ipfs = node
1819
hls.config.ipfsHash = testHash
1920
hls.loadSource('master.m3u8')
2021
hls.attachMedia(video)
21-
hls.on(Hls.Events.MANIFEST_PARSED, () => video.play())
22+
hls.on(Hls.Events.MANIFEST_PARSED, () => {
23+
const node = document.createTextNode("Video ready...");
24+
status.appendChild(node);
25+
26+
video.play()
27+
})
2228
}
2329
})

examples/browser-video-streaming/tests/test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ const play = test.extend({
1212

1313
play.describe('browser videostream:', () => {
1414
// DOM
15-
const video = "#video"
15+
const status = "#status"
1616

1717
play.beforeEach(async ({servers, page}) => {
1818
await page.goto(`http://localhost:${servers[0].port}/`);
1919
})
2020

2121
play('should properly initialized a IPFS node and stream a video', async ({ page }) => {
22-
await page.waitForFunction((el) => document.querySelector(el).readyState >= 2, video);
22+
await page.waitForSelector(`${status}:has-text('Video ready')`)
2323
});
2424
});

0 commit comments

Comments
 (0)