Skip to content

Commit

Permalink
feat: playwright tests (#1626)
Browse files Browse the repository at this point in the history
* feat: playwright tests

* feat(test): demo tests

* feat(test): prettier ci & cd

* fix: lower z-index for siders

* fix(ci): install browser
  • Loading branch information
FranGuam authored Mar 6, 2024
1 parent e5a97d1 commit ab9e5a6
Show file tree
Hide file tree
Showing 12 changed files with 714 additions and 324 deletions.
68 changes: 0 additions & 68 deletions .github/workflows/actions.yml

This file was deleted.

25 changes: 25 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: CD

on:
push:
branches: [ master ]

jobs:
deploy:
if: github.repository_owner == 'eesast'
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Login to DockerHub
run: echo "${{secrets.DOCKER_PASSWORD}}" | docker login -u "${{secrets.DOCKER_USERNAME}}" --password-stdin

- name: Build docker image
shell: bash
run: docker build -t eesast/web:latest .

- name: Push docker image
shell: bash
run: docker push eesast/web:latest
60 changes: 60 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: CI

on:
push:
branches:
- '*'
- '!master'
pull_request:
branches: [ master ]

concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"

- name: Get yarn cache path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- name: Restore yarn cache
uses: actions/cache@v4
id: yarn-cache
with:
path: ${{steps.yarn-cache-dir-path.outputs.dir}}
key: ${{runner.os}}-yarn-${{hashFiles('**/yarn.lock')}}
restore-keys: |
${{runner.os}}-yarn-
- name: Install dependencies
run: |
yarn install --frozen-lockfile
yarn playwright install --with-deps
- name: Check grammar
run: |
yarn lint
yarn typecheck
- name: Run Playwright tests
run: yarn playwright test

- name: Upload Playwright report
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 @@ -27,3 +27,7 @@ yarn-error.log*
!.vscode/settings.json
.idea/*
.eslintcache
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@
"@graphql-codegen/cli": "5.0.2",
"@graphql-codegen/typescript-operations": "4.2.0",
"@graphql-codegen/typescript-react-apollo": "4.3.0",
"@testing-library/react": "14.2.1",
"@playwright/test": "^1.42.1",
"@types/file-saver": "2.0.7",
"@types/is-url": "1.2.32",
"@types/jest": "29.5.12",
"@types/lodash.get": "4.4.9",
"@types/node": "20.11.24",
"@types/pizzip": "3.0.5",
Expand Down Expand Up @@ -79,7 +78,7 @@
"reset": "rimraf node_modules && rimraf yarn.lock && yarn",
"clean": "rimraf ./node_modules/.cache && rimraf build && rimraf electron",
"start": "react-app-rewired start",
"test": "react-app-rewired test --transformIgnorePatterns \"node_modules/(?!antd|rc|axios)\"",
"test": "playwright test --ui",
"build": "react-app-rewired build",
"analyze": "cross-env ANALYZER=true yarn build",
"lint": "eslint src --ext .js,.jsx,.ts,.tsx",
Expand Down
77 changes: 77 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { defineConfig, devices } from "@playwright/test";

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

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: "./tests",
/* Run tests in files in parallel */
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",
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: "on-first-retry",
},

/* Configure projects for major browsers */
projects: [
{
name: "chromium",
use: { ...devices["Desktop Chrome"] },
},

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

{
name: "webkit",
use: { ...devices["Desktop Safari"] },
},

/* Test against mobile viewports. */
// {
// name: "Mobile Chrome",
// use: { ...devices["Pixel 5"] },
// },
// {
// name: "Mobile Safari",
// use: { ...devices["iPhone 12"] },
// },

/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
],

/* Run your local dev server before starting the tests */
webServer: {
command: "yarn start",
url: "http://localhost:3000/?source=test",
reuseExistingServer: !process.env.CI,
},
});
19 changes: 0 additions & 19 deletions src/__tests__/App.test.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/app/ContestSite/MenuPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ const MenuPage: React.FC<ContestProps> = (props) => {
left: 0,
top: "72px",
bottom: 0,
zIndex: 99,
zIndex: 98,
}}
>
<Menu
Expand Down
2 changes: 1 addition & 1 deletion src/app/InfoSite/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ const InfoSite: React.FC<PageProps> = ({ mode, user }) => {
left: 0,
top: "72px",
bottom: 0,
zIndex: 99,
zIndex: 98,
}}
>
<Menu
Expand Down
Loading

0 comments on commit ab9e5a6

Please sign in to comment.