Skip to content

Commit decbdee

Browse files
authored
Merge pull request #3092 from IntersectMBO/refactor/separate-user-snapshot-test
Separate user snap test from 6. miscellaneous to 10. User Snap and align with updates
2 parents ae158bc + 0357730 commit decbdee

File tree

2 files changed

+192
-162
lines changed

2 files changed

+192
-162
lines changed
Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
import { faker } from "@faker-js/faker";
2+
import { test } from "@fixtures/walletExtension";
3+
import { setAllureEpic } from "@helpers/allure";
4+
import { isMobile } from "@helpers/mobile";
5+
import { expect, Page } from "@playwright/test";
6+
import { randomUUID } from "crypto";
7+
8+
test.beforeEach(async ({ page }) => {
9+
await setAllureEpic("10. User Snap");
10+
await page.goto("/");
11+
await page.waitForTimeout(2_000); // wait until page load properly
12+
13+
await page.getByTestId("feedback-footer-button").click();
14+
});
15+
16+
test("10A. Should open feedback modal", async ({ page }) => {
17+
await expect(page.getByLabel("Usersnap widget")).toBeVisible();
18+
await expect(
19+
page.getByRole("button", {
20+
name: "Report an issue Something",
21+
})
22+
).toBeVisible();
23+
await expect(
24+
page.getByRole("button", { name: "Send an idea Let us know what" })
25+
).toBeVisible();
26+
});
27+
28+
test("10B. Should verify a bug report form", async ({ page }) => {
29+
await page
30+
.getByRole("button", {
31+
name: "Report an issue Something",
32+
})
33+
.click();
34+
await expect(
35+
page.getByRole("button", { name: "Close annotation" })
36+
).toBeVisible();
37+
38+
if (isMobile(page)) {
39+
await expect(
40+
page.getByRole("button", { name: "Add screenshot" })
41+
).toBeVisible();
42+
await page.getByRole("button", { name: "Close annotation" }).click();
43+
await expect(page.getByLabel("Take screenshot")).toBeVisible();
44+
}
45+
46+
await expect(
47+
page.getByRole("heading", { name: "Report a bug" })
48+
).toBeVisible();
49+
await expect(page.getByPlaceholder("Add description")).toBeVisible();
50+
await expect(page.getByLabel("Record")).toBeVisible();
51+
await expect(page.getByRole("button", { name: "Submit" })).toBeVisible();
52+
53+
// check record action
54+
await page.getByLabel("Record").click();
55+
await expect(
56+
page.getByRole("button", { name: "Cancel recording" })
57+
).toBeVisible();
58+
});
59+
60+
test("10C. Should verify feature form", async ({ page }) => {
61+
await page
62+
.getByRole("button", { name: "Send an idea Let us know what" })
63+
.click();
64+
65+
await expect(
66+
page.getByRole("heading", { name: "Feature Request" })
67+
).toBeVisible();
68+
await expect(page.getByPlaceholder("Feature description")).toBeVisible();
69+
await expect(page.getByPlaceholder("Please add some context")).toBeVisible();
70+
await expect(page.getByLabel("Take screenshot")).toBeVisible();
71+
await expect(page.getByLabel("Record")).toBeVisible();
72+
await expect(
73+
page.getByRole("button", { name: "Request Feature" })
74+
).toBeVisible();
75+
76+
// check screenshot action
77+
await page.getByLabel("Take screenshot").click();
78+
await expect(
79+
page.getByRole("button", { name: "Close annotation" })
80+
).toBeVisible();
81+
await expect(
82+
page.getByRole("button", { name: "Add screenshot" })
83+
).toBeVisible();
84+
await page.getByRole("button", { name: "Close annotation" }).click();
85+
86+
// check record action
87+
await page.getByLabel("Record").click();
88+
await expect(
89+
page.getByRole("button", { name: "Cancel recording" })
90+
).toBeVisible();
91+
});
92+
93+
test.describe("Submit Usersnap", () => {
94+
const feedbackApiUrl =
95+
"https://widget.usersnap.com/api/widget/xhrrpc?submit_feedback";
96+
const bucketUrl = "https://s3.eu-central-1.amazonaws.com/upload.usersnap.com";
97+
98+
const interceptBucket = async (page: Page) => {
99+
await page.route(bucketUrl, async (route) =>
100+
route.fulfill({
101+
status: 204,
102+
})
103+
);
104+
};
105+
106+
const interceptUsersnap = async (page: Page) => {
107+
await page.route(feedbackApiUrl, async (route) =>
108+
route.fulfill({
109+
status: 200,
110+
body: JSON.stringify({
111+
status: true,
112+
data: {
113+
feedback: {
114+
feedback_id: randomUUID(),
115+
assignee_id: randomUUID(),
116+
labels: [],
117+
},
118+
screen_recording_url: null,
119+
attachment_urls: [
120+
{
121+
url: bucketUrl,
122+
fields: {
123+
"Content-Type": "image/png",
124+
key: randomUUID(),
125+
},
126+
},
127+
],
128+
},
129+
}),
130+
})
131+
);
132+
};
133+
134+
test("10D. Should report an issue", async ({ page }) => {
135+
// Intercept Usersnap submit API
136+
await interceptUsersnap(page);
137+
await interceptBucket(page);
138+
await page
139+
.getByRole("button", {
140+
name: "Report an issue Something",
141+
})
142+
.click();
143+
144+
if (isMobile(page)) {
145+
await page.getByRole("button", { name: "Add screenshot" }).click();
146+
} else {
147+
// Draw rectangle
148+
await page
149+
.locator('[class^="jt-container-"] > svg')
150+
.first()
151+
.evaluate((element) => {
152+
const rectangleSvg = `<g class="root-0-0-11 highlight" data-drawing="true" stroke-width="2" stroke="#fed200" x="147" y="16" width="1091" height="653"><rect width="1091" height="653" fill-opacity="0" x="147" y="16"></rect></g>`;
153+
element.innerHTML = rectangleSvg;
154+
});
155+
}
156+
157+
await page
158+
.getByPlaceholder("Add description")
159+
.fill(faker.lorem.paragraph(2));
160+
161+
await page.getByRole("button", { name: "Submit" }).click();
162+
163+
await expect(page.getByText("Thank you!")).toBeVisible();
164+
});
165+
166+
test("10E. Should submit an idea or new feature", async ({ page }) => {
167+
// Intercept Usersnap submit API
168+
await interceptUsersnap(page);
169+
await interceptBucket(page);
170+
171+
await page
172+
.getByRole("button", { name: "Send an idea Let us know what" })
173+
.click();
174+
175+
await page
176+
.getByPlaceholder("Feature description")
177+
.fill(faker.lorem.words(4));
178+
await page
179+
.getByPlaceholder("Please add some context")
180+
.fill(faker.lorem.paragraph(2));
181+
182+
// add screenshot
183+
await page.getByLabel("Take screenshot").click();
184+
await page.getByRole("button", { name: "Add screenshot" }).click();
185+
186+
await page.getByRole("button", { name: "Request Feature" }).click();
187+
188+
await expect(page.getByText("Thank you!")).toBeVisible();
189+
});
190+
});

