-
-
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
Pavel Mineev
committed
Aug 23, 2022
1 parent
dc048ef
commit 7dda793
Showing
10 changed files
with
331 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
name: frontend | ||
|
||
on: | ||
push: | ||
branches: [master] | ||
paths: ["frontend/apps/remark42/**"] | ||
|
||
pull_request: | ||
branches: [master] | ||
paths: ["frontend/apps/remark42/**"] | ||
|
||
jobs: | ||
e2e: | ||
timeout-minutes: 60 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: "16.15.1" | ||
|
||
- name: Start containers | ||
run: docker-compose -f compose-e2e-test.yml up -d --build | ||
|
||
- name: Install pnpm | ||
uses: pnpm/[email protected] | ||
id: pnpm-install | ||
with: | ||
version: 7 | ||
run_install: false | ||
|
||
- name: Get pnpm store directory | ||
id: pnpm-cache | ||
run: | | ||
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" | ||
- name: Setup pnpm cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} | ||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
restore-keys: | | ||
${{ runner.os }}-pnpm-store- | ||
- name: Install dependencies | ||
run: pnpm i | ||
working-directory: ./frontend/tests | ||
|
||
- name: Install Playwright Browsers | ||
run: npx playwright install --with-deps | ||
working-directory: ./frontend/tests | ||
|
||
- name: Run tests | ||
run: pnpm test | ||
working-directory: ./frontend/tests | ||
|
||
- uses: actions/upload-artifact@v2 | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# 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" | ||
hostname: "remark42" | ||
|
||
ports: | ||
- "8080:8080" # primary rest server | ||
- "8084:8084" # local oauth2 server | ||
|
||
environment: | ||
- REMARK_URL=http://127.0.0.1:8080 | ||
- SECRET=12345 | ||
- DEBUG=true | ||
- ADMIN_PASSWD=password | ||
- AUTH_DEV=true # activate local oauth "dev" | ||
- ADMIN_SHARED_ID=dev_user # set admin flag for default user on local oauth2 | ||
- POSITIVE_SCORE=false # restricts comment's score to be only positive | ||
- EDIT_TIME=5m # edit window | ||
- AUTH_ANON=true | ||
- AUTH_EMAIL_ENABLE=true | ||
volumes: | ||
- ./var:/srv/var |
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,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,17 @@ | ||
{ | ||
"name": "@remark42/tests", | ||
"version": "1.0.0", | ||
"private": true, | ||
"scripts": { | ||
"test": "playwright test" | ||
}, | ||
"author": "Paul Mineev <[email protected]>", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@playwright/test": "^1.25.0", | ||
"@types/node": "^18.7.8", | ||
"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: 'http://localhost: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: { | ||
// 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,21 @@ | ||
import { test } from "@playwright/test"; | ||
|
||
test.describe("Post comment", () => { | ||
test.beforeEach(async ({ page }) => { | ||
await page.goto("http://127.0.0.1:8080/web/"); | ||
}); | ||
|
||
test("as dev user", async ({ page }) => { | ||
const iframe = page.frameLocator("iframe[name]"); | ||
|
||
await iframe.locator("text=Sign In").click(); | ||
await iframe.locator("[title='Sign In with Dev']").click(); | ||
|
||
const authPage = await page.waitForEvent("popup"); | ||
|
||
await authPage.locator("text=Authorize").click(); | ||
await page.locator("body").focus(); | ||
await iframe.locator("textarea").type("Hello World"); | ||
await iframe.locator("text=Send").click(); | ||
}); | ||
}); |
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,9 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"lib": ["es5", "dom"], | ||
"types": ["cypress", "node"], | ||
"baseUrl": "." | ||
}, | ||
"include": ["**/*.ts"] | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
packages: | ||
- "apps/*" | ||
- "e2e" | ||
- "packages/*" |