From accfdee5e631173d324b40e76d6a9e707cf359e0 Mon Sep 17 00:00:00 2001 From: Peter Salomonsen Date: Sat, 30 Dec 2023 16:17:02 +0100 Subject: [PATCH] fix(test): flaky solution/sponsorship tests (#617) * parse and stringify transaction text content to avoid flakyness caused by whitespace diff * use locators instead of selectAndAssert --- .../continuous-integration-workflow.yml | 2 +- playwright-tests/tests/funding.spec.js | 43 ++++++++++--------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/.github/workflows/continuous-integration-workflow.yml b/.github/workflows/continuous-integration-workflow.yml index 50be724e8..3e0d5a318 100644 --- a/.github/workflows/continuous-integration-workflow.yml +++ b/.github/workflows/continuous-integration-workflow.yml @@ -35,6 +35,6 @@ jobs: npx playwright install-deps npx playwright install - name: Run tests - run: | + run: | npx playwright test diff --git a/playwright-tests/tests/funding.spec.js b/playwright-tests/tests/funding.spec.js index a0279b86d..2a96fc905 100644 --- a/playwright-tests/tests/funding.spec.js +++ b/playwright-tests/tests/funding.spec.js @@ -14,11 +14,7 @@ test.describe("Wallet is connected", () => { await page.click('button:has-text("Solution")'); - await setInputAndAssert( - page, - 'input[data-testid="name-editor"]', - "The test title" - ); + await page.getByTestId("name-editor").fill("The test title"); const descriptionInput = page .frameLocator("iframe") @@ -35,11 +31,8 @@ test.describe("Wallet is connected", () => { await page.click('label:has-text("Yes") button'); await selectAndAssert(page, 'div:has-text("Currency") select', "USDT"); - await setInputAndAssert( - page, - 'input[data-testid="requested-amount-editor"]', - "300" - ); + await page.getByTestId("requested-amount-editor").fill("300"); + await page.click('button:has-text("Submit")'); await expect(page.locator("div.modal-body code")).toHaveText( JSON.stringify( @@ -71,24 +64,17 @@ test.describe("Wallet is connected by moderator", () => { await page.click('button:has-text("Reply")'); await page.click('li:has-text("Sponsorship")'); - const tagsInput = page.getByText("Labels:").locator(".rbt-input-multi"); - await tagsInput.click(); - await tagsInput.pressSequentially("funding", { delay: 100 }); - await tagsInput.press("Tab"); - await tagsInput.pressSequentially("funding-information-coll", { - delay: 100, - }); - await tagsInput.press("Tab"); - await page .getByText("Title:") .getByRole("textbox") .fill("Sponsorship: DevHub Platform Development Work"); + await page .getByText("Amount:", { exact: true }) .getByRole("textbox") .fill("7050"); - await (await page.getByLabel("Select currency")).selectOption("USDC"); + + await page.getByLabel("Select currency").selectOption("USDC"); const descriptionInput = page .frameLocator("iframe") @@ -98,8 +84,23 @@ test.describe("Wallet is connected by moderator", () => { "Congrats on getting your funding request approved" ); + const tagsInput = page.getByText("Labels:").locator(".rbt-input-multi"); + await tagsInput.click(); + await tagsInput.pressSequentially("funding", { delay: 100 }); + await tagsInput.press("Tab"); + await tagsInput.pressSequentially("funding-information-coll", { + delay: 100, + }); + await tagsInput.press("Tab"); + await page.click('button:has-text("Submit")'); - await expect(page.locator("div.modal-body code")).toHaveText( + + const transactionText = JSON.stringify( + JSON.parse(await page.locator("div.modal-body code").innerText()), + null, + 1 + ); + await expect(transactionText).toEqual( JSON.stringify( { parent_id: 2586,