From f33187efe133e0aafeba2f7640d5c63a0775faf0 Mon Sep 17 00:00:00 2001 From: Vsevolod Kukol Date: Sat, 12 Sep 2026 00:43:57 +0200 Subject: [PATCH] Type-check Playwright E2E tests in CI --- .github/workflows/ci.yml | 1 + package.json | 1 + test/README.md | 15 +++++++++++++++ test/fx.ts | 2 ++ test/sql/document.spec.ts | 6 +++--- tsconfig.test.json | 16 +++++++++------- 6 files changed, 31 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8dc333990..c427da827 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,6 +40,7 @@ jobs: - run: npm ci - run: npm run compile - run: npm run compile:strict + - run: npm run compile:e2e format: runs-on: ubuntu-latest name: "Check Format" diff --git a/package.json b/package.json index 610b13075..7751f135a 100644 --- a/package.json +++ b/package.json @@ -227,6 +227,7 @@ "build:ase": "gulp build:ase", "selfServeDocs": "typedoc", "compile": "tsc", + "compile:e2e": "tsc -p ./tsconfig.test.json", "compile:contracts": "tsc -p ./tsconfig.contracts.json", "compile:strict": "tsc -p ./tsconfig.strict.json", "format": "prettier --write \"{src,test}/**/*.{ts,tsx,html}\" \"*.{js,html}\"", diff --git a/test/README.md b/test/README.md index ba5acc22e..58b7070f0 100644 --- a/test/README.md +++ b/test/README.md @@ -4,6 +4,21 @@ This directory contains end-to-end tests for Cosmos Data Explorer. These tests **require** that you either deploy, or have access to, several Cosmos test Accounts. The tests run in [Playwright](https://playwright.dev/), using the official Playwright test framework. +## Type-checking + +After installing dependencies, run this command from the repository root: + +```shell +npm run compile:e2e +``` + +This checks all test TypeScript files and `playwright.config.ts` without emitting files, +starting a browser, or connecting to Azure. It also loads the application declarations +needed by code imported from the tests. CI runs this check in the Compile TypeScript job. + +`npm run compile` checks the application, not the E2E suite. Playwright's `--list` option +checks test discovery but does not replace TypeScript type-checking. + ## Required Resources To run all the tests, you need: diff --git a/test/fx.ts b/test/fx.ts index f3fc2e679..388645611 100644 --- a/test/fx.ts +++ b/test/fx.ts @@ -118,6 +118,7 @@ function tryGetStandardName(accountType: TestAccount) { : `${process.env.DE_TEST_ACCOUNT_PREFIX}-`; return `${actualPrefix}${accountType.toLocaleLowerCase()}`; } + return undefined; } // Maps a base API account type to its dedicated connection string (account key) account. @@ -474,6 +475,7 @@ export enum CommandBarButton { ExecuteQuery = "Execute Query", UploadItem = "Upload Item", NewDocument = "New Document", + NewItem = "New Item", View = "View", } diff --git a/test/sql/document.spec.ts b/test/sql/document.spec.ts index a093da376..8252f5099 100644 --- a/test/sql/document.spec.ts +++ b/test/sql/document.spec.ts @@ -64,7 +64,7 @@ for (const { name, databaseId, containerId, documents } of documentTestCases) { let newDocumentId; await page.waitForTimeout(5000); await retry(async () => { - const newDocumentButton = await explorer.waitForCommandBarButton("New Item", 5000); + const newDocumentButton = await explorer.waitForCommandBarButton(CommandBarButton.NewItem, 5000); await expect(newDocumentButton).toBeVisible(); await expect(newDocumentButton).toBeEnabled(); await newDocumentButton.click(); @@ -79,7 +79,7 @@ for (const { name, databaseId, containerId, documents } of documentTestCases) { }; await documentsTab.resultsEditor.setText(JSON.stringify(newDocument)); - const saveButton = await explorer.waitForCommandBarButton("Save", 5000); + const saveButton = await explorer.waitForCommandBarButton(CommandBarButton.Save, 5000); await saveButton.click({ timeout: 5000 }); await expect(saveButton).toBeHidden({ timeout: 5000 }); }, 3); @@ -93,7 +93,7 @@ for (const { name, databaseId, containerId, documents } of documentTestCases) { await newSpan.click(); await expect(documentsTab.resultsEditor.locator).toBeAttached({ timeout: 60 * 1000 }); - const deleteButton = await explorer.waitForCommandBarButton("Delete", 5000); + const deleteButton = await explorer.waitForCommandBarButton(CommandBarButton.Delete, 5000); await deleteButton.click(); const deleteDialogButton = await explorer.waitForDialogButton("Delete", 5000); diff --git a/tsconfig.test.json b/tsconfig.test.json index 28c7ed92c..b94962f68 100644 --- a/tsconfig.test.json +++ b/tsconfig.test.json @@ -1,7 +1,9 @@ -{ - "extends": "./tsconfig.json", - "include": ["./test/**/*"], - "compilerOptions": { - "module": "commonjs" - } -} +{ + "extends": "./tsconfig.json", + "include": ["./test/**/*", "./playwright.config.ts", "./src/**/*.d.ts"], + "compilerOptions": { + "module": "commonjs", + "lib": ["es2022", "dom"], + "types": ["jest", "node"] + } +}