Skip to content

Commit 8fbb951

Browse files
committed
wip: poc
1 parent 00c7fc2 commit 8fbb951

File tree

12 files changed

+2262
-55
lines changed

12 files changed

+2262
-55
lines changed

.github/workflows/playwright.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Playwright Tests
2+
3+
on:
4+
push:
5+
branches: [main, 'feat/browserstack']
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
test:
12+
timeout-minutes: 60
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v5
16+
with:
17+
fetch-depth: 0
18+
persist-credentials: false
19+
- name: Use Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version-file: '.node-version'
23+
24+
- name: Prepare
25+
run: |
26+
corepack enable
27+
28+
# try and avoid timeout errors
29+
yarn config set httpTimeout 100000
30+
31+
yarn --immutable
32+
33+
yarn build:ts
34+
35+
- name: Run Playwright tests
36+
run: |
37+
cd playwright
38+
yarn test:ci
39+
env:
40+
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
41+
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
42+
43+
- uses: actions/upload-artifact@v4
44+
if: ${{ !cancelled() }}
45+
with:
46+
name: playwright-report
47+
path: playwright-report/
48+
retention-days: 30

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"shared-lib",
88
"webui",
99
"launcher",
10-
"launcher-ui"
10+
"launcher-ui",
11+
"playwright"
1112
],
1213
"type": "module",
1314
"scripts": {

playwright/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/log
2+
/playwright-report/
3+
/test-results/
4+
/browserstackSetupConfig.json
5+
/playwright-browserstack*

playwright/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# browserstack

playwright/browserstack.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# ======================
2+
# BrowserStack Reporting
3+
# ======================
4+
projectName: Bitfocus Companion
5+
# Set `buildName` as the name of the job / testsuite being run
6+
buildName: browserstack-playwright
7+
# `buildIdentifier` is a unique id to differentiate every execution that gets appended to
8+
# buildName. Choose your buildIdentifier format from the available expressions:
9+
# ${BUILD_NUMBER} (Default): Generates an incremental counter with every execution
10+
# ${DATE_TIME}: Generates a Timestamp with every execution. Eg. 05-Nov-19:30
11+
# Read more about buildIdentifiers here -> https://www.browserstack.com/docs/automate/selenium/organize-tests
12+
buildIdentifier: '#${BUILD_NUMBER}' # Supports strings along with either/both ${expression}
13+
14+
# =======================================
15+
# Platforms (Browsers / Devices to test)
16+
# =======================================
17+
# Platforms object contains all the browser / device combinations you want to test on.
18+
# Entire list available here -> (https://www.browserstack.com/list-of-browsers-and-platforms/automate)
19+
platforms:
20+
- os: OS X
21+
osVersion: Big Sur
22+
browserName: chrome
23+
browserVersion: latest
24+
- os: Windows
25+
osVersion: 10
26+
browserName: edge
27+
browserVersion: latest
28+
- deviceName: Samsung Galaxy S22 Ultra
29+
browserName: chrome # Try 'samsung' for Samsung browser
30+
osVersion: 12.0
31+
32+
# =======================
33+
# Parallels per Platform
34+
# =======================
35+
# The number of parallel threads to be used for each platform set.
36+
# BrowserStack's SDK runner will select the best strategy based on the configured value
37+
#
38+
# Example 1 - If you have configured 3 platforms and set `parallelsPerPlatform` as 2, a total of 6 (2 * 3) parallel threads will be used on BrowserStack
39+
#
40+
# Example 2 - If you have configured 1 platform and set `parallelsPerPlatform` as 5, a total of 5 (1 * 5) parallel threads will be used on BrowserStack
41+
parallelsPerPlatform: 1
42+
43+
# ==========================================
44+
# BrowserStack Local
45+
# (For localhost, staging/private websites)
46+
# ==========================================
47+
# Set browserStackLocal to true if your website under test is not accessible publicly over the internet
48+
# Learn more about how BrowserStack Local works here -> https://www.browserstack.com/docs/automate/selenium/local-testing-introduction
49+
browserstackLocal: true
50+
# browserStackLocalOptions:
51+
# Options to be passed to BrowserStack local in-case of advanced configurations
52+
# localIdentifier: # <string> (Default: null) Needed if you need to run multiple instances of local.
53+
# forceLocal: true # <boolean> (Default: false) Set to true if you need to resolve all your traffic via BrowserStack Local tunnel.
54+
# Entire list of arguments available here -> https://www.browserstack.com/docs/automate/selenium/manage-incoming-connections
55+
56+
# ===================
57+
# Debugging features
58+
# ===================
59+
debug: false # <boolean> # Set to true if you need screenshots for every selenium command ran
60+
networkLogs: false # <boolean> Set to true to enable HAR logs capturing
61+
consoleLogs: errors # <string> Remote browser's console debug levels to be printed (Default: errors)
62+
# Available options are `disable`, `errors`, `warnings`, `info`, `verbose` (Default: errors)
63+
# CUSTOM_TAG_<INT>: # <string> (Default: parent folder name of the test file) Custom tag for your test suite
64+
65+
# Test Reporting And Analytics is an intelligent test reporting & debugging product. It collects data using the SDK. Read more about what data is collected at https://www.browserstack.com/docs/test-reporting-and-analytics/references/terms-and-conditions
66+
# Visit automation.browserstack.com to see your test reports and insights. To disable test reporting and analytics, specify `testReporting: false` in the key below.
67+
testReporting: true

playwright/package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "@companion-app/playwright",
3+
"version": "4.2.0",
4+
"private": true,
5+
"type": "module",
6+
"scripts": {
7+
"test:ci": "browserstack-node-sdk playwright test --config=./playwright.config.ts",
8+
"test": "browserstack-node-sdk playwright test --config=./playwright.local.config.ts"
9+
},
10+
"devDependencies": {
11+
"@playwright/test": "^1.55.1",
12+
"browserstack-node-sdk": "^1.43.0"
13+
},
14+
"packageManager": "[email protected]"
15+
}

