Skip to content

Commit

Permalink
clean URL for community share button
Browse files Browse the repository at this point in the history
fixes #889
  • Loading branch information
petersalomonsen committed Jul 19, 2024
1 parent 36c6c75 commit 336b77a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
8 changes: 1 addition & 7 deletions instances/devhub.near/widget/devhub/page/community/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,7 @@ const tabs = [];

const onShareClick = () =>
clipboard
.writeText(
href({
gateway: "near.social",
widgetSrc: "${REPL_DEVHUB}/widget/app",
params: { page: "community", handle: community.handle },
})
)
.writeText(`https://${REPL_DEVHUB}.page/community/${community.handle}`)
.then(setLinkCopied(true));

let currentTab = tabs.find((it) => normalize(it.title) === tab);
Expand Down
32 changes: 32 additions & 0 deletions playwright-tests/tests/community/sharelinks.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { test, expect } from "@playwright/test";
import { pauseIfVideoRecording } from "../../testUtils.js";

test.describe("share links", () => {
test.use({
contextOptions: {
permissions: ["clipboard-read", "clipboard-write"],
},
});

test("community share button should create a clean URL", async ({ page }) => {
await page.goto(
"/devhub.near/widget/app?page=community&handle=webassemblymusic"
);
const shareButton = await page.locator("button", { hasText: "Share" });
await expect(shareButton).toBeVisible();
await shareButton.click();

const linkUrlFromClipboard = await page.evaluate(
"navigator.clipboard.readText()"
);
expect(linkUrlFromClipboard).toEqual(
"https://devhub.near.page/community/webassemblymusic"
);
await pauseIfVideoRecording(page);
await page.goto(linkUrlFromClipboard);

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

0 comments on commit 336b77a

Please sign in to comment.