Skip to content

Commit

Permalink
Use playwright instead of cypress
Browse files Browse the repository at this point in the history
  • Loading branch information
darashi authored Mar 8, 2024
1 parent b1e5017 commit cb4379a
Show file tree
Hide file tree
Showing 16 changed files with 670 additions and 101 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
cypress
e2e
doc
frontend/dist
frontend/node_modules
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Playwright Tests
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies
run: npm ci
- name: Build Frontend
run: npm run build
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Playwright tests
run: npx playwright test
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
22 changes: 0 additions & 22 deletions .github/workflows/test.yml

This file was deleted.

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
/cypress/videos/
/node_modules/
/public/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
3 changes: 0 additions & 3 deletions cypress.json

This file was deleted.

5 changes: 0 additions & 5 deletions cypress/fixtures/example.json

This file was deleted.

6 changes: 0 additions & 6 deletions cypress/integration/root_spec.js

This file was deleted.

17 changes: 0 additions & 17 deletions cypress/plugins/index.js

This file was deleted.

25 changes: 0 additions & 25 deletions cypress/support/commands.js

This file was deleted.

20 changes: 0 additions & 20 deletions cypress/support/index.js

This file was deleted.

23 changes: 23 additions & 0 deletions e2e/login.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { test, expect } from "@playwright/test";

test.describe("login", () => {
test("bad password", async ({ page }) => {
await page.goto("/-login");

await page.fill("input[id=password]", "bad-password");
await page.getByRole("button", { name: "Login" }).click();
await expect(page.getByRole("alert")).toContainText("Authenitacion failed");
});

test("successful login and logout", async ({ page }) => {
await page.goto("/-login");

await page.fill("input[id=password]", "admin-password");
await page.getByRole("button", { name: "Login" }).click();

await expect(page).toHaveURL("/");

await page.getByRole("link", { name: "Logout" }).click();
await expect(page.getByRole("link", { name: "Login" })).toBeVisible();
});
});
37 changes: 37 additions & 0 deletions e2e/top.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { test, expect } from "@playwright/test";

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

await expect(page.getByRole("navigation")).toContainText("SPARQList");
await expect(page.getByRole("link", { name: "Login" })).toBeVisible();
});

test("navigate to login", async ({ page }) => {
await page.goto("/");
await page.click("text=Login");

await expect(page).toHaveURL("/-login");
});

test("search", async ({ page }) => {
await page.goto("/");

await expect(
page.getByRole("link", { name: "gene_and_organism_annotation" }),
).toBeVisible();
await expect(
page.getByRole("link", { name: "adjacent_prefectures -" }),
).toBeVisible();

await page.fill("input[type=search]", "ge");

await expect(
page.getByRole("link", { name: "gene_and_organism_annotation" }),
).toBeVisible();
await expect(
page.getByRole("link", { name: "adjacent_prefectures -" }),
).not.toBeVisible();
});
});
63 changes: 60 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
"devDependencies": {
"@babel/core": "^7.24.0",
"@babel/preset-env": "^7.24.0",
"@types/node": "^20.11.25",
"babel-jest": "^29.7.0",
"cypress": "^13.6.6",
"jest": "^29.7.0",
"nodemon": "^3.1.0"
},
"dependencies": {
"@playwright/test": "^1.42.1",
"accepts": "^1.3.8",
"body-parser": "^1.20.2",
"commonmark": "^0.31.0",
Expand Down
Loading

0 comments on commit cb4379a

Please sign in to comment.