playwright/playwright.config.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { defineConfig } from '@playwright/test'
2+
3+
// This is a sample config for what users might be running locally
4+
export default defineConfig({
5+
testDir: './tests',
6+
7+
/* Fail the build on CI if you accidentally left test.only in the source code. */
8+
forbidOnly: !!process.env.CI,
9+
/* Retry on CI only */
10+
retries: process.env.CI ? 2 : 0,
11+
/* Opt out of parallel tests on CI. */
12+
workers: process.env.CI ? 1 : undefined,
13+
14+
/* Maximum time one test can run for. */
15+
timeout: 90 * 1000,
16+
expect: {
17+
/**
18+
* Maximum time expect() should wait for the condition to be met.
19+
* For example in `await expect(locator).toHaveText();`
20+
*/
21+
timeout: 5000,
22+
},
23+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
24+
reporter: 'html',
25+
/* Configure projects for major browsers */
26+
projects: [
27+
{
28+
name: 'chrome',
29+
use: {
30+
browserName: 'chromium',
31+
channel: 'chrome',
32+
},
33+
},
34+
],
35+
})
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// This is a sample config for what users might be running locally
2+
const config = {
3+
testDir: './tests',
4+
testMatch: '**/bstack_local*.js',
5+
6+
/* Maximum time one test can run for. */
7+
timeout: 90 * 1000,
8+
expect: {
9+
/**
10+
* Maximum time expect() should wait for the condition to be met.
11+
* For example in `await expect(locator).toHaveText();`
12+
*/
13+
timeout: 5000,
14+
},
15+
/* tests in parallel */
16+
workers: 1,
17+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
18+
reporter: 'line',
19+
/* Configure projects for major browsers */
20+
projects: [
21+
{
22+
name: 'chrome',
23+
use: {
24+
browserName: 'chromium',
25+
channel: 'chrome',
26+
},
27+
},
28+
],
29+
}
30+
31+
module.exports = config

playwright/tests/example.spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { test, expect } from '@playwright/test'
2+
3+
test('has title', async ({ page }) => {
4+
await page.goto('https://playwright.dev/')
5+
6+
// Expect a title "to contain" a substring.
7+
await expect(page).toHaveTitle(/Playwright/)
8+
})
9+
10+
test('get started link', async ({ page }) => {
11+
await page.goto('https://playwright.dev/')
12+
13+
// Click the get started link.
14+
await page.getByRole('link', { name: 'Get started' }).click()
15+
16+
// Expects page to have a heading with the name of Installation.
17+
await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible()
18+
})

playwright/tsconfig.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"include": ["tests/**/*.ts", "playwright.config.ts"],
3+
"exclude": ["node_modules/**"],
4+
"compilerOptions": {
5+
"rootDir": ".",
6+
"baseUrl": "./",
7+
"paths": {
8+
"*": ["./node_modules/*"],
9+
"~/*": ["./src/*"]
10+
},
11+
"module": "esnext",
12+
"moduleResolution": "bundler",
13+
"jsx": "react",
14+
// "allowJs": true,
15+
// "checkJs": true,
16+
"strictPropertyInitialization": true,
17+
"noEmit": true,
18+
// "composite": true,
19+
20+
"target": "ESNext",
21+
"noImplicitAny": true,
22+
"sourceMap": true,
23+
"declaration": false,
24+
"importHelpers": false,
25+
"listFiles": false,
26+
"traceResolution": false,
27+
"pretty": true,
28+
"lib": ["DOM", "DOM.Iterable", "ESNext"],
29+
"types": ["node", "react"],
30+
"strict": true,
31+
"alwaysStrict": false,
32+
"forceConsistentCasingInFileNames": true,
33+
"noFallthroughCasesInSwitch": true,
34+
"noImplicitReturns": true,
35+
"noUnusedLocals": true,
36+
"noUnusedParameters": true,
37+
"skipLibCheck": true,
38+
"allowSyntheticDefaultImports": true,
39+
"esModuleInterop": true,
40+
"resolveJsonModule": true
41+
},
42+
"references": [{ "path": "../companion" }, { "path": "../shared-lib" }]
43+
}

0 commit comments

Comments
 (0)