From 96866192433fbd252b041f5752a8fd65e6042bc4 Mon Sep 17 00:00:00 2001 From: Stepan Vladovskiy Date: Mon, 8 Jul 2024 09:52:32 +0000 Subject: [PATCH 1/4] feat: e2e_tests job is started in case if ci all jobs are successeful. In output return github.event.depolyment ststus for debug. (not a prod mode) --- .github/workflows/node-ci.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.yml index 4729e632..5e819c27 100644 --- a/.github/workflows/node-ci.yml +++ b/.github/workflows/node-ci.yml @@ -26,9 +26,13 @@ jobs: run: npm run build e2e_tests: - if: github.event_name == 'deployment_status' && github.event.deployment_status.state == 'success' + needs: ci runs-on: ubuntu-latest steps: + - name: Debug event info + run: | + echo "Event Name: ${{ github.event_name }}" + echo "Deployment Status: ${{ github.event.deployment_status.state }}" - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: From 32519d5ee923f2c856f9466717f87a631141ba08 Mon Sep 17 00:00:00 2001 From: Stepan Vladovskiy Date: Mon, 8 Jul 2024 10:10:35 +0000 Subject: [PATCH 2/4] fix: without auth playwright tests, they are in tests-with-auth dir. testing --- .../2-auth-topics-actions.spec.ts | 1 + .../3-auth-drafts-actions.spec.ts | 1 + .../4-auth-user-actions.spec.ts | 1 + tests-with-auth/readme.txt | 1 + tests/{page-sections.spec.ts => 1-page-sections.spec.ts} | 1 + 5 files changed, 5 insertions(+) rename tests/auth-topics-actions.spec.ts => tests-with-auth/2-auth-topics-actions.spec.ts (99%) rename tests/auth-drafts-actions.spec.ts => tests-with-auth/3-auth-drafts-actions.spec.ts (99%) rename tests/auth-user-actions.spec.ts => tests-with-auth/4-auth-user-actions.spec.ts (99%) create mode 100644 tests-with-auth/readme.txt rename tests/{page-sections.spec.ts => 1-page-sections.spec.ts} (98%) diff --git a/tests/auth-topics-actions.spec.ts b/tests-with-auth/2-auth-topics-actions.spec.ts similarity index 99% rename from tests/auth-topics-actions.spec.ts rename to tests-with-auth/2-auth-topics-actions.spec.ts index f94e16cd..29f03204 100644 --- a/tests/auth-topics-actions.spec.ts +++ b/tests-with-auth/2-auth-topics-actions.spec.ts @@ -45,6 +45,7 @@ test.beforeAll(async ({ browser }) => { console.log('Waiting for the server to start...') await new Promise((resolve) => setTimeout(resolve, 5000)) const baseURL = process.env.BASE_URL || 'https://localhost:3000' + console.log('Base URL:', baseURL) await waitForServer(baseURL) page = await browser.newPage() test.setTimeout(150000) diff --git a/tests/auth-drafts-actions.spec.ts b/tests-with-auth/3-auth-drafts-actions.spec.ts similarity index 99% rename from tests/auth-drafts-actions.spec.ts rename to tests-with-auth/3-auth-drafts-actions.spec.ts index 4c804d4a..650cdab8 100644 --- a/tests/auth-drafts-actions.spec.ts +++ b/tests-with-auth/3-auth-drafts-actions.spec.ts @@ -45,6 +45,7 @@ test.beforeAll(async ({ browser }) => { console.log('Waiting for the server to start...') await new Promise((resolve) => setTimeout(resolve, 5000)) const baseURL = process.env.BASE_URL || 'https://localhost:3000' + console.log('Base URL:', baseURL) await waitForServer(baseURL) page = await browser.newPage() test.setTimeout(150000) diff --git a/tests/auth-user-actions.spec.ts b/tests-with-auth/4-auth-user-actions.spec.ts similarity index 99% rename from tests/auth-user-actions.spec.ts rename to tests-with-auth/4-auth-user-actions.spec.ts index 9323519e..11f5a5a6 100644 --- a/tests/auth-user-actions.spec.ts +++ b/tests-with-auth/4-auth-user-actions.spec.ts @@ -47,6 +47,7 @@ test.beforeAll(async ({ browser }) => { console.log('Waiting for the server to start...') await new Promise((resolve) => setTimeout(resolve, 5000)) const baseURL = process.env.BASE_URL || 'https://localhost:3000' + console.log('Base URL:', baseURL) await waitForServer(baseURL) context = await browser.newContext() page = await context.newPage() diff --git a/tests-with-auth/readme.txt b/tests-with-auth/readme.txt new file mode 100644 index 00000000..02a91b29 --- /dev/null +++ b/tests-with-auth/readme.txt @@ -0,0 +1 @@ +This is folder with Playwright tests, that are needed to move in /tests dir for wrking on playwright circle \ No newline at end of file diff --git a/tests/page-sections.spec.ts b/tests/1-page-sections.spec.ts similarity index 98% rename from tests/page-sections.spec.ts rename to tests/1-page-sections.spec.ts index f3c36901..8f51104b 100644 --- a/tests/page-sections.spec.ts +++ b/tests/1-page-sections.spec.ts @@ -45,6 +45,7 @@ test.beforeAll(async ({ browser }) => { console.log('Waiting for the server to start...') await new Promise((resolve) => setTimeout(resolve, 5000)) const baseURL = process.env.BASE_URL || 'https://localhost:3000' + console.log('Base URL:', baseURL) await waitForServer(baseURL) page = await browser.newPage() test.setTimeout(150000) From 3bfa4adf6855bcea1eef733b3632974ada32661a Mon Sep 17 00:00:00 2001 From: Stepan Vladovskiy Date: Mon, 8 Jul 2024 10:24:07 +0000 Subject: [PATCH 3/4] fix: playwright config with baseURL env bar. --- playwright.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playwright.config.ts b/playwright.config.ts index 3d8bb816..b3bf954d 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -27,7 +27,7 @@ export default defineConfig({ /* 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: 'https://localhost:3000', + baseURL: process.env.BASE_URL || 'https://localhost:3000', /* Headless */ headless: true, /* Ignode SSL certificates */ From c6816b9271ebb93ebc4f4baf33c229f592d24724 Mon Sep 17 00:00:00 2001 From: Stepan Vladovskiy Date: Mon, 8 Jul 2024 10:37:56 +0000 Subject: [PATCH 4/4] feat: With e2e tests on CI github worflow. README+. After tuned page need to move auth tests to main test dir --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 81599367..d45e61c2 100644 --- a/README.md +++ b/README.md @@ -46,3 +46,18 @@ If workers is no needed use: - `npx playwright test --project=webkit --workers 4` For more information on how to write tests using Playwright - [Playwright documentation](https://playwright.dev/docs/intro). + +## 🚀 Tests in CI Mode + +Tests are executed within a GitHub workflow. We organize our tests into two main directories: + +- `tests`: Contains tests that do not require authentication. +- `tests-with-auth`: Houses tests that interact with authenticated parts of the application. + +🔧 **Configuration:** + +Playwright is configured to utilize the `BASE_URL` environment variable. Ensure this is properly set in your CI configuration to point to the correct environment. + +📝 **Note:** + +After pages have been adjusted to work with authentication, all tests should be moved to the `tests` directory to streamline the testing process.