Skip to content

Commit

Permalink
Merge pull request #525 from PotLock/fix/modal-tests
Browse files Browse the repository at this point in the history
Updates tests for modal
  • Loading branch information
lachlanglen authored Apr 9, 2024
2 parents aacded7 + b7802c0 commit cf1b3e3
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 9 deletions.
1 change: 1 addition & 0 deletions apps/potlock/widget/ModalDonation/AmountInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ const AmountInput = (props) => {
value={value}
placeholder="0"
onChange={(e) => HandleAmoutChange(e.target.value)}
name="amount"
/>
<div className="usd-amount">
{" "}
Expand Down
19 changes: 16 additions & 3 deletions playwright-tests/tests/donate.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,32 @@ test("should open donate modal", async ({ page }) => {
test.setTimeout(120000); // 2 minutes... we want to improve performance
await page.goto(`${ROOT_SRC}?tab=project&projectId=${DEFAULT_PROJECT_ID}`);
await page.getByRole("button", { name: "Donate" }).click();
expect(await page.isVisible("text=Donate to project")).toBeTruthy();
expect(await page.isVisible("text=Donate to")).toBeTruthy();
});

test("project with no active pot should donate direct with correct amount", async ({ page }) => {
test.setTimeout(120000); // 2 minutes... we want to improve performance

// go to project page (PotLock project)
await page.goto(`${ROOT_SRC}?tab=project&projectId=${DEFAULT_PROJECT_ID}`);

// click donate button
await page.getByRole("button", { name: "Donate" }).click();
expect(await page.isVisible("text=Donate to project")).toBeTruthy();

// wait for modal to appear
expect(await page.isVisible("text=Donate to")).toBeTruthy();

// input amount
await page.fill("input[name=amount]", "100");
await page.getByRole("button", { name: "Donate" }).nth(1).click();

await page.getByRole("button", { name: "Proceed to donate" }).click();

// Confirm Donation
await page.getByRole("button", { name: "Confirm donation" }).click();

// Confirmation modal should be visible
const transactionObj = JSON.parse(await page.locator("div.modal-body code").innerText());
// check if transaction object is correct
expect(transactionObj).toMatchObject({
bypass_protocol_fee: false,
message: "",
Expand Down
18 changes: 13 additions & 5 deletions playwright-tests/tests/pot.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,21 @@ import { test, expect } from "@playwright/test";
import { ROOT_SRC, DEFAULT_POT_ID } from "../util/constants";

test.beforeEach(async ({ page }) => {
await page.goto(`${ROOT_SRC}?tab=pot&potId=${DEFAULT_POT_ID}`);
await page.goto(`${ROOT_SRC}?tab=pot&potId=${DEFAULT_POT_ID}&nav=projects`);
});

test("clicking pot card should go to pot page", async ({ page }) => {
await page.getByText("NEAR Retroactive Builders").click();
test("clicking project card should go to project page", async ({ page }) => {
test.setTimeout(120000); // 1 minute... we want to improve performance

const url = page.url();
const projectSearchBar = await page.getByPlaceholder("Search projects");

expect(url).toContain("?tab=pot&potId=build.v1.potfactory.potlock.near");
await projectSearchBar.fill("magic");

const projectCard = page.getByText("MagicBuild");

await Promise.all([projectCard.click(), page.waitForLoadState("load")]);

const projectUrl = page.url();

expect(projectUrl).toContain("?tab=project&projectId=magicbuild");
});
4 changes: 3 additions & 1 deletion playwright-tests/tests/pots.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ test.beforeEach(async ({ page }) => {
});

test("clicking pot card should go to pot page", async ({ page }) => {
await page.getByText("NEAR Retroactive Builders").click();
const potCard = await page.getByText("NEAR Retroactive Builders");

await Promise.all([potCard.click(), page.waitForLoadState("load")]);

const url = page.url();

Expand Down

0 comments on commit cf1b3e3

Please sign in to comment.