-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Motivation: E2E tests are important to verify the correctness of behavior. Mocking tests are fast and easy to inject inputs but they can't check changes in other sides. It will not be easy to test all functions with e2e tests. So I am going to write e2e tests for core features of the webapp. Modifications: - Set up Playwright for e2e tests of the webapp
- Loading branch information
Showing
13 changed files
with
174 additions
and
0 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,4 @@ | ||
/test-results/ | ||
/playwright-report/ | ||
/blob-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
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,24 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
test.beforeEach('Login', async ({ page }) => { | ||
await page.goto('/'); | ||
|
||
await expect(page.getByText(/Login/)).toBeVisible(); | ||
await page.getByPlaceholder('ID').fill('foo'); | ||
await page.getByPlaceholder('Password').fill('bar'); | ||
await page.getByRole('button', { name: 'Login' }).click(); | ||
}); | ||
|
||
test('welcome message', async ({ page }) => { | ||
await expect(page.getByRole('heading', { name: 'Welcome to Central Dogma!' })).toBeVisible(); | ||
}); | ||
|
||
test('search project', async ({ page }) => { | ||
await page.goto('/'); | ||
|
||
await expect(page.getByText('Search project ...')).toBeVisible(); | ||
await expect(page.getByRole('combobox')).toBeVisible(); | ||
await page.locator('#project-select').click(); | ||
await expect(page.getByRole('option', { name: 'dogma' })).toBeVisible(); | ||
await expect(page.getByRole('option', { name: 'foo' })).toBeVisible(); | ||
}); |
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
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
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,71 @@ | ||
import { defineConfig, devices } from '@playwright/test'; | ||
|
||
/** | ||
* Read environment variables from file. | ||
* https://github.com/motdotla/dotenv | ||
*/ | ||
// import dotenv from 'dotenv'; | ||
// dotenv.config({ path: path.resolve(__dirname, '.env') }); | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
export default defineConfig({ | ||
testDir: './e2e', | ||
/* Timeout for each test. 60 seconds */ | ||
timeout: 60 * 1000, | ||
/* 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'] }, | ||
}, | ||
// Uncomment the following to run tests in other browsers. | ||
// { | ||
// name: 'firefox', | ||
// use: { ...devices['Desktop Firefox'] }, | ||
// }, | ||
// | ||
// { | ||
// name: 'webkit', | ||
// use: { ...devices['Desktop Safari'] }, | ||
// }, | ||
], | ||
|
||
// Run your local dev server before starting the tests | ||
webServer: [ | ||
{ | ||
command: 'npm run backend', | ||
url: 'http://127.0.0.1:36462/monitor/l7check', | ||
reuseExistingServer: !process.env.CI, | ||
stdout: 'ignore', | ||
stderr: 'pipe', | ||
}, | ||
{ | ||
command: 'npm run develop', | ||
url: 'http://127.0.0.1:3000', | ||
reuseExistingServer: !process.env.CI, | ||
stdout: 'ignore', | ||
stderr: 'pipe', | ||
}, | ||
], | ||
}); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.