Skip to content

Commit

Permalink
show URL during test
Browse files Browse the repository at this point in the history
  • Loading branch information
petersalomonsen committed Jul 19, 2024
1 parent 336b77a commit 6f90b63
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
16 changes: 16 additions & 0 deletions playwright-tests/testUtils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
import { expect } from "@playwright/test";

export async function showPageURLInTest(page) {
await page.evaluate(() => {
const urlDiv = document.createElement("div");
urlDiv.style.position = "fixed";
urlDiv.style.top = "0";
urlDiv.style.left = "0";
urlDiv.style.backgroundColor = "rgba(255, 200, 200, 0.8)";
urlDiv.style.padding = "5px";
urlDiv.style.zIndex = "10000";
urlDiv.style.fontSize = "12px";
urlDiv.style.fontFamily = "Arial, sans-serif";
urlDiv.innerText = window.location.href;
document.body.appendChild(urlDiv);
});
}

export const pauseIfVideoRecording = async (page) => {
let isVideoRecorded = (await page.video()) ? true : false;
if (isVideoRecorded) {
Expand Down
9 changes: 8 additions & 1 deletion playwright-tests/tests/community/sharelinks.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test, expect } from "@playwright/test";
import { pauseIfVideoRecording } from "../../testUtils.js";
import { pauseIfVideoRecording, showPageURLInTest } from "../../testUtils.js";

test.describe("share links", () => {
test.use({
Expand All @@ -12,8 +12,13 @@ test.describe("share links", () => {
await page.goto(
"/devhub.near/widget/app?page=community&handle=webassemblymusic"
);
await showPageURLInTest(page);

const shareButton = await page.locator("button", { hasText: "Share" });
await expect(shareButton).toBeVisible();

await shareButton.hover();
await pauseIfVideoRecording(page);
await shareButton.click();

const linkUrlFromClipboard = await page.evaluate(
Expand All @@ -25,8 +30,10 @@ test.describe("share links", () => {
await pauseIfVideoRecording(page);
await page.goto(linkUrlFromClipboard);

await showPageURLInTest(page);
await expect(await page.getByText("WebAssembly Music")).toBeVisible({
timeout: 10000,
});
await pauseIfVideoRecording(page);
});
});

0 comments on commit 6f90b63

Please sign in to comment.