Skip to content

Commit

Permalink
Merge pull request #1529 from IntersectMBO/feat/user-snap
Browse files Browse the repository at this point in the history
Feat/user-snap
  • Loading branch information
kneerose authored Jul 9, 2024
2 parents 060cbbe + 676c9cf commit 25593f5
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 3 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions tests/govtool-frontend/playwright/lib/constants/docsUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ export const ABSTAIN_VOTE_DOC_URL = `${environments.docsUrl}/how-to-use-the-govt
export const SIGNAL_NO_CONFIDENCE_VOTE_DOC_URL = `${environments.docsUrl}/how-to-use-the-govtool/using-govtool/delegating/signal-no-confidence-on-every-vote`;
export const FAQS_DOC_URL = `${environments.docsUrl}/faqs`;
export const GUIDES_DOC_URL = `${environments.docsUrl}/about/what-is-sanchonet-govtool`;
export const PRIVACY_POLICY = `${environments.docsUrl}/legal/privacy-policy`;
export const TERMS_AND_CONDITIONS = `${environments.docsUrl}/legal/terms-and-conditions`;
export const HELP_DOC_URL = `${environments.docsUrl}/support/get-help-in-discord`;
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import {
DELEGATION_DOC_URL,
DIRECT_VOTER_DOC_URL,
REGISTER_DREP_DOC_URL,
GOVERNANCE_ACTION_DOC_URL,
PROPOSE_GOVERNANCE_ACTION_DOC_URL,
FAQS_DOC_URL,
GUIDES_DOC_URL,
HELP_DOC_URL,
PRIVACY_POLICY,
REGISTER_DREP_DOC_URL,
TERMS_AND_CONDITIONS,
} from "@constants/docsUrl";
import { faker } from "@faker-js/faker";
import { test } from "@fixtures/walletExtension";
import { setAllureEpic } from "@helpers/allure";
import { isMobile, openDrawer } from "@helpers/mobile";
Expand Down Expand Up @@ -77,3 +79,155 @@ test("6D. Should open Sanchonet docs in a new tab when clicking `Learn More` on
]);
await expect(directVoterLearnMorepage).toHaveURL(DIRECT_VOTER_DOC_URL);
});

test("6M. Should navigate between footer links", async ({ page, context }) => {
await page.goto("/");

const [privacyPolicy] = await Promise.all([
context.waitForEvent("page"),
page.getByTestId("privacy-policy-footer-link").click(),
]);
await expect(privacyPolicy).toHaveURL(PRIVACY_POLICY);

const [termsAndConditions] = await Promise.all([
context.waitForEvent("page"),
page.getByTestId("term-of-service-footer-link").click(),
]);
await expect(termsAndConditions).toHaveURL(TERMS_AND_CONDITIONS);

const [helpUrl] = await Promise.all([
context.waitForEvent("page"),
page.getByTestId("help-footer-button").click(),
]);
await expect(helpUrl).toHaveURL(HELP_DOC_URL);
});

test.describe("User Snap", () => {
test.beforeEach(async ({ page }) => {
await page.goto("/");
await page.waitForTimeout(2_000); // wait until page load properly

await page.getByTestId("feedback-footer-button").click();
});

test("6N. Should open feedback modal", async ({ page }) => {
await expect(page.getByLabel("Usersnap widget")).toBeVisible();
await expect(
page.getByRole("button", {
name: "Report an issue Something",
})
).toBeVisible();
await expect(
page.getByRole("button", {
name: "Idea or new feature Let us",
})
).toBeVisible();
});

test("6O. Should verify a bug report form", async ({ page }) => {
await page
.getByRole("button", {
name: "Report an issue Something",
})
.click();

await expect(
page.getByRole("heading", { name: "Report a bug" })
).toBeVisible();
await expect(page.getByPlaceholder("Your feedback")).toBeVisible();
await expect(page.getByText("Drag & drop or Browse")).toBeVisible();
await expect(page.getByPlaceholder("[email protected]")).toBeVisible();
await expect(page.getByLabel("Take screenshot")).toBeVisible();
await expect(page.getByLabel("Record")).toBeVisible();
await expect(page.getByRole("button", { name: "Submit" })).toBeVisible();
});

test("6P. Should verify feature form", async ({ page }) => {
await page
.getByRole("button", {
name: "Idea or new feature Let us",
})
.click();

await expect(
page.getByRole("heading", { name: "Idea or new feature" })
).toBeVisible();
await expect(
page.getByPlaceholder("Example: New navigation")
).toBeVisible();
await expect(page.getByLabel("Any additional details")).toBeVisible();
await expect(page.getByLabel("Any additional details")).toBeVisible();
await expect(page.getByText("Drag & drop or Browse")).toBeVisible();
await expect(page.getByPlaceholder("[email protected]")).toBeVisible();
await expect(page.getByLabel("Take screenshot")).toBeVisible();
await expect(page.getByLabel("Record")).toBeVisible();
await expect(page.getByRole("button", { name: "Submit" })).toBeVisible();
});

test.describe("Feedback Tests", () => {
const attachmentInputSelector = "input[type=file]";
const feedbackApiUrl =
"https://widget.usersnap.com/api/widget/xhrrpc?submit_feedback";
const mockAttachmentPath = "./lib/_mock/mockAttachment.png";

test("6Q. Should report an issue", async ({ page }) => {
// Intercept Usersnap submit API
await page.route(feedbackApiUrl, async (route) =>
route.fulfill({
status: 200,
})
);

await page
.getByRole("button", {
name: "Report an issue Something",
})
.click();

await page
.getByPlaceholder("Your feedback")
.fill(faker.lorem.paragraph(2));
await page.setInputFiles(attachmentInputSelector, [mockAttachmentPath]);
await page
.getByPlaceholder("[email protected]")
.fill(faker.internet.email());

await page.getByRole("button", { name: "Submit" }).click();

await expect(page.getByText("Feedback was not submitted,")).toBeVisible();
});

test("6R. Should submit an idea or new feature", async ({ page }) => {
// Intercept Usersnap submit API
await page.route(feedbackApiUrl, async (route) =>
route.fulfill({
status: 200,
})
);

await page
.getByRole("button", {
name: "Idea or new feature Let us",
})
.click();

await page
.getByPlaceholder("Example: New navigation")
.fill(faker.lorem.words(4));
await page
.getByLabel("Please summarize your idea or")
.fill(faker.lorem.paragraph(2));
await page
.getByLabel("Any additional details")
.fill(faker.lorem.paragraph(2));
await page.setInputFiles(attachmentInputSelector, [mockAttachmentPath]);
await page
.getByPlaceholder("[email protected]")
.fill(faker.internet.email());

await page.getByRole("button", { name: "Submit" }).click();

await expect(page.getByText("Feedback was not submitted,")).toBeVisible();
});
});
});

0 comments on commit 25593f5

Please sign in to comment.