Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates tests for modal #525

Merged
merged 2 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading