diff --git a/instances/devhub.near/widget/devhub/page/community/index.jsx b/instances/devhub.near/widget/devhub/page/community/index.jsx index b4d3a0764..1675316b6 100644 --- a/instances/devhub.near/widget/devhub/page/community/index.jsx +++ b/instances/devhub.near/widget/devhub/page/community/index.jsx @@ -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); diff --git a/playwright-tests/tests/community/sharelinks.spec.js b/playwright-tests/tests/community/sharelinks.spec.js new file mode 100644 index 000000000..38a158df9 --- /dev/null +++ b/playwright-tests/tests/community/sharelinks.spec.js @@ -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, + }); + }); +});