Skip to content

Commit

Permalink
test(e2e): AVR-549 replace Protractor tests with Playwright
Browse files Browse the repository at this point in the history
  • Loading branch information
mkrzyzanowski committed Nov 15, 2024
1 parent 079a917 commit c476f26
Show file tree
Hide file tree
Showing 20 changed files with 279 additions and 15,412 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Deploy Staging

on:
release:
types: [ published ]
types: [published]
push:
branches:
- dev
Expand All @@ -12,7 +12,7 @@ on:
permissions:
contents: read
id-token: write

jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -22,8 +22,8 @@ jobs:
- name: Use Node.js 14
uses: actions/setup-node@v4
with:
node-version: '14'
cache: 'npm'
node-version: "14"
cache: "npm"

- name: Install deps
run: |
Expand All @@ -38,7 +38,7 @@ jobs:
- name: Run E2E Tests
run: |
npm run e2e
npm run e2e:stg
- name: Build SSR
run: |
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ name: Deploy to ECS

on:
release:
types: [ published ]
types: [published]
workflow_dispatch:

permissions:
contents: read
id-token: write

jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -18,8 +18,8 @@ jobs:
- name: Use Node.js 14
uses: actions/setup-node@v4
with:
node-version: '14'
cache: 'npm'
node-version: "14"
cache: "npm"

- name: Install deps
run: |
Expand All @@ -35,7 +35,7 @@ jobs:
- name: Run E2E Tests
continue-on-error: true
run: |
npm run e2e
npm run e2e:live
- name: Build SSR
run: |
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/deploy_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ name: Deploy to GH Pages (dev)

on:
push:
branches: [ dev ]
branches: [dev]

permissions:
contents: read
id-token: write

jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -17,8 +17,8 @@ jobs:
- name: Use Node.js 14
uses: actions/setup-node@v4
with:
node-version: '14'
cache: 'npm'
node-version: "14"
cache: "npm"

- name: Install deps
run: |
Expand All @@ -33,7 +33,7 @@ jobs:
- name: Run E2E Tests
run: |
npm run e2e
npm run e2e:dev
- name: Build Beta
run: |
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/test-e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: E2E Tests
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
workflow_dispatch:
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "14"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Playwright tests
run: npx playwright test
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright-report/
retention-days: 14
37 changes: 0 additions & 37 deletions .github/workflows/test.yml

This file was deleted.

5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,8 @@ testem.log
# System Files
.DS_Store
Thumbs.db
node_modules/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
12 changes: 12 additions & 0 deletions e2e/app.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { test, expect } from "@playwright/test";

test.describe("avrae frontpage", () => {
test.beforeEach(async ({ page }) => {
await page.goto("/");
});

test("should display welcome message", async ({ page }) => {
const paragraphText = await page.textContent("css=.about-avrae");
expect(paragraphText).toContain("I am Avrae");
});
});
35 changes: 35 additions & 0 deletions e2e/commands.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { test, expect } from "@playwright/test";
import { CommandsPage } from "./pages/commands";

test.describe("avrae commands page", () => {
let commandsPage: CommandsPage;

test.beforeEach(async ({ page }) => {
commandsPage = new CommandsPage(page);
await commandsPage.navigate();
});

test("should display a header", async () => {
const headerText = await commandsPage.getHeaderText();
expect(headerText).toEqual("Avrae Commands");
});

test("should show some modules", async () => {
const renderedModules = await commandsPage.getRenderedModules();
for (const moduleElement of await renderedModules.all()) {
expect(moduleElement);
}
});

test("should show some commands in each module", async () => {
const renderedModules = await commandsPage.getRenderedModules();
for (const moduleElement of await renderedModules.all()) {
const moduleCommands = await commandsPage.getModuleCommands(
moduleElement
);
for (const commandElement of await moduleCommands.all()) {
expect(commandElement).toBeVisible();
}
}
});
});
25 changes: 25 additions & 0 deletions e2e/pages/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Page } from "@playwright/test";

export class CommandsPage {
readonly page: Page;

constructor(page: Page) {
this.page = page;
}

async navigate() {
await this.page.goto("/commands");
}

async getHeaderText() {
return this.page.textContent("h1");
}

async getRenderedModules() {
return this.page.locator("css=.module-container");
}

async getModuleCommands(moduleElement) {
return moduleElement.locator("css=avr-command-display");
}
}
10 changes: 0 additions & 10 deletions e2e/protractor-ci.conf.js

This file was deleted.

28 changes: 0 additions & 28 deletions e2e/protractor.conf.js

This file was deleted.

14 changes: 0 additions & 14 deletions e2e/src/app.e2e-spec.ts

This file was deleted.

11 changes: 0 additions & 11 deletions e2e/src/app.po.ts

This file was deleted.

25 changes: 0 additions & 25 deletions e2e/src/commands.e2e-spec.ts

This file was deleted.

13 changes: 0 additions & 13 deletions e2e/tsconfig.e2e.json

This file was deleted.

6 changes: 6 additions & 0 deletions e2e/urls.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const URLS = {
live: "https://avrae.io",
stg: "",
dev: "http://localhost:4200",
docker: "http://localhost:8000",
};
Loading

0 comments on commit c476f26

Please sign in to comment.