-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
701ce13
commit 8945ab0
Showing
15 changed files
with
552 additions
and
28 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,69 @@ | ||
name: e2e Tests | ||
|
||
on: | ||
push: | ||
paths: | ||
- 'e2e/**' | ||
- 'shared/**' | ||
- 'api/**' | ||
- 'client/**' | ||
- '.github/workflows/e2e-tests.yml' | ||
- '/*' # include changes in root | ||
- '!infrastructure/**' # exclude infra folder | ||
- 'package.json' | ||
|
||
workflow_dispatch: | ||
|
||
|
||
jobs: | ||
e2e-tests: | ||
name: e2e tests | ||
runs-on: ubuntu-22.04 | ||
|
||
services: | ||
database: | ||
image: postgres:13 | ||
ports: | ||
- 5432:5432 | ||
env: | ||
POSTGRES_USER: blue-carbon-cost | ||
POSTGRES_PASSWORD: blue-carbon-cost | ||
POSTGRES_DB: blc | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Node setup | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: '.nvmrc' | ||
|
||
- uses: pnpm/action-setup@v4 | ||
|
||
- name: Cache dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: node_modules | ||
key: ${{ runner.os }}-node_modules-${{ hashFiles('pnpm-lock.yaml') }} | ||
restore-keys: | | ||
${{ runner.os }}-node_modules- | ||
- name: Install dependencies | ||
working-directory: . | ||
run: pnpm install | ||
|
||
- name: Install Chromium browser | ||
working-directory: e2e | ||
run: npx playwright install --with-deps chromium | ||
|
||
- name: Run e2e tests | ||
working-directory: e2e | ||
run: pnpm test | ||
|
||
- uses: actions/upload-artifact@v4 | ||
if: ${{ !cancelled() }} | ||
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 |
---|---|---|
|
@@ -135,4 +135,8 @@ dist | |
/infrastructure/.terraform/ | ||
|
||
# MacOs | ||
.DS_Store | ||
.DS_Store | ||
|
||
# e2e | ||
/e2e/playwright-report/ | ||
/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,3 @@ | ||
NEXTAUTH_URL=http://localhost:$PORT | ||
NEXTAUTH_SECRET=WAzjpS46vFxp17TsRDU3FXo+TF0vrfy6uhCXwGMBUE8= | ||
NEXT_PUBLIC_API_URL=https://dev.blue-carbon-cost-tool.dev-vizzuality.com/api |
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,20 @@ | ||
{ | ||
"name": "e2e", | ||
"private": true, | ||
"dependencies": { | ||
"shared": "workspace:*" | ||
}, | ||
"devDependencies": { | ||
"@playwright/test": "1.44.1", | ||
"@types/lodash": "4.17.4", | ||
"@types/node": "catalog:", | ||
"tsc-alias": "1.8.10", | ||
"typescript": "catalog:" | ||
}, | ||
"scripts": { | ||
"pretest": "tsc && tsc-alias", | ||
"test": "playwright test -c ./dist/e2e", | ||
"test:ui": "pnpm pretest && playwright test --ui -c ./dist/e2e", | ||
"codegen": "pnpm --filter api start:dev & pnpm --filter client dev & playwright codegen localhost:3000" | ||
} | ||
} |
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,48 @@ | ||
import { defineConfig, devices } from '@playwright/test'; | ||
|
||
const API_URL = 'http://localhost:4000'; | ||
const APP_URL = 'http://localhost:3000'; | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
export default defineConfig({ | ||
/* Run your local dev server before starting the tests */ | ||
webServer: [ | ||
{ | ||
command: 'pnpm --filter api run build && NODE_ENV=test pnpm --filter api run start:prod', | ||
url: API_URL, | ||
reuseExistingServer: !process.env.CI, | ||
}, | ||
{ | ||
command: 'NODE_ENV=test pnpm --filter client run build && NODE_ENV=test pnpm --filter client run start', | ||
url: APP_URL, | ||
reuseExistingServer: !process.env.CI, | ||
}, | ||
], | ||
testDir: './tests', | ||
/* Run tests in files in parallel */ | ||
fullyParallel: false, | ||
workers: 1, | ||
/* 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. */ | ||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */ | ||
reporter: process.env.CI ? 'list' : '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: APP_URL, | ||
/* 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'] }, | ||
}, | ||
], | ||
}); |
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 @@ | ||
import { test, expect, Page } from '@playwright/test'; | ||
import { E2eTestManager } from '@shared/lib/e2e-test-manager'; | ||
import { User } from '@shared/entities/users/user.entity'; | ||
|
||
let testManager: E2eTestManager; | ||
let page: Page; | ||
|
||
test.beforeAll(async ({ browser }) => { | ||
page = await browser.newPage(); | ||
testManager = await E2eTestManager.load(page); | ||
}); | ||
|
||
test.beforeEach(async () => { | ||
await testManager.clearDatabase(); | ||
}); | ||
|
||
test.afterEach(async () => { | ||
await testManager.clearDatabase(); | ||
}); | ||
|
||
test.afterAll(async () => { | ||
await testManager.close(); | ||
}); | ||
|
||
// test('an user signs up successfully', async ({ page }) => { | ||
// const user: Pick<User, 'email' | 'password'> = { | ||
// email: '[email protected]', | ||
// password: 'password', | ||
// }; | ||
// | ||
// await page.goto('/auth/signup'); | ||
// | ||
// await page.getByLabel('Email').fill(user.email); | ||
// await page.locator('input[type="password"]').fill(user.password); | ||
// await page.getByRole('checkbox').check(); | ||
// | ||
// await page.getByRole('button', { name: /sign up/i }).click(); | ||
// | ||
// await page.waitForURL('/auth/signin'); | ||
// | ||
// await page.getByLabel('Email').fill(user.email); | ||
// await page.locator('input[type="password"]').fill(user.password); | ||
// | ||
// await page.getByRole('button', { name: /log in/i }).click(); | ||
// | ||
// await page.waitForURL('/profile'); | ||
// await expect(await page.locator('input[type="email"]')).toHaveValue( | ||
// user.email | ||
// ); | ||
// }); | ||
|
||
test('an user signs in successfully', async ({ page }) => { | ||
const user: Pick<User, 'email' | 'password' | 'partnerName'> = { | ||
email: '[email protected]', | ||
password: '12345678', | ||
partnerName: 'partner-test' | ||
}; | ||
|
||
await testManager.mocks().createUser(user); | ||
await testManager.login(user as User) | ||
await expect(page.getByText(`Email: ${user.email}`)).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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"extends": "../tsconfig.json", | ||
"compilerOptions": { | ||
"target": "ESNext", | ||
"module": "CommonJS", | ||
"moduleResolution": "Node", | ||
"sourceMap": false, | ||
"outDir": "./dist", | ||
} | ||
} |
Oops, something went wrong.