From 59f9d8ca7eacf77ea1a7bfe91d1bbb17a0f5befe Mon Sep 17 00:00:00 2001 From: Nikkel Mollenhauer <57323886+NikkelM@users.noreply.github.com> Date: Sat, 29 Jun 2024 19:55:40 +0100 Subject: [PATCH] Run compatibility tests once per day and on PR changes --- .github/workflows/compatibilityTest.yml | 42 +++++++++++++++++++++++++ package.json | 3 +- test/compatibility.test.js | 13 ++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/compatibilityTest.yml create mode 100644 test/compatibility.test.js diff --git a/.github/workflows/compatibilityTest.yml b/.github/workflows/compatibilityTest.yml new file mode 100644 index 00000000..3d86f7fb --- /dev/null +++ b/.github/workflows/compatibilityTest.yml @@ -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 diff --git a/package.json b/package.json index 6da0c8f2..7dcfc590 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/test/compatibility.test.js b/test/compatibility.test.js new file mode 100644 index 00000000..00dab61d --- /dev/null +++ b/test/compatibility.test.js @@ -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'); + }); + }); +}); \ No newline at end of file