From 23cac4215164ec8906e93ee4da0c35ae3d71d2f7 Mon Sep 17 00:00:00 2001 From: BOHEUS Date: Fri, 8 Nov 2024 21:32:41 +0100 Subject: [PATCH 1/3] Basic test verifying if demo account is working properly --- packages/twenty-e2e-testing/playwright.config.ts | 7 +++++++ .../twenty-e2e-testing/tests/demo_basic.spec.ts | 14 ++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 packages/twenty-e2e-testing/tests/demo_basic.spec.ts diff --git a/packages/twenty-e2e-testing/playwright.config.ts b/packages/twenty-e2e-testing/playwright.config.ts index 964b31e3210f..034d84ac3884 100644 --- a/packages/twenty-e2e-testing/playwright.config.ts +++ b/packages/twenty-e2e-testing/playwright.config.ts @@ -40,6 +40,13 @@ export default defineConfig({ name: 'Login setup', testMatch: /login\.setup\.ts/, // finds all tests matching this regex, in this case only 1 test should be found }, + { + name: 'Demo check', + use: { + ...devices['Desktop Chrome'], + }, + testMatch: /demo_basic\.spec\.ts/, + }, { name: 'chromium', use: { diff --git a/packages/twenty-e2e-testing/tests/demo_basic.spec.ts b/packages/twenty-e2e-testing/tests/demo_basic.spec.ts new file mode 100644 index 000000000000..a4268cc3d5e2 --- /dev/null +++ b/packages/twenty-e2e-testing/tests/demo_basic.spec.ts @@ -0,0 +1,14 @@ +import { test, expect } from '../lib/fixtures/screenshot'; + +test('Fail if demo account is working properly @demo-only', async ({ + page, +}) => { + await page.goto('https://demo.twenty.com/'); + await page.getByRole('button', { name: 'Continue With Email' }).click(); + await page.getByRole('button', { name: 'Continue', exact: true }).click(); + await page.getByRole('button', { name: 'Sign in' }).click(); + await expect(page.getByText('Welcome to Twenty')).not.toBeVisible(); + await expect(page.getByText('Server’s on a coffee break')).toBeVisible({ + timeout: 10000, + }); +}); From 422196bca8b4445e0d56bdffb7f6b7756a93e6d6 Mon Sep 17 00:00:00 2001 From: BOHEUS Date: Sat, 9 Nov 2024 11:29:30 +0100 Subject: [PATCH 2/3] Fix structure --- packages/twenty-e2e-testing/playwright.config.ts | 4 +++- packages/twenty-e2e-testing/tests/{ => all}/companies.spec.ts | 2 +- .../twenty-e2e-testing/tests/{ => all}/workspaces.spec.ts | 2 +- .../twenty-e2e-testing/tests/{ => demo}/demo_basic.spec.ts | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) rename packages/twenty-e2e-testing/tests/{ => all}/companies.spec.ts (91%) rename packages/twenty-e2e-testing/tests/{ => all}/workspaces.spec.ts (98%) rename packages/twenty-e2e-testing/tests/{ => demo}/demo_basic.spec.ts (89%) diff --git a/packages/twenty-e2e-testing/playwright.config.ts b/packages/twenty-e2e-testing/playwright.config.ts index 034d84ac3884..23d5006f34fc 100644 --- a/packages/twenty-e2e-testing/playwright.config.ts +++ b/packages/twenty-e2e-testing/playwright.config.ts @@ -45,7 +45,7 @@ export default defineConfig({ use: { ...devices['Desktop Chrome'], }, - testMatch: /demo_basic\.spec\.ts/, + testMatch: /demo\/demo_basic\.spec\.ts/, }, { name: 'chromium', @@ -54,6 +54,7 @@ export default defineConfig({ storageState: path.resolve(__dirname, '.auth', 'user.json'), // takes saved cookies from directory }, dependencies: ['Login setup'], // forces to run login setup before running tests from this project - CASE SENSITIVE + testMatch: /all\/.+\.spec\.ts/, }, { name: 'firefox', @@ -62,6 +63,7 @@ export default defineConfig({ storageState: path.resolve(__dirname, '.auth', 'user.json'), }, dependencies: ['Login setup'], + testMatch: /all\/.+\.spec\.ts/, }, //{ diff --git a/packages/twenty-e2e-testing/tests/companies.spec.ts b/packages/twenty-e2e-testing/tests/all/companies.spec.ts similarity index 91% rename from packages/twenty-e2e-testing/tests/companies.spec.ts rename to packages/twenty-e2e-testing/tests/all/companies.spec.ts index 1aa53d61322e..d372b214af30 100644 --- a/packages/twenty-e2e-testing/tests/companies.spec.ts +++ b/packages/twenty-e2e-testing/tests/all/companies.spec.ts @@ -1,4 +1,4 @@ -import { test, expect } from '../lib/fixtures/screenshot'; +import { test, expect } from '../../lib/fixtures/screenshot'; test.describe('Basic check', () => { test('Checking if table in Companies is visible', async ({ page }) => { diff --git a/packages/twenty-e2e-testing/tests/workspaces.spec.ts b/packages/twenty-e2e-testing/tests/all/workspaces.spec.ts similarity index 98% rename from packages/twenty-e2e-testing/tests/workspaces.spec.ts rename to packages/twenty-e2e-testing/tests/all/workspaces.spec.ts index f8cff58f5414..ebe79f8e235d 100644 --- a/packages/twenty-e2e-testing/tests/workspaces.spec.ts +++ b/packages/twenty-e2e-testing/tests/all/workspaces.spec.ts @@ -1,5 +1,5 @@ import { test, expect } from '@playwright/test'; -import { sh } from '../drivers/shell_driver'; +import { sh } from '../../drivers/shell_driver'; test.describe('', () => { test('Testing logging', async ({ page }) => { diff --git a/packages/twenty-e2e-testing/tests/demo_basic.spec.ts b/packages/twenty-e2e-testing/tests/demo/demo_basic.spec.ts similarity index 89% rename from packages/twenty-e2e-testing/tests/demo_basic.spec.ts rename to packages/twenty-e2e-testing/tests/demo/demo_basic.spec.ts index a4268cc3d5e2..cb275fd2b799 100644 --- a/packages/twenty-e2e-testing/tests/demo_basic.spec.ts +++ b/packages/twenty-e2e-testing/tests/demo/demo_basic.spec.ts @@ -1,4 +1,4 @@ -import { test, expect } from '../lib/fixtures/screenshot'; +import { test, expect } from '../../lib/fixtures/screenshot'; test('Fail if demo account is working properly @demo-only', async ({ page, From 36169675309a834bac12164366f926d70d73011b Mon Sep 17 00:00:00 2001 From: BOHEUS Date: Mon, 18 Nov 2024 19:21:47 +0100 Subject: [PATCH 3/3] Added Github CI workflow, adapted test and config --- .github/workflows/ci-demo-check.yml | 59 +++++++++++++++++++ .../twenty-e2e-testing/playwright.config.ts | 2 +- .../tests/demo/demo_basic.spec.ts | 9 +-- 3 files changed, 65 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/ci-demo-check.yml diff --git a/.github/workflows/ci-demo-check.yml b/.github/workflows/ci-demo-check.yml new file mode 100644 index 000000000000..9f6af7d7a6b4 --- /dev/null +++ b/.github/workflows/ci-demo-check.yml @@ -0,0 +1,59 @@ +name: CI demo check +on: + schedule: + - cron: '30 7,19 * * *' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + test: + timeout-minutes: 15 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-node@v4 + with: + node-version: lts/* + + - name: Install dependencies + uses: ./.github/workflows/actions/yarn-install + + - name: Install Playwright Browsers + run: yarn playwright install --with-deps + + - name: Run Playwright tests + id: test + run: yarn playwright test --grep @demo-only + + - name: Upload report after tests + uses: actions/upload-artifact@v4 + with: + name: playwright-report + path: playwright-report/ + retention-days: 90 + + - name: Send Discord notification + env: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} + uses: Ilshidur/action-discord@0.3.2 + with: + args: 'Demo check ${{ steps.test.outcome }} - check ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}' + + - name: Send email if demo is not working + if: steps.test.outcome == 'failure' + uses: dawidd6/action-send-mail@v3.12.0 + with: + connection_url: ${{ secrets.MAIL_CONNECTION }} + server_address: smtp.gmail.com + server_port: 465 + secure: true + username: ${{ secrets.MAIL_USERNAME }} + subject: 'Demo is not working' + from: 'Github CI Demo check' + to: ${{ secrets.RECIPIENTS }} + body: 'Link' + priority: high \ No newline at end of file diff --git a/packages/twenty-e2e-testing/playwright.config.ts b/packages/twenty-e2e-testing/playwright.config.ts index 23d5006f34fc..c8adda3f4ba7 100644 --- a/packages/twenty-e2e-testing/playwright.config.ts +++ b/packages/twenty-e2e-testing/playwright.config.ts @@ -34,7 +34,7 @@ export default defineConfig({ expect: { timeout: 5000, }, - reporter: [['html', { open: 'never' }]], + reporter: process.env.CI ? 'github' : 'list', projects: [ { name: 'Login setup', diff --git a/packages/twenty-e2e-testing/tests/demo/demo_basic.spec.ts b/packages/twenty-e2e-testing/tests/demo/demo_basic.spec.ts index cb275fd2b799..61f17bcd400a 100644 --- a/packages/twenty-e2e-testing/tests/demo/demo_basic.spec.ts +++ b/packages/twenty-e2e-testing/tests/demo/demo_basic.spec.ts @@ -1,6 +1,6 @@ -import { test, expect } from '../../lib/fixtures/screenshot'; +import { test, expect } from '@playwright/test'; -test('Fail if demo account is working properly @demo-only', async ({ +test('Check if demo account is working properly @demo-only', async ({ page, }) => { await page.goto('https://demo.twenty.com/'); @@ -8,7 +8,8 @@ test('Fail if demo account is working properly @demo-only', async ({ await page.getByRole('button', { name: 'Continue', exact: true }).click(); await page.getByRole('button', { name: 'Sign in' }).click(); await expect(page.getByText('Welcome to Twenty')).not.toBeVisible(); - await expect(page.getByText('Server’s on a coffee break')).toBeVisible({ - timeout: 10000, + await page.waitForTimeout(5000); + await expect(page.getByText('Server’s on a coffee break')).not.toBeVisible({ + timeout: 5000, }); });