generated from NablaT/starter-ps6-full-stack
-
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.
Ref: #383
- Loading branch information
Showing
9 changed files
with
218 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
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,22 @@ | ||
{ | ||
"extends": ["../../../.eslintrc.json"], | ||
"ignorePatterns": ["!**/*"], | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"], | ||
"rules": { | ||
"jest/no-done-callback": "off" | ||
} | ||
}, | ||
{ | ||
"files": ["*.ts", "*.tsx"], | ||
"rules": { | ||
"jest/no-done-callback": "off" | ||
} | ||
}, | ||
{ | ||
"files": ["*.js", "*.jsx"], | ||
"rules": {} | ||
} | ||
] | ||
} |
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 type { PlaywrightTestConfig } from '@playwright/test'; | ||
|
||
import { baseConfig } from '../../../playwright.config.base'; | ||
|
||
const config: PlaywrightTestConfig = { | ||
...baseConfig, | ||
globalSetup: require.resolve( | ||
'apps/front-end/cross-office-e2e/src/support/global-setup.ts' | ||
), | ||
globalTeardown: require.resolve( | ||
'apps/front-end/cross-office-e2e/src/support/global-teardown.ts' | ||
), | ||
use: { | ||
...baseConfig.use, | ||
ignoreHTTPSErrors: true, | ||
video: 'on-first-retry', | ||
screenshot: 'only-on-failure', | ||
}, | ||
}; | ||
|
||
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,38 @@ | ||
{ | ||
"name": "front-end-cross-office-e2e", | ||
"$schema": "../../../node_modules/nx/schemas/project-schema.json", | ||
"sourceRoot": "apps/front-end/cross-office-e2e/src", | ||
"projectType": "application", | ||
"targets": { | ||
"e2e": { | ||
"executor": "@mands/nx-playwright:playwright-executor", | ||
"options": { | ||
"e2eFolder": "apps/front-end/cross-office-e2e", | ||
"packageRunner": "pnpm" | ||
}, | ||
"configurations": { | ||
"production": {} | ||
} | ||
}, | ||
"ts-check": { | ||
"executor": "nx:run-commands", | ||
"options": { | ||
"commands": [ | ||
{ | ||
"command": "tsc --build --force --verbose apps/undefined-e2e/tsconfig.json" | ||
} | ||
] | ||
} | ||
}, | ||
"lint": { | ||
"executor": "@nrwl/linter:eslint", | ||
"outputs": ["{options.outputFile}"], | ||
"options": { | ||
"lintFilePatterns": [ | ||
"apps/front-end/cross-office-e2e/**/*.{ts,tsx,js,jsx}" | ||
] | ||
} | ||
} | ||
}, | ||
"tags": [] | ||
} |
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 @@ | ||
import { expect, test } from '@playwright/test'; | ||
|
||
test('should start page', async ({ page }) => { | ||
await page.goto('/'); | ||
|
||
expect(true).toBeTruthy(); | ||
}); |
63 changes: 63 additions & 0 deletions
63
apps/front-end/cross-office-e2e/src/support/global-setup.ts
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,63 @@ | ||
/* eslint-disable */ | ||
import axios from 'axios'; | ||
import { subProcess, subProcessSync } from 'subspawn'; | ||
import { environment, protocol } from '@webonjour/shared/environments'; | ||
|
||
var __TEARDOWN_MESSAGE__: string; | ||
|
||
module.exports = async function () { | ||
// Start services that the app needs to run (e.g. database, docker-compose, etc.). | ||
console.log('\nSetting up...\n'); | ||
|
||
let executor = 'docker-compose'; | ||
|
||
// Check if docker compose is installed | ||
try { | ||
subProcessSync('docker-compose --version', true); | ||
} catch (e) { | ||
executor = 'podman-compose'; | ||
try { | ||
subProcessSync('podman-compose --version', true); | ||
} catch (e) { | ||
executor = 'docker compose'; | ||
try { | ||
subProcessSync('docker compose --version', true); | ||
} catch (e) { | ||
console.log('Please install docker-compose or podman-compose'); | ||
process.exit(1); | ||
} | ||
} | ||
} | ||
|
||
subProcessSync(`${executor} -f docker-compose.yml up -d`, true); | ||
// wait for the database to start | ||
for (let i = 0; i < 200; i++) { | ||
try { | ||
// subProcessSync("npx prisma migrate dev deploy", true); | ||
subProcessSync('npx prisma migrate reset --force', true); | ||
subProcessSync('npx prisma generate', true); | ||
break; | ||
} catch (e) { | ||
console.log('Waiting for database to start...'); | ||
await new Promise((resolve) => setTimeout(resolve, 1000)); | ||
} | ||
} | ||
subProcess('API', 'npx nx serve backend-api', true); | ||
|
||
axios.defaults.baseURL = `${protocol(environment.api.secure)}://${ | ||
environment.api.domain | ||
}`; | ||
console.log('axios.defaults.baseURL', axios.defaults.baseURL); | ||
// wait for the server to start | ||
for (let i = 0; i < 200; i++) { | ||
try { | ||
await axios.get(`/health`); | ||
break; | ||
} catch (e) { | ||
console.log('Waiting for server to start...'); | ||
await new Promise((resolve) => setTimeout(resolve, 1000)); | ||
} | ||
} | ||
// Hint: Use `globalThis` to pass variables to global teardown. | ||
globalThis.__TEARDOWN_MESSAGE__ = '\nTearing down...\n'; | ||
}; |
33 changes: 33 additions & 0 deletions
33
apps/front-end/cross-office-e2e/src/support/global-teardown.ts
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 @@ | ||
/* eslint-disable */ | ||
|
||
import { killSubProcesses, subProcessSync } from 'subspawn'; | ||
|
||
module.exports = async function () { | ||
// Put clean up logic here (e.g. stopping services, docker-compose, etc.). | ||
// Hint: `globalThis` is shared between setup and teardown. | ||
// stop the server | ||
|
||
let executor = 'docker-compose'; | ||
|
||
// Check if docker compose is installed | ||
try { | ||
subProcessSync('docker-compose --version', true); | ||
} catch (e) { | ||
executor = 'podman-compose'; | ||
try { | ||
subProcessSync('podman-compose --version', true); | ||
} catch (e) { | ||
executor = 'docker compose'; | ||
try { | ||
subProcessSync('docker compose --version', true); | ||
} catch (e) { | ||
console.log('Please install docker-compose or podman-compose'); | ||
process.exit(1); | ||
} | ||
} | ||
} | ||
|
||
killSubProcesses('API'); | ||
subProcessSync(`${executor} -f docker-compose.yml down`, true); | ||
console.log(globalThis.__TEARDOWN_MESSAGE__); | ||
}; |
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": { | ||
"sourceMap": false, | ||
"outDir": "../../../dist/out-tsc", | ||
"allowJs": true, | ||
"types": ["jest", "node"] | ||
}, | ||
"include": ["**/*.ts", "**/*.js"] | ||
} |
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.base.json", | ||
"files": [], | ||
"include": [], | ||
"references": [ | ||
{ | ||
"path": "./tsconfig.e2e.json" | ||
} | ||
] | ||
} |