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..9a6200880 100644 --- a/.github/workflows/e2e-certifier.yml +++ b/.github/workflows/e2e-certifier.yml @@ -13,9 +13,11 @@ 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: + e2e-certifier: runs-on: ubuntu-24.04 steps: - name: Deploy JSUI beta version on Netlify @@ -26,10 +28,14 @@ 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: npm run validate-jsui-version + - name: Run tests working-directory: ${{ github.workspace }}/playwright - run: npx playwright test + run: npm test diff --git a/playwright/e2e/validateJsuiVersion.ts b/playwright/e2e/validateJsuiVersion.ts new file mode 100644 index 000000000..7728e38da --- /dev/null +++ b/playwright/e2e/validateJsuiVersion.ts @@ -0,0 +1,24 @@ +// 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; +const timeout = 180_000; + +if (expectedJsuiVersion) { + console.log(`Expected JSUI version: ${expectedJsuiVersion}`); + + test('validate JSUI version', async ({page}) => { + 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.'); +} 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,