From 08ff8baa6e37d48247f14540b6785da104710110 Mon Sep 17 00:00:00 2001 From: wmannard Date: Tue, 15 Oct 2024 17:26:33 -0400 Subject: [PATCH 1/4] add e2e certifier JSUI-3539 --- .deployment.config.json | 11 +++++++++++ .github/workflows/e2e-certifier.yml | 16 ++++++++++++++-- playwright/e2e/validateJsuiVersion.ts | 19 +++++++++++++++++++ playwright/package.json | 5 ++++- playwright/playwright.config.ts | 8 ++++++++ 5 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 playwright/e2e/validateJsuiVersion.ts diff --git a/.deployment.config.json b/.deployment.config.json index db00dace5..7dfcc7f9c 100644 --- a/.deployment.config.json +++ b/.deployment.config.json @@ -71,6 +71,17 @@ }, { "system_certifier": "snyk-code" + }, + { + "github": { + "name": "e2e-certifier", + "workflow_repository": "coveo/search-ui", + "workflow_file": "e2e-certifier.yml", + "extra_parameters": { + "JSUI_VERSION": "$[MAJOR_MINOR_VERSION].$[PATCH_VERSION]" + }, + "required": false + } } ] }, diff --git a/.github/workflows/e2e-certifier.yml b/.github/workflows/e2e-certifier.yml index 7220bf908..1802c2348 100644 --- a/.github/workflows/e2e-certifier.yml +++ b/.github/workflows/e2e-certifier.yml @@ -13,6 +13,8 @@ on: description: The package name job: description: The name of the job (as defined in the deployment config) + JSUI_VERSION: + description: The version of JSUI to test jobs: test-job: @@ -29,7 +31,17 @@ jobs: run: | npm install npx playwright install --with-deps - + + - name: Validate JSUI version + working-directory: ${{ github.workspace }}/playwright + env: + JSUI_VERSION: ${{ inputs.JSUI_VERSION }} + run: | + echo "Expecting deployed JSUI version to be ${{ inputs.JSUI_VERSION }}" + npm run validate-jsui-version + - name: Run tests working-directory: ${{ github.workspace }}/playwright - run: npx playwright test + env: + JSUI_VERSION: ${{ inputs.JSUI_VERSION }} + run: npm test diff --git a/playwright/e2e/validateJsuiVersion.ts b/playwright/e2e/validateJsuiVersion.ts new file mode 100644 index 000000000..69e67b974 --- /dev/null +++ b/playwright/e2e/validateJsuiVersion.ts @@ -0,0 +1,19 @@ +// This test is run in CI to validate that the JSUI version is the one expected. +import {test, expect} from '@playwright/test'; +import {pageURL} from '../utils/utils'; + +const expectedJsuiVersion = process.env.JSUI_VERSION; +console.log(`Expected JSUI version: ${expectedJsuiVersion}`); + +if (expectedJsuiVersion) { + test('validate JSUI version', async ({page}) => { + test.setTimeout(180_000); + await page.goto(pageURL()); + const coveoVersion = await page.evaluate(() => (window as any).Coveo.version); + // Example value: {lib: '2.10120.0', product: '2.10120.0', supportedApiVersion: 2} + expect(coveoVersion.lib).toBe(expectedJsuiVersion); + expect(coveoVersion.product).toBe(expectedJsuiVersion); + }); +} else { + console.log('No JSUI version to validate.'); +} diff --git a/playwright/package.json b/playwright/package.json index e12ced3d9..feaef6431 100644 --- a/playwright/package.json +++ b/playwright/package.json @@ -3,7 +3,10 @@ "version": "1.0.0", "description": "", "main": "index.js", - "scripts": {}, + "scripts": { + "test": "npx playwright test --project chromium --project firefox --project webkit", + "validate-jsui-version": "npx playwright test --project validate-jsui-version" + }, "keywords": [], "author": "", "license": "ISC", diff --git a/playwright/playwright.config.ts b/playwright/playwright.config.ts index 8fec8ad93..151d0086e 100644 --- a/playwright/playwright.config.ts +++ b/playwright/playwright.config.ts @@ -36,8 +36,14 @@ export default defineConfig({ /* Configure projects for major browsers */ projects: [ + { + name: 'validate-jsui-version', + testMatch: 'validateJsuiVersion.ts', + }, + { name: 'chromium', + testIgnore: 'validateJsuiVersion.ts', use: { ...devices['Desktop Chrome'], headless: true, @@ -46,6 +52,7 @@ export default defineConfig({ { name: 'firefox', + testIgnore: 'validateJsuiVersion.ts', use: { ...devices['Desktop Firefox'], headless: true, @@ -54,6 +61,7 @@ export default defineConfig({ { name: 'webkit', + testIgnore: 'validateJsuiVersion.ts', use: { ...devices['Desktop Safari'], headless: true, From 6b66c55662710e6748a514945b0db8dcf8b4ab20 Mon Sep 17 00:00:00 2001 From: wmannard Date: Tue, 15 Oct 2024 17:36:55 -0400 Subject: [PATCH 2/4] update workflow commands --- .github/workflows/e2e-certifier.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/e2e-certifier.yml b/.github/workflows/e2e-certifier.yml index 1802c2348..649f6a768 100644 --- a/.github/workflows/e2e-certifier.yml +++ b/.github/workflows/e2e-certifier.yml @@ -28,17 +28,13 @@ jobs: - name: Install test dependencies working-directory: ${{ github.workspace }}/playwright - run: | - npm install - npx playwright install --with-deps + run: npm install && npx playwright install --with-deps - name: Validate JSUI version working-directory: ${{ github.workspace }}/playwright env: JSUI_VERSION: ${{ inputs.JSUI_VERSION }} - run: | - echo "Expecting deployed JSUI version to be ${{ inputs.JSUI_VERSION }}" - npm run validate-jsui-version + run: npm run validate-jsui-version - name: Run tests working-directory: ${{ github.workspace }}/playwright From 284a02ab8d4d6b7ca3c8a5228eb89dd58503fe59 Mon Sep 17 00:00:00 2001 From: wmannard Date: Tue, 15 Oct 2024 17:47:32 -0400 Subject: [PATCH 3/4] rename main job --- .github/workflows/e2e-certifier.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/e2e-certifier.yml b/.github/workflows/e2e-certifier.yml index 649f6a768..9a6200880 100644 --- a/.github/workflows/e2e-certifier.yml +++ b/.github/workflows/e2e-certifier.yml @@ -17,7 +17,7 @@ on: description: The version of JSUI to test jobs: - test-job: + e2e-certifier: runs-on: ubuntu-24.04 steps: - name: Deploy JSUI beta version on Netlify @@ -38,6 +38,4 @@ jobs: - name: Run tests working-directory: ${{ github.workspace }}/playwright - env: - JSUI_VERSION: ${{ inputs.JSUI_VERSION }} run: npm test From 58da2cb4b35e39c9159fb101f4c013b9a760dada Mon Sep 17 00:00:00 2001 From: wmannard Date: Tue, 15 Oct 2024 17:58:17 -0400 Subject: [PATCH 4/4] add expect/toPass loop JSUI-3539 --- playwright/e2e/validateJsuiVersion.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/playwright/e2e/validateJsuiVersion.ts b/playwright/e2e/validateJsuiVersion.ts index 69e67b974..7728e38da 100644 --- a/playwright/e2e/validateJsuiVersion.ts +++ b/playwright/e2e/validateJsuiVersion.ts @@ -3,17 +3,22 @@ import {test, expect} from '@playwright/test'; import {pageURL} from '../utils/utils'; const expectedJsuiVersion = process.env.JSUI_VERSION; -console.log(`Expected JSUI version: ${expectedJsuiVersion}`); +const timeout = 180_000; if (expectedJsuiVersion) { + console.log(`Expected JSUI version: ${expectedJsuiVersion}`); + test('validate JSUI version', async ({page}) => { - test.setTimeout(180_000); - await page.goto(pageURL()); - const coveoVersion = await page.evaluate(() => (window as any).Coveo.version); - // Example value: {lib: '2.10120.0', product: '2.10120.0', supportedApiVersion: 2} - expect(coveoVersion.lib).toBe(expectedJsuiVersion); - expect(coveoVersion.product).toBe(expectedJsuiVersion); + test.setTimeout(timeout); + await expect(async () => { + await page.goto(pageURL()); + const coveoVersion = await page.evaluate(() => (window as any).Coveo.version); + // Example value: {lib: '2.10120.0', product: '2.10120.0', supportedApiVersion: 2} + expect(coveoVersion.lib).toBe(expectedJsuiVersion); + expect(coveoVersion.product).toBe(expectedJsuiVersion); + }).toPass({timeout}); }); + } else { console.log('No JSUI version to validate.'); }