Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Test - Add Playwright to Test Megadata #1211

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Playwright Tests

on:
pull_request:
branches:
include:
- release/*
exclude:
- main

jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: npm install -g yarn && yarn
- name: Install Playwright Browsers
run: yarn playwright install --with-deps
- name: Run Playwright tests
run: yarn playwright test
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ build
/test-results/
/playwright-report/
/playwright/.cache/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
"@fortawesome/free-brands-svg-icons": "^6.4.2",
"@fortawesome/free-solid-svg-icons": "^6.4.2",
"@fortawesome/react-fontawesome": "^0.2.0",
"@playwright/test": "^1.40.1",
"@types/node": "^20.8.7",
"eslint": "^8.53.0",
"eslint-plugin-jsx-a11y": "^6.8.0",
Expand Down
46 changes: 46 additions & 0 deletions playwright.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// @ts-check
const { defineConfig, devices } = require('@playwright/test');

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();

/**
* @see https://playwright.dev/docs/test-configuration
*/
module.exports = defineConfig({
testDir: './tests',
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
timeout: 5 * 60 * 1000,
use: {
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},

projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},

{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},

{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},
],
});
25 changes: 25 additions & 0 deletions tests/megadata.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// @ts-check
const { test, expect } = require('@playwright/test');

const baseurl = 'https://ssw.com.au/rules';

test('should have history.json', async ({ request }) => {
const response = await request.get(`${baseurl}/history.json`);
expect(response.status()).toBe(200);
});

test('should have megadata', async ({ page }) => {
await page.goto('https://ssw.com.au/rules/latest-rules/?size=50');

let randomNum = Math.floor(Math.random() * 50);

const ruleLink = await page
.locator('.cat-grid-container')
.getByRole('link')
.nth(randomNum);

await ruleLink.click();

const locator = page.locator('.history');
await expect(locator).toContainText('See history');
});
55 changes: 55 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4161,6 +4161,17 @@ __metadata:
languageName: node
linkType: hard

"@playwright/test@npm:^1.40.1":
version: 1.40.1
resolution: "@playwright/test@npm:1.40.1"
dependencies:
playwright: "npm:1.40.1"
bin:
playwright: cli.js
checksum: 1edbc9659fb6a9c5299cacd9a0c7d3fdc88939036642d8f367e13d267d808ae3f88ca9d00e9981e3bcd5f584ccefba38d24eda6b23d27895908f203dc35f339e
languageName: node
linkType: hard

"@pmmmwh/react-refresh-webpack-plugin@npm:^0.5.10":
version: 0.5.11
resolution: "@pmmmwh/react-refresh-webpack-plugin@npm:0.5.11"
Expand Down Expand Up @@ -5332,6 +5343,7 @@ __metadata:
"@fortawesome/free-solid-svg-icons": "npm:^6.4.2"
"@fortawesome/react-fontawesome": "npm:^0.2.0"
"@microsoft/applicationinsights-web": "npm:^3.0.3"
"@playwright/test": "npm:^1.40.1"
"@raae/gatsby-remark-oembed": "npm:^0.3.3"
"@types/node": "npm:^20.8.7"
algoliasearch: "npm:^4.20.0"
Expand Down Expand Up @@ -11504,6 +11516,16 @@ __metadata:
languageName: node
linkType: hard

"fsevents@npm:2.3.2":
version: 2.3.2
resolution: "fsevents@npm:2.3.2"
dependencies:
node-gyp: "npm:latest"
checksum: be78a3efa3e181cda3cf7a4637cb527bcebb0bd0ea0440105a3bb45b86f9245b307dc10a2507e8f4498a7d4ec349d1910f4d73e4d4495b16103106e07eee735b
conditions: os=darwin
languageName: node
linkType: hard

"fsevents@npm:~2.3.2":
version: 2.3.3
resolution: "fsevents@npm:2.3.3"
Expand All @@ -11514,6 +11536,15 @@ __metadata:
languageName: node
linkType: hard

"fsevents@patch:fsevents@npm%3A2.3.2#optional!builtin<compat/fsevents>":
version: 2.3.2
resolution: "fsevents@patch:fsevents@npm%3A2.3.2#optional!builtin<compat/fsevents>::version=2.3.2&hash=df0bf1"
dependencies:
node-gyp: "npm:latest"
conditions: os=darwin
languageName: node
linkType: hard

"fsevents@patch:fsevents@npm%3A~2.3.2#optional!builtin<compat/fsevents>":
version: 2.3.3
resolution: "fsevents@patch:fsevents@npm%3A2.3.3#optional!builtin<compat/fsevents>::version=2.3.3&hash=df0bf1"
Expand Down Expand Up @@ -18256,6 +18287,30 @@ __metadata:
languageName: node
linkType: hard

"playwright-core@npm:1.40.1":
version: 1.40.1
resolution: "playwright-core@npm:1.40.1"
bin:
playwright-core: cli.js
checksum: 56c283012974982313a6ae583b975ee4af76d52059fb9a25d9cc616a11224685ec64682b391910c795d2b12d2ab5c7eec31124722c75c0b1703a76ac9b6fd1c2
languageName: node
linkType: hard

"playwright@npm:1.40.1":
version: 1.40.1
resolution: "playwright@npm:1.40.1"
dependencies:
fsevents: "npm:2.3.2"
playwright-core: "npm:1.40.1"
dependenciesMeta:
fsevents:
optional: true
bin:
playwright: cli.js
checksum: 5dae164d1f69162da8d7eee52da651296fb885c76a8b36049f216975c751a0a826ff05795a1c0902dc0bd193fe606ae17d5def655f4cbcccb8d8b71afb74b950
languageName: node
linkType: hard

"plist@npm:^3.0.1":
version: 3.1.0
resolution: "plist@npm:3.1.0"
Expand Down
Loading