-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #189 from trossr32/playwright-integration-tests
add playwright integration tests
- Loading branch information
Showing
34 changed files
with
1,735 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: Playwright tests | ||
on: | ||
pull_request: | ||
branches: [ staging, main, master ] | ||
types: | ||
- opened | ||
- synchronize | ||
paths: | ||
- '.github/workflows/playwright.yml' | ||
- 'src/**' | ||
- 'tests/playwright/**' | ||
- 'package.json' | ||
|
||
schedule: | ||
- cron: '0 6 1,11,21 * *' | ||
|
||
workflow_dispatch: | ||
|
||
jobs: | ||
test: | ||
timeout-minutes: 15 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: lts/* | ||
|
||
- name: Publish extension to dist folder | ||
run: | | ||
npm ci | ||
npm i grunt -g | ||
grunt playwright | ||
- name: Install test dependencies | ||
run: npm ci | ||
working-directory: tests/playwright | ||
|
||
- name: Install playwright browser (chromium) | ||
run: npx playwright install --with-deps chromium | ||
working-directory: tests/playwright | ||
|
||
- name: Run playwright tests | ||
run: npx playwright test | ||
working-directory: tests/playwright | ||
|
||
- uses: actions/upload-artifact@v4 | ||
if: always() | ||
with: | ||
name: playwright-report | ||
path: tests/playwright/playwright-report/ | ||
retention-days: 30 |
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 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 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,5 @@ | ||
node_modules/ | ||
/test-results/ | ||
/playwright-report/ | ||
/blob-report/ | ||
/playwright/.cache/ |
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 @@ | ||
export const iconDataLocator = 'a[data-servarr-icon="true"]'; |
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,39 @@ | ||
import { test as base, chromium, type BrowserContext } from '@playwright/test'; | ||
import path from 'path'; | ||
|
||
export const test = base.extend<{ | ||
context: BrowserContext; | ||
extensionId: string; | ||
}>({ | ||
context: async ({ }, use) => { | ||
const pathToExtension = path.resolve(__dirname, '../../dist'); | ||
console.log('Loading extension from', pathToExtension); | ||
const context = await chromium.launchPersistentContext('', { | ||
headless: false, | ||
args: [ | ||
`--headless=new`, | ||
`--disable-extensions-except=${pathToExtension}`, | ||
`--load-extension=${pathToExtension}`, | ||
], | ||
}); | ||
await use(context); | ||
await context.close(); | ||
}, | ||
extensionId: async ({ context }, use) => { | ||
// for manifest v2: | ||
let [background] = context.backgroundPages() | ||
if (!background) | ||
background = await context.waitForEvent('backgroundpage') | ||
|
||
// for manifest v3: | ||
/* | ||
let [background] = context.serviceWorkers(); | ||
if (!background) | ||
background = await context.waitForEvent('serviceworker'); | ||
*/ | ||
|
||
const extensionId = background.url().split('/')[2]; | ||
await use(extensionId); | ||
}, | ||
}); | ||
export const expect = test.expect; |
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 @@ | ||
/** | ||
* Get the expected Sonarr URL for a given add new path query | ||
* @param query | ||
* @returns expected Sonarr URL | ||
*/ | ||
export const getExpectedSonarrUrl = (query: string): string => `http://my.sonarr-url.domain:8989/add/new/${query}`; | ||
|
||
/** | ||
* Get the expected Radarr URL for a given add new path query | ||
* @param query | ||
* @returns expected Radarr URL | ||
*/ | ||
export const getExpectedRadarrUrl = (query: string): string => `http://my.radarr-url.domain:7878/add/new/${query}`; | ||
|
||
/** | ||
* Get the expected Lidarr URL for a given search query | ||
* @param query | ||
* @returns expected Lidarr URL | ||
*/ | ||
export const getExpectedLidarrUrl = (query: string): string => `http://my.lidarr-url.domain:8686/add/search/${query}`; |
Oops, something went wrong.