-
-
Notifications
You must be signed in to change notification settings - Fork 386
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
353 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: e2e | ||
|
||
on: | ||
push: | ||
branches: [master] | ||
paths: | ||
- "frontend/apps/remark42/**" | ||
- "frontend/e2e/**" | ||
|
||
pull_request: | ||
branches: [master] | ||
paths: | ||
- "frontend/apps/remark42/**" | ||
- "frontend/e2e/**" | ||
|
||
jobs: | ||
tests: | ||
name: Tests | ||
timeout-minutes: 60 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Build & run containers | ||
id: tests | ||
run: COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker-compose -f compose-e2e-test.yml up --build --quiet-pull --exit-code-from tests | ||
|
||
- uses: actions/upload-artifact@v2 | ||
if: always() | ||
with: | ||
name: playwright-report | ||
path: ./playwright-report/ | ||
retention-days: 30 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# compose for running e2e tests in CI | ||
version: "2" | ||
|
||
services: | ||
remark42: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
args: | ||
- SKIP_BACKEND_TEST=true | ||
- SKIP_FRONTEND_TEST=true | ||
|
||
image: umputun/remark42:dev | ||
container_name: "remark42" | ||
|
||
environment: | ||
# remark42 hostname used for proper dev auth work for tests container which connects to it | ||
# using the such hostname (unlike local development where 127.0.0.1 is used) | ||
- REMARK_URL=http://remark42:8080 | ||
- SECRET=12345 | ||
- DEBUG=true | ||
- ADMIN_PASSWD=password | ||
- AUTH_DEV=true # activate local OAuth "dev" listening on http://remark42:8084 | ||
- ADMIN_SHARED_ID=dev_user # set admin flag for default user on local oauth2 | ||
- AUTH_ANON=true | ||
- AUTH_EMAIL_ENABLE=true | ||
volumes: | ||
- ./var:/srv/var | ||
|
||
tests: | ||
build: | ||
context: ./frontend | ||
dockerfile: Dockerfile.e2e | ||
depends_on: [remark42] | ||
volumes: | ||
- ./playwright-report:/frontend/e2e/playwright-report |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/.vscode/ | ||
/.idea/ | ||
|
||
# e2e tests arficats | ||
/e2e/playwright-report/ | ||
/e2e/playwright/.cache/ | ||
/e2e/test-results/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
FROM mcr.microsoft.com/playwright:v1.25.0-focal | ||
|
||
ENV CI true | ||
WORKDIR /frontend | ||
|
||
COPY ./package.json ./pnpm-workspace.yaml ./pnpm-lock.yaml /frontend/ | ||
COPY ./e2e/package.json /frontend/e2e/ | ||
RUN corepack enable pnpm && pnpm install | ||
|
||
COPY ./e2e/playwright.config.ts /frontend/e2e/ | ||
COPY ./e2e/tests /frontend/e2e/tests/ | ||
|
||
WORKDIR /frontend/e2e | ||
|
||
CMD pnpm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules/ | ||
/test-results/ | ||
/playwright-report/ | ||
/playwright/.cache/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "@remark42/tests", | ||
"version": "1.0.0", | ||
"private": true, | ||
"type": "module", | ||
"scripts": { | ||
"test": "playwright test" | ||
}, | ||
"author": "Paul Mineev <paul@mineev.me>", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@playwright/test": "^1.25.0", | ||
"@types/node": "^18.7.8", | ||
"nanoid": "^4.0.0", | ||
"playwright": "^1.25.0", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^4.7.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import type { PlaywrightTestConfig } from '@playwright/test' | ||
import { devices } from '@playwright/test' | ||
|
||
/** | ||
* Read environment variables from file. | ||
* https://github.com/motdotla/dotenv | ||
*/ | ||
// require('dotenv').config(); | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
const config: PlaywrightTestConfig = { | ||
testDir: './tests', | ||
/* Maximum time one test can run for. */ | ||
timeout: 30 * 1000, | ||
expect: { | ||
/** | ||
* Maximum time expect() should wait for the condition to be met. | ||
* For example in `await expect(locator).toHaveText();` | ||
*/ | ||
timeout: 5000, | ||
}, | ||
/* 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: { | ||
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */ | ||
actionTimeout: 0, | ||
/* Base URL to use in actions like `await page.goto('/')`. */ | ||
baseURL: process.env.CI ? 'http://remark42:8080' : 'http://127.0.0.1:8080', | ||
|
||
/* 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: { | ||
// channel: 'msedge', | ||
// }, | ||
// }, | ||
// { | ||
// name: 'Google Chrome', | ||
// use: { | ||
// channel: 'chrome', | ||
// }, | ||
// }, | ||
], | ||
|
||
/* Folder for test artifacts such as screenshots, videos, traces, etc. */ | ||
// outputDir: 'test-results/', | ||
|
||
/* Run your local dev server before starting the tests */ | ||
// webServer: { | ||
// command: 'npm run start', | ||
// port: 3000, | ||
// }, | ||
} | ||
|
||
export default config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** @type {import('prettier').Config} */ | ||
module.exports = { | ||
singleQuote: true, | ||
semi: false, | ||
arrowParens: 'always', | ||
trailingComma: 'es5', | ||
printWidth: 120, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { test } from '@playwright/test' | ||
import { nanoid } from 'nanoid' | ||
import * as path from 'path' | ||
|
||
test.describe('Post comment', () => { | ||
test.beforeEach(async ({ page }) => { | ||
await page.goto('/web/') | ||
}) | ||
|
||
test('as dev user', async ({ page, browserName }) => { | ||
const iframe = page.frameLocator('iframe[name]') | ||
await iframe.locator('text=Sign In').click() | ||
const [authPage] = await Promise.all([ | ||
page.waitForEvent('popup'), | ||
iframe.locator("[title='Sign In with Dev']").click(), | ||
]) | ||
await authPage.locator('text=Authorize').click() | ||
// triggers tab visibility and enables widget to re-render with auth state | ||
await page.press('iframe[name]', 'Tab') | ||
await iframe.locator('textarea').click() | ||
const message = `Hello world! ${nanoid()}` | ||
await iframe.locator('textarea').type(message) | ||
await iframe.locator('text=Send').click() | ||
// checks if comment was posted | ||
iframe.locator(`text=${message}`).first() | ||
await page.reload() | ||
// checks if saved comment is visible | ||
iframe.locator(`text=${message}`).first() | ||
}) | ||
}) |
Oops, something went wrong.