Skip to content

Commit

Permalink
Merge pull request #43 from currents-dev/feat/rules-example
Browse files Browse the repository at this point in the history
[CSR-1773] feat: Add rules example for github actions
  • Loading branch information
twk3 authored Dec 11, 2024
2 parents 71f3bdb + 38963dd commit d6ce0d1
Show file tree
Hide file tree
Showing 25 changed files with 765 additions and 416 deletions.
6 changes: 3 additions & 3 deletions .github/test-basic-pwc-failed-only.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
name: "Playwright Tests - check failed"
timeout-minutes: 60
runs-on: ubuntu-22.04
container: mcr.microsoft.com/playwright:latest
container: mcr.microsoft.com/playwright:v1.49.0-jammy
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -96,7 +96,7 @@ jobs:
name: "Playwright Tests - run basic tests"
timeout-minutes: 60
runs-on: ubuntu-22.04
container: mcr.microsoft.com/playwright:latest
container: mcr.microsoft.com/playwright:v1.49.0-jammy
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -134,7 +134,7 @@ jobs:
if: 'failure()'
needs: [previousFailedFirst, fullRun]
runs-on: ubuntu-22.04
container: mcr.microsoft.com/playwright:latest
container: mcr.microsoft.com/playwright:v1.49.0-jammy
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/test-basic-pwc-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
name: "PW tests"
timeout-minutes: 60
runs-on: ubuntu-22.04
container: mcr.microsoft.com/playwright:latest
container: mcr.microsoft.com/playwright:v1.49.0-jammy
env:
TESTGROUP: basic
steps:
Expand Down
20 changes: 10 additions & 10 deletions .github/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
name: "accessibility tests"
timeout-minutes: 60
runs-on: ubuntu-22.04
container: mcr.microsoft.com/playwright:v1.28.1-focal
container: mcr.microsoft.com/playwright:v1.49.0-jammy
env:
TESTGROUP: accessibility
BASEURL: https://playwright.dev/docs/accessibility-testing # Playwright tests use this for baseURL
Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:
name: "basic tests"
timeout-minutes: 60
runs-on: ubuntu-22.04
container: mcr.microsoft.com/playwright:v1.28.1-focal
container: mcr.microsoft.com/playwright:v1.49.0-jammy
env:
TESTGROUP: basic
environment:
Expand Down Expand Up @@ -167,7 +167,7 @@ jobs:
name: "drag-and-drop tests"
timeout-minutes: 60
runs-on: ubuntu-22.04
container: mcr.microsoft.com/playwright:v1.28.1-focal
container: mcr.microsoft.com/playwright:v1.49.0-jammy
env:
TESTGROUP: drag-and-drop
BASEURL: https://www.w3schools.com/html/html5_draganddrop.asp # Playwright tests use this for baseURL
Expand Down Expand Up @@ -248,7 +248,7 @@ jobs:
name: "fixtures tests"
timeout-minutes: 60
runs-on: ubuntu-22.04
container: mcr.microsoft.com/playwright:v1.28.1-focal
container: mcr.microsoft.com/playwright:v1.49.0-jammy
env:
TESTGROUP: fixtures
environment:
Expand Down Expand Up @@ -285,7 +285,7 @@ jobs:
name: "github-api tests"
timeout-minutes: 60
runs-on: ubuntu-22.04
container: mcr.microsoft.com/playwright:v1.28.1-focal
container: mcr.microsoft.com/playwright:v1.49.0-jammy
env:
TESTGROUP: github-api
GITHUB_USER: ${{ secrets.REPO_USER }}
Expand Down Expand Up @@ -325,7 +325,7 @@ jobs:
timeout-minutes: 60
if: ${{ false }} # disable for now for bot detection
runs-on: ubuntu-22.04
container: mcr.microsoft.com/playwright:v1.28.1-focal
container: mcr.microsoft.com/playwright:v1.49.0-jammy
env:
TESTGROUP: oauth
BASEURL: https://courses.ultimateqa.com/users/sign_in # Playwright tests use this for baseURL
Expand Down Expand Up @@ -367,7 +367,7 @@ jobs:
name: "performance tests"
timeout-minutes: 60
runs-on: ubuntu-22.04
container: mcr.microsoft.com/playwright:v1.28.1-focal
container: mcr.microsoft.com/playwright:v1.49.0-jammy
env:
TESTGROUP: performance
BASEURL: https://fastestwebsite.net/ # Playwright tests use this for baseURL
Expand Down Expand Up @@ -406,7 +406,7 @@ jobs:
name: "svgomg tests"
timeout-minutes: 60
runs-on: ubuntu-22.04
container: mcr.microsoft.com/playwright:v1.28.1-focal
container: mcr.microsoft.com/playwright:v1.49.0-jammy
env:
TESTGROUP: svgomg
BASEURL: https://demo.playwright.dev/svgomg # Playwright tests use this for baseURL
Expand Down Expand Up @@ -444,7 +444,7 @@ jobs:
name: "todomvc tests"
timeout-minutes: 60
runs-on: ubuntu-22.04
container: mcr.microsoft.com/playwright:v1.28.1-focal
container: mmcr.microsoft.com/playwright:v1.49.0-jammy
env:
TESTGROUP: todomvc
BASEURL: https://demo.playwright.dev/todomvc # Playwright tests use this for baseURL
Expand Down Expand Up @@ -482,7 +482,7 @@ jobs:
name: "visual-comparison tests"
timeout-minutes: 60
runs-on: ubuntu-22.04
container: mcr.microsoft.com/playwright:v1.28.1-focal
container: mcr.microsoft.com/playwright:v1.49.0-jammy
env:
TESTGROUP: visual-comparison
BASEURL: https://playwright.dev # Playwright tests use this for baseURL
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/argos-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
name: "PW tests"
timeout-minutes: 60
runs-on: ubuntu-22.04
container: mcr.microsoft.com/playwright:1.46.1
container: mcr.microsoft.com/playwright:v1.49.0-jammy

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rerun-shards-pwc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
shard: [1, 2, 3]
timeout-minutes: 60
runs-on: ubuntu-latest
container: mcr.microsoft.com/playwright:latest
container: mcr.microsoft.com/playwright:v1.49.0-noble
env:
CURRENTS_PROJECT_ID: bnsqNa
CURRENTS_RECORD_KEY: ${{ secrets.CURRENTS_RECORD_KEY }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rerun-shards-reporter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
shard: [1, 2, 3]
timeout-minutes: 60
runs-on: ubuntu-latest
container: mcr.microsoft.com/playwright:latest
container: mcr.microsoft.com/playwright:v1.49.0-noble
env:
CURRENTS_PROJECT_ID: bnsqNa
CURRENTS_RECORD_KEY: ${{ secrets.CURRENTS_RECORD_KEY }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reruns-or8n.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
shard: [1, 2, 3]
timeout-minutes: 60
runs-on: ubuntu-latest
container: mcr.microsoft.com/playwright:latest
container: mcr.microsoft.com/playwright:v1.49.0-noble
env:
CURRENTS_PROJECT_ID: bnsqNa
CURRENTS_RECORD_KEY: ${{ secrets.CURRENTS_RECORD_KEY }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-basic-pwc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
name: "Playwright Tests - pwc"
timeout-minutes: 60
runs-on: ubuntu-22.04
container: mcr.microsoft.com/playwright:1.46.1
container: mcr.microsoft.com/playwright:v1.49.0-jammy

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-basic-reporter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
name: "Playwright Tests - Reporter"
timeout-minutes: 60
runs-on: ubuntu-22.04
container: mcr.microsoft.com/playwright:1.46.1
container: mcr.microsoft.com/playwright:v1.49.0-jammy

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-or8n.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
name: "Playwright Tests - pwc-p"
timeout-minutes: 60
runs-on: ubuntu-22.04
container: mcr.microsoft.com/playwright:1.46.1
container: mcr.microsoft.com/playwright:v1.49.0-jammy

steps:
- uses: actions/checkout@v4
Expand Down
5 changes: 3 additions & 2 deletions basic/0-failing.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { expect, test } from "@playwright/test";
import { expect } from "@playwright/test";
import { test } from "./base.ts";

test("basic test @basic", async ({ page }) => {
await page.goto("https://todomvc.com/examples/backbone/dist/");
await page.goto("https://demo.playwright.dev/todomvc");

// Use locators to represent a selector and re-use them
const inputBox = page.locator("input.new-todo");
Expand Down
5 changes: 3 additions & 2 deletions basic/1-getting-started.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { expect, test } from "@playwright/test";
import { expect } from "@playwright/test";
import { test } from "./base.ts";

test("basic test @basic", async ({ page }) => {
await page.goto("https://todomvc.com/examples/backbone/dist/");
await page.goto("https://demo.playwright.dev/todomvc");

// Use locators to represent a selector and re-use them
const inputBox = page.locator("input.new-todo");
Expand Down
3 changes: 2 additions & 1 deletion basic/2-actions.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expect, test } from "@playwright/test";
import { expect } from "@playwright/test";
import { test } from "./base.ts";

test.beforeEach(async ({ page }) => {
await page.goto("https://todomvc.com/examples/backbone/dist/");
Expand Down
13 changes: 6 additions & 7 deletions basic/3-assertions.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { expect, test } from "@playwright/test";
import { expect } from "@playwright/test";
import { test } from "./base.ts";

test.beforeEach(async ({ page }) => {
await page.goto("https://todomvc.com/examples/backbone/dist/");
await page.goto("https://demo.playwright.dev/todomvc");
});

/**
Expand All @@ -10,8 +11,8 @@ test.beforeEach(async ({ page }) => {
*/
test("should be able to use assertions", async ({ page }) => {
await test.step("toHaveTitle/toHaveURL", async () => {
await expect(page).toHaveTitle("TodoMVC: Backbone");
await expect(page).toHaveURL("https://todomvc.com/examples/backbone/dist/");
await expect(page).toHaveTitle("React • TodoMVC");
await expect(page).toHaveURL(/^https:\/\/demo.playwright.dev\/todomvc/);
});

await test.step("toBeEmpty/toHaveValue", async () => {
Expand Down Expand Up @@ -45,11 +46,9 @@ test("should be able to use assertions", async ({ page }) => {
await expect(page.locator("text=Buy milk")).toBeHidden();
});

await test.step("toHaveClass/toHaveCSS", async () => {
await test.step("toHaveClass", async () => {
await expect(
page.locator('[placeholder="What needs to be done?"]')
).toHaveClass("new-todo");
await page.click("text=Clear completed");
await expect(page.locator(".main")).toHaveCSS("display", "none");
});
});
3 changes: 2 additions & 1 deletion basic/4-file-uploads.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {test, expect} from '@playwright/test';
import { expect } from "@playwright/test";
import { test } from "./base.ts";

const fileToUpload = __filename; // '__filename' is the current test file.

Expand Down
3 changes: 2 additions & 1 deletion basic/5-flaky.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expect, test } from "@playwright/test";
import { expect } from "@playwright/test";
import { test } from "./base.ts";

/**
* This test clicks on an element with the text 'Load user' and waits for a
Expand Down
3 changes: 2 additions & 1 deletion basic/6-networking.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {test, expect} from '@playwright/test';
import { expect } from "@playwright/test";
import { test } from "./base.ts";

/**
* This test clicks on an element with the text 'Load user' and waits for a
Expand Down
3 changes: 2 additions & 1 deletion basic/7-accessibility.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test, expect } from "@playwright/test";
import { expect } from "@playwright/test";
import { test } from "./base.ts";
import AxeBuilder from "@axe-core/playwright"; // 1

test.describe("homepage", () => {
Expand Down
2 changes: 1 addition & 1 deletion basic/7-argos.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { argosScreenshot } from "@argos-ci/playwright";
import { test } from "@playwright/test";
import { test } from "./base.ts";

test("basic test @basic", async ({ page }) => {
await page.goto("https://example.com");
Expand Down
48 changes: 48 additions & 0 deletions basic/8-rules.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { expect } from "@playwright/test";
import { test } from "./base.ts";

/**
* All tests in this file are matched with a Currents Quarantine Rule based on filename.
* See the `rules` fixture in `base.ts` to see how the rules fixtures were configured,
* and the docs for more information on how to configure rules: https://docs.currents.dev/guides/automation-rules
*
*/

/**
* This is a failing test that will be quarantined by the file based rule
*
* | field | operation | value | - | action |
* | ----- | --------- | --------------- | --- | ---------- |
* | File | is | 8-rules.spec.ts | -> | Quarantine |
*/
test("rules quarantine test", async ({ page }) => {
await page.goto("https://demo.playwright.dev/todomvc");

// Use locators to represent a selector and re-use them
const inputBox = page.locator("input.new-todo");
const todoList = page.locator(".todo-list");

await inputBox.fill("Learn JavaScript");
await inputBox.press("Enter");
await expect(todoList).toHaveText("Learn Playwright");
});

/**
* This tests will be completely skipped by a rule that matches fileName + test name
*
* | field | operation | value | - | action |
* | ----- | --------- | --------------- | ---- | ---------- |
* | File | is | 8-rules.spec.ts | And | |
* | Title | is | rules skip test | -> | Skip |
*/
test("rules skip test", async ({ page }) => {
await page.goto("https://demo.playwright.dev/todomvc");

// Use locators to represent a selector and re-use them
const inputBox = page.locator("input.new-todo");
const todoList = page.locator(".todo-list");

await inputBox.fill("Learn JavaScript");
await inputBox.press("Enter");
await expect(todoList).toHaveText("Learn JavaScript");
});
11 changes: 11 additions & 0 deletions basic/base.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {
CurrentsFixtures,
CurrentsWorkerFixtures,
fixtures,
} from "@currents/playwright";
import { test as base } from "@playwright/test";

export const test = base.extend<CurrentsFixtures, CurrentsWorkerFixtures>({
...fixtures.baseFixtures,
...fixtures.rulesFixtures,
});
2 changes: 1 addition & 1 deletion basic/pom/todoPage.pom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ export class TodoPage {
}

async goto() {
await this.page.goto("https://todomvc.com/examples/backbone/dist/");
await this.page.goto("https://demo.playwright.dev/todomvc");
}
}
15 changes: 12 additions & 3 deletions basic/pw.config.shared.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { devices, PlaywrightTestConfig } from "@playwright/test";
import { CurrentsFixtures, CurrentsWorkerFixtures } from "@currents/playwright";
import { defineConfig, devices } from "@playwright/test";

const config: PlaywrightTestConfig = {
const config = defineConfig<CurrentsFixtures, CurrentsWorkerFixtures>({
timeout: 10 * 1000,

fullyParallel: true,
Expand Down Expand Up @@ -37,8 +38,16 @@ const config: PlaywrightTestConfig = {
},
],

webServer: {
command: 'node ./server/index.js',
port: 4346,
reuseExistingServer: !process.env.CI,
stdout: 'ignore',
stderr: 'pipe',
},

/* Folder for test artifacts such as screenshots, videos, traces, etc. */
outputDir: "test-results/",
};
});

export default config;
Loading

0 comments on commit d6ce0d1

Please sign in to comment.