tests/govtool-frontend/playwright/tests/6-miscellaneous/miscellaneous.spec.ts

Lines changed: 2 additions & 162 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@ import {
99
REGISTER_DREP_DOC_URL,
1010
TERMS_AND_CONDITIONS,
1111
} from "@constants/docsUrl";
12-
import { faker } from "@faker-js/faker";
1312
import { test } from "@fixtures/walletExtension";
1413
import { setAllureEpic } from "@helpers/allure";
1514
import { isMobile, openDrawer } from "@helpers/mobile";
1615
import { expect, Page } from "@playwright/test";
17-
import { randomUUID } from "crypto";
1816
import environments from "lib/constants/environments";
1917

2018
test.beforeEach(async () => {
@@ -104,165 +102,7 @@ test("6M. Should navigate between footer links", async ({ page, context }) => {
104102
await expect(helpUrl).toHaveURL(HELP_DOC_URL);
105103
});
106104

107-
test.describe("User Snap", () => {
108-
test.beforeEach(async ({ page }) => {
109-
await page.goto("/");
110-
await page.waitForTimeout(2_000); // wait until page load properly
111-
112-
await page.getByTestId("feedback-footer-button").click();
113-
});
114-
115-
test("6N. Should open feedback modal", async ({ page }) => {
116-
await expect(page.getByLabel("Usersnap widget")).toBeVisible();
117-
await expect(
118-
page.getByRole("button", {
119-
name: "Report an issue Something",
120-
})
121-
).toBeVisible();
122-
await expect(
123-
page.getByRole("button", {
124-
name: "Idea or new feature Let us",
125-
})
126-
).toBeVisible();
127-
});
128-
129-
test("6O. Should verify a bug report form", async ({ page }) => {
130-
await page
131-
.getByRole("button", {
132-
name: "Report an issue Something",
133-
})
134-
.click();
135-
136-
await expect(
137-
page.getByRole("heading", { name: "Report a bug" })
138-
).toBeVisible();
139-
await expect(page.getByPlaceholder("Your feedback")).toBeVisible();
140-
await expect(page.getByText("Drag & drop or Browse")).toBeVisible();
141-
await expect(page.getByLabel("Take screenshot")).toBeVisible();
142-
await expect(page.getByLabel("Record")).toBeVisible();
143-
await expect(page.getByRole("button", { name: "Submit" })).toBeVisible();
144-
});
145-
146-
test("6P. Should verify feature form", async ({ page }) => {
147-
await page
148-
.getByRole("button", {
149-
name: "Idea or new feature Let us",
150-
})
151-
.click();
152-
153-
await expect(
154-
page.getByRole("heading", { name: "Idea or new feature" })
155-
).toBeVisible();
156-
await expect(
157-
page.getByPlaceholder("Example: New navigation")
158-
).toBeVisible();
159-
await expect(
160-
page.getByPlaceholder("Example: New navigation")
161-
).toBeVisible();
162-
await expect(page.getByLabel("Any additional details")).toBeVisible();
163-
await expect(page.getByText("Drag & drop or Browse")).toBeVisible();
164-
await expect(
165-
page.getByLabel("Please summarize your idea or")
166-
).toBeVisible();
167-
await expect(page.getByLabel("Take screenshot")).toBeVisible();
168-
await expect(page.getByLabel("Record")).toBeVisible();
169-
await expect(page.getByRole("button", { name: "Submit" })).toBeVisible();
170-
});
171-
172-
test.describe("Feedback Tests", () => {
173-
const attachmentInputSelector = "input[type=file]";
174-
const feedbackApiUrl =
175-
"https://widget.usersnap.com/api/widget/xhrrpc?submit_feedback";
176-
const bucketUrl =
177-
"https://s3.eu-central-1.amazonaws.com/upload.usersnap.com";
178-
const mockAttachmentPath = "./lib/_mock/mockAttachment.png";
179-
180-
const interceptBucket = async (page: Page) => {
181-
await page.route(bucketUrl, async (route) =>
182-
route.fulfill({
183-
status: 204,
184-
})
185-
);
186-
};
187-
188-
const interceptUsersnap = async (page: Page) => {
189-
await page.route(feedbackApiUrl, async (route) =>
190-
route.fulfill({
191-
status: 200,
192-
body: JSON.stringify({
193-
status: true,
194-
data: {
195-
feedback: {
196-
feedback_id: randomUUID(),
197-
assignee_id: randomUUID(),
198-
labels: [],
199-
},
200-
screen_recording_url: null,
201-
attachment_urls: [
202-
{
203-
url: bucketUrl,
204-
fields: {
205-
"Content-Type": "image/png",
206-
key: randomUUID(),
207-
},
208-
},
209-
],
210-
},
211-
}),
212-
})
213-
);
214-
};
215-
216-
test("6Q. Should report an issue", async ({ page }) => {
217-
// Intercept Usersnap submit API
218-
await interceptUsersnap(page);
219-
await interceptBucket(page);
220-
await page
221-
.getByRole("button", {
222-
name: "Report an issue Something",
223-
})
224-
.click();
225-
226-
await page
227-
.getByPlaceholder("Your feedback")
228-
.fill(faker.lorem.paragraph(2));
229-
await page.setInputFiles(attachmentInputSelector, [mockAttachmentPath]);
230-
231-
await page.getByRole("button", { name: "Submit" }).click();
232-
233-
await expect(page.getByText("Thank you!")).toBeVisible();
234-
});
235-
236-
test("6R. Should submit an idea or new feature", async ({ page }) => {
237-
// Intercept Usersnap submit API
238-
await interceptUsersnap(page);
239-
await interceptBucket(page);
240-
241-
await page
242-
.getByRole("button", {
243-
name: "Idea or new feature Let us",
244-
})
245-
.click();
246-
247-
await page
248-
.getByPlaceholder("Example: New navigation")
249-
.fill(faker.lorem.words(4));
250-
await page
251-
.getByLabel("Please summarize your idea or")
252-
.fill(faker.lorem.paragraph(2));
253-
await page
254-
.getByLabel("Any additional details")
255-
.fill(faker.lorem.paragraph(2));
256-
await page.setInputFiles(attachmentInputSelector, [mockAttachmentPath]);
257-
258-
await page.getByRole("button", { name: "Submit" }).click();
259-
260-
await expect(page.getByText("Thank you!")).toBeVisible();
261-
});
262-
});
263-
});
264-
265-
test("6S. Should Warn users that they are in bootstrapping phase via banner", async ({
105+
test("6N. Should Warn users that they are in bootstrapping phase via banner", async ({
266106
page,
267107
context,
268108
}) => {
@@ -296,7 +136,7 @@ test("6S. Should Warn users that they are in bootstrapping phase via banner", as
296136
await expect(bootstrap).toHaveURL(BOOTSTRAP_DOC_URL);
297137
});
298138

299-
test("6T. Should display proper network name", async ({ page }) => {
139+
test("6O. Should display proper network name", async ({ page }) => {
300140
await page.route("**/network/metrics", async (route) => {
301141
// Fetch the original response from the server
302142
const response = await route.fetch();

0 commit comments

Comments
 (0)