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.
Merge pull request #387 from 2019-2020-ps6/383-cross-offices-tests
383 cross offices tests
- Loading branch information
Showing
20 changed files
with
396 additions
and
37 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
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,18 @@ | ||
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, | ||
}, | ||
}; | ||
|
||
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,56 @@ | ||
{ | ||
"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": { | ||
"front-end-serve": { | ||
"executor": "@angular-devkit/architect:allOf", | ||
"options": { | ||
"targets": [ | ||
{ | ||
"target": "front-end-back-office:serve" | ||
}, | ||
{ | ||
"target": "front-end-front-office:serve" | ||
} | ||
] | ||
} | ||
}, | ||
"e2e": { | ||
"executor": "@mands/nx-playwright:playwright-executor", | ||
"options": { | ||
"ui": true, | ||
"e2eFolder": "apps/front-end/cross-office-e2e", | ||
"packageRunner": "npx", | ||
"devServerTarget": "front-end-cross-office-e2e:front-end-serve" | ||
}, | ||
"configurations": { | ||
"ci": { | ||
"ui": false | ||
}, | ||
"development": {} | ||
} | ||
}, | ||
"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,31 @@ | ||
import { expect } from '@playwright/test'; | ||
import { test } from '@webonjour/fixtures-e2e'; | ||
|
||
test.describe('cross-office', () => { | ||
test.afterEach(async ({ backOfficePage, frontOfficePage }) => { | ||
await backOfficePage.close(); | ||
await frontOfficePage.close(); | ||
}); | ||
|
||
test('back should work', async ({ BackOffice }) => { | ||
await BackOffice.loginPage.goto(); | ||
expect(true).toBeTruthy(); | ||
}); | ||
|
||
test('front should work', async ({ FrontOffice }) => { | ||
await FrontOffice.floorSelectionPage.goto(); | ||
expect(true).toBeTruthy(); | ||
}); | ||
|
||
test('floor selection should work', async ({ FrontOffice }) => { | ||
await FrontOffice.floorSelectionPage.goto(); | ||
await FrontOffice.floorSelectionPage.selectFloor(0); | ||
expect(true).toBeTruthy(); | ||
}); | ||
|
||
test('using both', async ({ BackOffice, FrontOffice }) => { | ||
await BackOffice.loginPage.goto(); | ||
await FrontOffice.floorSelectionPage.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'; | ||
}; |
Oops, something went wrong.