Skip to content

Commit

Permalink
fix: fix crash on /user/[username] route due to browser support iss…
Browse files Browse the repository at this point in the history
…ue (#1580)
  • Loading branch information
babblebey authored Aug 22, 2023
1 parent 02a17b4 commit 336a43e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ const ContributorProfileTab = ({

const router = useRouter();

pathnameRef.current = router.pathname.split("/").at(-1);
const pathnames = router.pathname.split("/");
pathnameRef.current = pathnames[pathnames.length - 1];

const getCurrentPathName = useMemo(() => {
return pathnameRef.current && pathnameRef.current !== "[username]"
Expand Down
28 changes: 28 additions & 0 deletions e2e-tests/OpenUserProfile.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { test, expect } from "@playwright/test";

test("Open a User (with GitHub Account Connected) Profile", async ({ page }) => {
await page.goto("/user/babblebey", { waitUntil: "domcontentloaded" });

await expect(page).toHaveURL(/\/user\/babblebey/, { timeout: 10000 });
await expect(page).toHaveTitle(/babblebey | OpenSauced/);
await expect(page.getByRole("heading", { name: "babblebey" })).toBeVisible();
await expect(page.getByRole("img", { name: "Avatar" })).toBeVisible();
await expect(page.getByRole("img", { name: "user profile cover image" })).toBeVisible();
await expect(page.getByRole("link", { name: "Get Card" })).toBeVisible();
await expect(page.getByRole("button", { name: "Share" })).toBeVisible();
await expect(page.getByRole("tab")).toBeVisible();
});

test("Open a User (without Github Account Connected) Profile", async ({ page }) => {
await page.goto("/user/githubuser", { waitUntil: "domcontentloaded" });

await expect(page).toHaveURL("/user/githubuser", { timeout: 10000 });
await expect(page).toHaveTitle(/githubuser | OpenSauced/);
await expect(page.getByRole("heading", { name: "githubuser" })).toBeVisible();
await expect(page.getByRole("img", { name: "Avatar" })).toBeHidden();
await expect(page.getByRole("img", { name: "user profile cover image" })).toBeHidden();
await expect(page.getByRole("link", { name: "Get Card" })).toBeHidden();
await expect(page.getByRole("button", { name: "Share" })).toBeHidden();
await expect(page.getByRole("tab")).toBeHidden();
await expect(page.getByRole("heading", { name: "Contribution Insights" })).toBeVisible();
});

0 comments on commit 336a43e

Please sign in to comment.