From b4a66a76906e4e61ba2a4e8e68140eab944a0462 Mon Sep 17 00:00:00 2001 From: Nora Date: Wed, 10 Jan 2024 12:59:22 +0000 Subject: [PATCH] Update readme --- .gitignore | 1 + extensions/ql-vscode/test/e2e/README.md | 14 +++++++--- .../ql-vscode/test/e2e/run-query.spec.ts | 26 ++++++++++++------- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 28013dc67..4784b9ab8 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ artifacts/ # E2E Reports **/playwright-report/** +**/test-results/** \ No newline at end of file diff --git a/extensions/ql-vscode/test/e2e/README.md b/extensions/ql-vscode/test/e2e/README.md index 2effa1159..c62724bb7 100644 --- a/extensions/ql-vscode/test/e2e/README.md +++ b/extensions/ql-vscode/test/e2e/README.md @@ -1,9 +1,17 @@ ## VS Code CodeQL E2E Tests -### Set up +When running the tests locally on a mac a different processor has to be emulated, which makes everythign VERY slow. Hence many timeouts in the test. + +### How to use locally + +Setup - run `docker-compose build` from the e2e test folder `vscode-codeql/extensions/ql-vscode/test/e2e` - run `docker-compose up` from the e2e test folder `vscode-codeql/extensions/ql-vscode/test/e2e` -- run `npx playwright test --ui` from the vscode-codeql folder `vscode-codeql/extensions/ql-vscode` -When you've run the test once! remove the volume data, e.g. by running `docker-compose down -v` \ No newline at end of file +Run tests + +- run `npx playwright test --ui` from the vscode-codeql folder `vscode-codeql/extensions/ql-vscode` to follow the test while it's running. This UI has a 'locator' tool with which elements on the test screen can be +- use `npx playwright test --debug` to follow the test in real time and interact with the interface, e.g. press enter or input into fields, stop and start + +If you get failures after the first test run you can try to remove the volume data, e.g. by running `docker-compose down -v`. Sometimes already existing queries from former runs change the input the extension needs. diff --git a/extensions/ql-vscode/test/e2e/run-query.spec.ts b/extensions/ql-vscode/test/e2e/run-query.spec.ts index a4c000632..e98fa742e 100644 --- a/extensions/ql-vscode/test/e2e/run-query.spec.ts +++ b/extensions/ql-vscode/test/e2e/run-query.spec.ts @@ -25,7 +25,7 @@ test("run query and open it from history", async ({ page }) => { ) .press("Enter"); - // Download database + // download database await page .getByRole("button", { name: "Download database" }) .click({ timeout: 60000 }); @@ -39,17 +39,26 @@ test("run query and open it from history", async ({ page }) => { await page.keyboard.type("Run Query on selected"); await page.keyboard.press("Enter"); - // select folder for first query run - // await page.getByRole("button", { name: "OK" }).click(); + // check if results page is visible + await expect(page.getByText("CodeQL Query Results")).toBeVisible({ + timeout: 600000, + }); - // check that query was run successfully and results page opens - await page.getByText("Hello world on d3/d3").click({ timeout: 800000 }); + // wait for query history item to be finished + await expect( + page + .locator("#list_id_6_0") + .getByLabel("Hello world on d3/d3 -") + .locator("div") + .first(), + ).toBeVisible({ timeout: 60000 }); // close results page and open query from history await page .getByLabel("CodeQL Query Results, Editor Group") .getByLabel("Close (Ctrl+F4)") .click(); + await expect( page .frameLocator(".webview") @@ -65,9 +74,6 @@ test("run query and open it from history", async ({ page }) => { .click(); await expect( - page - .frameLocator('iframe[name="\\34 884429a-d667-4121-932e-99abaa20b599"]') - .frameLocator('iframe[title="CodeQL Query Results"]') - .getByText("#selectalerts32 resultsShow"), - ).not.toBeVisible(); + page.getByLabel("CodeQL Query Results", { exact: true }).locator("div"), + ).toBeVisible({ timeout: 60000 }); });