Skip to content

Commit

Permalink
fix(test): flaky solution/sponsorship tests (#617)
Browse files Browse the repository at this point in the history
* parse and stringify transaction text content to avoid flakyness caused by whitespace diff
* use locators instead of selectAndAssert
  • Loading branch information
petersalomonsen authored Dec 30, 2023
1 parent fe4cccd commit accfdee
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/continuous-integration-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ jobs:
npx playwright install-deps
npx playwright install
- name: Run tests
run: |
run: |
npx playwright test
43 changes: 22 additions & 21 deletions playwright-tests/tests/funding.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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(
Expand Down Expand Up @@ -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")
Expand All @@ -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,
Expand Down

0 comments on commit accfdee

Please sign in to comment.