Skip to content

Commit

Permalink
Run compatibility tests once per day and on PR changes
Browse files Browse the repository at this point in the history
  • Loading branch information
NikkelM committed Jun 29, 2024
1 parent 8cd8b71 commit 59f9d8c
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
42 changes: 42 additions & 0 deletions .github/workflows/compatibilityTest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Run Compatibility Tests

on:
schedule:
- cron: '0 0 * * *'
push:
branches:
- main
pull_request:
branches:
- main

jobs:
CompatibilityTest:
runs-on: ubuntu-latest
steps:
- name: Set up Git repository
uses: actions/checkout@v3

- name: Set up node
uses: actions/setup-node@v3
with:
node-version: 18

- name: Cache node modules
id: cache-npm
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install dependencies
run: npm install

- name: Run compatibility tests
run: npm run test:compatibility
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"build:firefox": "webpack --env browser=firefox --config webpack.prod.cjs",
"lint": "eslint --ext .ts,.js --max-warnings=0 . --ignore-path .eslintignore",
"lint:firefox": "web-ext lint --source-dir ./dist/firefox",
"test": "c8 --reporter=lcov --reporter=text mocha ./test/testSetup.js ./test/chromeStorage.test.js ./test/**/*.test.js --require mocha-suppress-logs"
"test": "c8 --reporter=lcov --reporter=text mocha ./test/testSetup.js ./test/chromeStorage.test.js ./test/**/*.test.js --exclude ./test/compatibility.test.js --require mocha-suppress-logs",
"test:compatibility": "mocha ./test/testSetup.js ./test/compatibility.test.js --require mocha-suppress-logs"
},
"type": "module",
"devDependencies": {
Expand Down
13 changes: 13 additions & 0 deletions test/compatibility.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import expect from 'expect.js';

describe('compatibility', function () {
context('YouTube', function () {
it('should redirect multiple videos to a temporary playlist URL', async function () {
const watchVideosUrl = 'https://www.youtube.com/watch_videos?video_ids=dQw4w9WgXcQ,dQw4w9WgXcQ,dQw4w9WgXcQ,dQw4w9WgXcQ';
const redirectedUrl = (await fetch(watchVideosUrl)).url;

// The playlist is temporary, indicated by a TL start in the ID
expect(redirectedUrl).to.contain('https://www.youtube.com/watch?v=dQw4w9WgXcQ&list=TL');
});
});
});

0 comments on commit 59f9d8c

Please sign in to comment.