From e2796e23bb7c01c7290354e80cdcf53b59e4978d Mon Sep 17 00:00:00 2001 From: KobeN <7845001+kobenguyent@users.noreply.github.com> Date: Sun, 25 Feb 2024 17:44:02 +0100 Subject: [PATCH 01/11] feat: build app ci/cd --- .github/workflows/build-app.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/build-app.yml diff --git a/.github/workflows/build-app.yml b/.github/workflows/build-app.yml new file mode 100644 index 0000000..8ac9c73 --- /dev/null +++ b/.github/workflows/build-app.yml @@ -0,0 +1,29 @@ +# This to verify lib version bump doesn't break anything +name: Building app testing + +on: + push: + branches: + - master + - main + pull_request: + branches: + - '**' + +jobs: + publish-npm: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 16 + registry-url: https://registry.npmjs.org/ + - run: git config --global user.name "GitHub CD bot" + - run: git config --global user.email "github-cd-bot@example.com" + - name: Install deps + run: npm i + - name: Build docs + run: npm run build + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From 90c92edf473fd875b5efd1433c8a1c88a9f66e31 Mon Sep 17 00:00:00 2001 From: kobenguyent Date: Mon, 26 Feb 2024 11:24:48 +0100 Subject: [PATCH 02/11] fix: e2e tests --- .../workflows/{build-app.yml => e2-tests.yml} | 10 +++++----- .gitignore | 5 +++++ test/e2e/codecept.conf.ts | 15 ++++++++++++++ test/e2e/homepage_test.ts | 16 +++++++++++++++ test/e2e/package.json | 20 +++++++++++++++++++ test/e2e/steps.d.ts | 11 ++++++++++ test/e2e/steps_file.ts | 10 ++++++++++ test/e2e/tsconfig.json | 16 +++++++++++++++ 8 files changed, 98 insertions(+), 5 deletions(-) rename .github/workflows/{build-app.yml => e2-tests.yml} (71%) create mode 100644 test/e2e/codecept.conf.ts create mode 100644 test/e2e/homepage_test.ts create mode 100644 test/e2e/package.json create mode 100644 test/e2e/steps.d.ts create mode 100644 test/e2e/steps_file.ts create mode 100644 test/e2e/tsconfig.json diff --git a/.github/workflows/build-app.yml b/.github/workflows/e2-tests.yml similarity index 71% rename from .github/workflows/build-app.yml rename to .github/workflows/e2-tests.yml index 8ac9c73..65b2139 100644 --- a/.github/workflows/build-app.yml +++ b/.github/workflows/e2-tests.yml @@ -1,5 +1,5 @@ # This to verify lib version bump doesn't break anything -name: Building app testing +name: E2E Tests on: push: @@ -22,8 +22,8 @@ jobs: - run: git config --global user.name "GitHub CD bot" - run: git config --global user.email "github-cd-bot@example.com" - name: Install deps - run: npm i - - name: Build docs - run: npm run build + run: npm i -g wait-for-localhost-cli && npm i + - name: Start app + run: npm run serve; wait-for-localhost 8080; cd test/e2e; npm run test env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 9d3a14b..3b2b76d 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,8 @@ yarn-error.log* /dist_electron package-lock.json + + +test/e2e/node_modules +test/e2e/yarn.lock +test/e2e/output diff --git a/test/e2e/codecept.conf.ts b/test/e2e/codecept.conf.ts new file mode 100644 index 0000000..9990874 --- /dev/null +++ b/test/e2e/codecept.conf.ts @@ -0,0 +1,15 @@ +export const config: CodeceptJS.MainConfig = { + tests: './*_test.ts', + output: './output', + helpers: { + Playwright: { + browser: 'chromium', + url: 'http://localhost:8080', + show: false + } + }, + include: { + I: './steps_file' + }, + name: 'e2e' +} diff --git a/test/e2e/homepage_test.ts b/test/e2e/homepage_test.ts new file mode 100644 index 0000000..2466638 --- /dev/null +++ b/test/e2e/homepage_test.ts @@ -0,0 +1,16 @@ +const { I } = inject(); + +Feature('homepage'); + +Before(() => { + I.amOnPage(''); +}) + +Scenario('See write a test button', () => { + I.waitForText('Write a Test'); +}); + +Scenario('See scenario detail link', () => { + I.waitForElement('.Scenario-detailLink'); +}); + diff --git a/test/e2e/package.json b/test/e2e/package.json new file mode 100644 index 0000000..f896a74 --- /dev/null +++ b/test/e2e/package.json @@ -0,0 +1,20 @@ +{ + "name": "e2e", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "npx codeceptjs run --verbose" + }, + "author": "", + "license": "ISC", + "dependencies": { + "codeceptjs": "^3.5.14", + "playwright": "^1.41.2" + }, + "devDependencies": { + "@types/node": "20.11.20", + "ts-node": "10.9.2", + "typescript": "5.3.3" + } +} diff --git a/test/e2e/steps.d.ts b/test/e2e/steps.d.ts new file mode 100644 index 0000000..49d8f0f --- /dev/null +++ b/test/e2e/steps.d.ts @@ -0,0 +1,11 @@ +/// +type steps_file = typeof import('./steps_file'); + +declare namespace CodeceptJS { + interface SupportObject { I: I, current: any } + interface Methods extends Playwright {} + interface I extends ReturnType {} + namespace Translation { + interface Actions {} + } +} diff --git a/test/e2e/steps_file.ts b/test/e2e/steps_file.ts new file mode 100644 index 0000000..1083a85 --- /dev/null +++ b/test/e2e/steps_file.ts @@ -0,0 +1,10 @@ +// in this file you can append custom step methods to 'I' object + +export = function() { + return actor({ + + // Define custom steps here, use 'this' to access default methods of I. + // It is recommended to place a general 'login' function here. + + }); +} diff --git a/test/e2e/tsconfig.json b/test/e2e/tsconfig.json new file mode 100644 index 0000000..a4a3e5f --- /dev/null +++ b/test/e2e/tsconfig.json @@ -0,0 +1,16 @@ +{ + "ts-node": { + "files": true + }, + "compilerOptions": { + "target": "es2018", + "lib": ["es2018", "DOM"], + "esModuleInterop": true, + "module": "commonjs", + "strictNullChecks": false, + "types": ["codeceptjs", "node"], + "declaration": true, + "skipLibCheck": true + }, + "exclude": ["node_modules"] +} \ No newline at end of file From 352dc2c2c6312a74208959f5afac8ad3410d88a0 Mon Sep 17 00:00:00 2001 From: kobenguyent Date: Mon, 26 Feb 2024 11:28:55 +0100 Subject: [PATCH 03/11] fix: e2e command --- .github/workflows/e2-tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2-tests.yml b/.github/workflows/e2-tests.yml index 65b2139..5ef959e 100644 --- a/.github/workflows/e2-tests.yml +++ b/.github/workflows/e2-tests.yml @@ -23,7 +23,7 @@ jobs: - run: git config --global user.email "github-cd-bot@example.com" - name: Install deps run: npm i -g wait-for-localhost-cli && npm i - - name: Start app - run: npm run serve; wait-for-localhost 8080; cd test/e2e; npm run test + - name: Start app and run tests + run: npm run serve &; wait-for-localhost 8080; cd test/e2e; npm i && npm run test env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 9d65ad7b9da4948fe2bfa39cec9e385caf07fd52 Mon Sep 17 00:00:00 2001 From: kobenguyent Date: Mon, 26 Feb 2024 11:30:51 +0100 Subject: [PATCH 04/11] fix: e2e command --- .github/workflows/e2-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2-tests.yml b/.github/workflows/e2-tests.yml index 5ef959e..391051c 100644 --- a/.github/workflows/e2-tests.yml +++ b/.github/workflows/e2-tests.yml @@ -24,6 +24,6 @@ jobs: - name: Install deps run: npm i -g wait-for-localhost-cli && npm i - name: Start app and run tests - run: npm run serve &; wait-for-localhost 8080; cd test/e2e; npm i && npm run test + run: npm run serve & wait-for-localhost 8080; cd test/e2e; npm i && npm run test env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 263360f5aef404ceb95b61ebc65efebc505965dc Mon Sep 17 00:00:00 2001 From: kobenguyent Date: Mon, 26 Feb 2024 11:33:11 +0100 Subject: [PATCH 05/11] fix: e2e command --- .github/workflows/e2-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2-tests.yml b/.github/workflows/e2-tests.yml index 391051c..ee49096 100644 --- a/.github/workflows/e2-tests.yml +++ b/.github/workflows/e2-tests.yml @@ -24,6 +24,6 @@ jobs: - name: Install deps run: npm i -g wait-for-localhost-cli && npm i - name: Start app and run tests - run: npm run serve & wait-for-localhost 8080; cd test/e2e; npm i && npm run test + run: npm run serve & wait-for-localhost 8080; cd test/e2e; npm i && npx playwright install chromium && npm run test env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 74188e87c4ab59b0c7b51f5068a8e2549137fd63 Mon Sep 17 00:00:00 2001 From: kobenguyent Date: Mon, 26 Feb 2024 11:37:15 +0100 Subject: [PATCH 06/11] fix: e2e command --- test/e2e/codecept.conf.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/e2e/codecept.conf.ts b/test/e2e/codecept.conf.ts index 9990874..474f125 100644 --- a/test/e2e/codecept.conf.ts +++ b/test/e2e/codecept.conf.ts @@ -5,7 +5,9 @@ export const config: CodeceptJS.MainConfig = { Playwright: { browser: 'chromium', url: 'http://localhost:8080', - show: false + show: false, + timeout: 10000, + waitForNavigation: 'load' } }, include: { From 6b51602eda4e790feb7a0e439e9a903140ae772f Mon Sep 17 00:00:00 2001 From: kobenguyent Date: Mon, 26 Feb 2024 11:48:57 +0100 Subject: [PATCH 07/11] fix: e2e command --- test/e2e/homepage_test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/homepage_test.ts b/test/e2e/homepage_test.ts index 2466638..213454a 100644 --- a/test/e2e/homepage_test.ts +++ b/test/e2e/homepage_test.ts @@ -2,7 +2,7 @@ const { I } = inject(); Feature('homepage'); -Before(() => { +BeforeSuite(() => { I.amOnPage(''); }) From a2b332463c165ae228118d3ec8f4b1f58e2b8527 Mon Sep 17 00:00:00 2001 From: kobenguyent Date: Mon, 26 Feb 2024 11:49:24 +0100 Subject: [PATCH 08/11] fix: e2e command --- test/e2e/codecept.conf.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/e2e/codecept.conf.ts b/test/e2e/codecept.conf.ts index 474f125..578bd55 100644 --- a/test/e2e/codecept.conf.ts +++ b/test/e2e/codecept.conf.ts @@ -7,7 +7,8 @@ export const config: CodeceptJS.MainConfig = { url: 'http://localhost:8080', show: false, timeout: 10000, - waitForNavigation: 'load' + waitForNavigation: 'load', + waitForAction: 10000 } }, include: { From 3b182a13abacb0b5f4811f743c5b423202c11cbc Mon Sep 17 00:00:00 2001 From: kobenguyent Date: Mon, 26 Feb 2024 11:53:42 +0100 Subject: [PATCH 09/11] fix: e2e command --- test/e2e/homepage_test.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/test/e2e/homepage_test.ts b/test/e2e/homepage_test.ts index 213454a..c0e255f 100644 --- a/test/e2e/homepage_test.ts +++ b/test/e2e/homepage_test.ts @@ -2,15 +2,10 @@ const { I } = inject(); Feature('homepage'); -BeforeSuite(() => { - I.amOnPage(''); -}) -Scenario('See write a test button', () => { +Scenario('Home page is loaded', () => { + I.amOnPage(''); I.waitForText('Write a Test'); -}); - -Scenario('See scenario detail link', () => { I.waitForElement('.Scenario-detailLink'); }); From af970c72dc740a0da795b74d27667cb93019841f Mon Sep 17 00:00:00 2001 From: KobeN <7845001+kobenguyent@users.noreply.github.com> Date: Mon, 26 Feb 2024 12:10:01 +0100 Subject: [PATCH 10/11] fix: codecept conf --- test/e2e/codecept.conf.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/codecept.conf.ts b/test/e2e/codecept.conf.ts index 578bd55..e53e30a 100644 --- a/test/e2e/codecept.conf.ts +++ b/test/e2e/codecept.conf.ts @@ -8,7 +8,7 @@ export const config: CodeceptJS.MainConfig = { show: false, timeout: 10000, waitForNavigation: 'load', - waitForAction: 10000 + waitForTimeout: 10000 } }, include: { From cbe7c48f95c708136cfe6991828bc7bb8aaed22b Mon Sep 17 00:00:00 2001 From: KobeN <7845001+kobenguyent@users.noreply.github.com> Date: Mon, 26 Feb 2024 12:22:05 +0100 Subject: [PATCH 11/11] homepage_test.ts aktualisieren --- test/e2e/homepage_test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/test/e2e/homepage_test.ts b/test/e2e/homepage_test.ts index c0e255f..3ae8888 100644 --- a/test/e2e/homepage_test.ts +++ b/test/e2e/homepage_test.ts @@ -6,6 +6,5 @@ Feature('homepage'); Scenario('Home page is loaded', () => { I.amOnPage(''); I.waitForText('Write a Test'); - I.waitForElement('.Scenario-detailLink'); });