Skip to content

Commit

Permalink
Merge pull request #1408 from skaut/playwright
Browse files Browse the repository at this point in the history
Migrated to playwright
  • Loading branch information
marekdedic authored Oct 22, 2023
2 parents 078c05c + 6ef0475 commit 07aa70a
Show file tree
Hide file tree
Showing 46 changed files with 11,045 additions and 15,174 deletions.
20 changes: 12 additions & 8 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"parserOptions": {
"parser": "@typescript-eslint/parser",
"project": ["./tsconfig.json", "./cypress/tsconfig.json"],
"project": ["./tsconfig.json"],
"extraFileExtensions": [".svelte"]
},
"env": {
"browser": true,
"node": false
},
"plugins": ["deprecation", "cypress", "jest", "simple-import-sort", "@typescript-eslint"],
"plugins": ["deprecation", "jest", "simple-import-sort", "@typescript-eslint"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/strict-type-checked",
Expand Down Expand Up @@ -196,14 +196,18 @@
},
{
"files": [
"__tests__/frontend/**/*.cy.ts",
"__tests__/test-utils/stubEndpoints.ts"
"__tests__/frontend/*.ts",
"__tests__/test-utils/stub-endpoints.ts"
],
"extends": ["plugin:cypress/recommended"],
"extends": ["plugin:playwright/recommended"],
"rules": {
"cypress/no-force": "error",
"cypress/assertion-before-screenshot": "error",
"cypress/no-pause": "error"
"playwright/no-nth-methods": "error",
"playwright/no-raw-locators": "error",
"playwright/prefer-strict-equal": "error",
"playwright/prefer-to-be": "error",
"playwright/prefer-to-contain": "error",
"playwright/prefer-to-have-count": "error",
"playwright/prefer-to-have-length": "error"
}
}
],
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,29 @@ jobs:
run: |
npm ci
- name: Get installed Playwright version
id: playwright-version
run: |
echo "version=$(node -e "console.log(require('./package-lock.json').packages['node_modules/@playwright/test'].version)")"
echo "version=$(node -e "console.log(require('./package-lock.json').packages['node_modules/@playwright/test'].version)")" >> $GITHUB_OUTPUT
- name: Cache playwright binaries
id: playwright-cache
uses: actions/cache@v3
with:
path: "~/.cache/ms-playwright"
key: playwright-binaries-${{ runner.os }}-${{ env.cache-version }}-${{ steps.playwright-version.outputs.version }}

- name: "Install playwright binaries"
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: |
npx playwright install --with-deps
- name: "Install playwright binaries"
if: steps.playwright-cache.outputs.cache-hit == 'true'
run: |
npx playwright install-deps
- name: "Run tests"
run: |
npm run test:frontend
Expand All @@ -120,3 +143,10 @@ jobs:
uses: codecov/[email protected]
with:
flags: frontend

- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
91 changes: 75 additions & 16 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Created by https://www.gitignore.io/api/vim,node,vuejs
# Edit at https://www.gitignore.io/?templates=vim,node,vuejs
# Created by https://www.toptal.com/developers/gitignore/api/vim,node,svelte
# Edit at https://www.toptal.com/developers/gitignore?templates=vim,node,svelte

### Node ###
# Logs
Expand All @@ -9,6 +9,7 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
Expand All @@ -24,6 +25,7 @@ lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output
Expand All @@ -44,15 +46,27 @@ build/Release
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

Expand All @@ -62,22 +76,40 @@ typings/
# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
# dotenv environment variable files
.env
.env.test
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# next.js build output
# Next.js build output
.next
out

# nuxt.js build output
# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

Expand All @@ -87,16 +119,47 @@ typings/
# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

### Node Patch ###
# Serverless Webpack directories
.webpack/

# Optional stylelint cache

# SvelteKit build / generate output
.svelte-kit

### Svelte ###
# gitignore template for the SvelteKit, frontend web component framework
# website: https://kit.svelte.dev/

.svelte-kit/
package

### Vim ###
# Swap
[._]*.s[a-v][a-z]
!*.svg # comment out if you don't need vector files
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]

# Session
Session.vim
Sessionx.vim

# Temporary
.netrwhist
Expand All @@ -106,12 +169,8 @@ tags
# Persistent undo
[._]*.un~

### Vuejs ###
# Recommended template: Node.gitignore

dist/
npm-debug.log
yarn-error.log

# End of https://www.gitignore.io/api/vim,node,vuejs
# End of https://www.toptal.com/developers/gitignore/api/vim,node,svelte

/test-results/
/playwright-report/
/playwright/.cache/
37 changes: 0 additions & 37 deletions __tests__/frontend/basic.cy.ts

This file was deleted.

48 changes: 48 additions & 0 deletions __tests__/frontend/basic.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { expect, test } from "playwright-test-coverage";

import { setup } from "../test-utils/stub-endpoints";

test("works with basic configuration", async ({ page }) => {
await page.goto("/");
const getCalls = await setup(page);

await page.evaluate(() => {
window._endpointStubs.listSharedDrives = [
{
status: "success",
value: { status: "success", response: [] },
},
{
status: "success",
value: { status: "success", response: [] },
},
];
window._endpointStubs.move = [
{
status: "success",
value: { status: "success", response: { errors: [] } },
},
];
});

await expect(
page.getByText("Shared drive mover", { exact: true }),
).toBeVisible();
await page.getByText("Continue").click();
await page.getByText("My Drive").click();
await page.getByText("Continue").click();
await page.getByText("My Drive").click();
await page.getByText("Continue").click();
await expect(
page.getByText(
'contents of the folder "My Drive" into the folder "My Drive"',
),
).toBeVisible();
await page.getByText("Move", { exact: true }).click();
await expect(page.getByText("Done!", { exact: true })).toBeVisible();
await expect(page.getByText("Successfully moved")).toBeVisible();

const moveCalls = getCalls("move");
expect(moveCalls).toHaveLength(1);
expect(moveCalls[0]).toStrictEqual(["root", "root", true, true, false]);
});
61 changes: 0 additions & 61 deletions __tests__/frontend/configuration.cy.ts

This file was deleted.

Loading

0 comments on commit 07aa70a

Please sign in to comment.