Skip to content

Commit

Permalink
test: added some logged out E2E tests for the repo page
Browse files Browse the repository at this point in the history
  • Loading branch information
nickytonline committed Aug 13, 2024
1 parent 8ee4cd5 commit 382cc2d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
7 changes: 6 additions & 1 deletion components/Repositories/AddToWorkspaceModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ export default function AddToWorkspaceModal({ repository, isOpen, onCloseModal,

return (
<Dialog open={isOpen}>
<DialogContent autoStyle={false} onEscapeKeyDown={onCloseModal} onInteractOutside={onCloseModal}>
<DialogContent
aria-label="Add to workspace"
autoStyle={false}
onEscapeKeyDown={onCloseModal}
onInteractOutside={onCloseModal}
>
<Card heading={<h1 className="text-xl font-semibold">Add to workspace</h1>}>
<div className="flex flex-col gap-4 w-[32rem] h-full px-8 py-4">
{!user ? (
Expand Down
31 changes: 28 additions & 3 deletions e2e/repo-page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,38 @@ test("Loads a repository page", async ({ page }) => {
await expect(rangePopup).toBeVisible();
await expect(rangePopup).toHaveAttribute("aria-haspopup", "menu");
await expect(rangePopup).toHaveAttribute("data-state", "closed");
});

test("repository page has an OG image", async ({ page }) => {
await page.goto("/s/open-sauced/app");
page.getByRole("button", { name: "Add to Workspace", exact: true }).click();
await expect(page.getByRole("button", { name: "Workspace from SBOM", exact: true })).toBeVisible();
await expect(page.getByRole("button", { name: "Share", exact: true })).toBeVisible();

// check for OG image
const expectedUrl = `${config.use?.baseURL}/og-images/repository/open-sauced/app/30?description=%F0%9F%8D%95+Insights+into+your+entire+open+source+ecosystem.`;

await expect(page.locator('meta[property="og:image"]')).toHaveAttribute("content", expectedUrl);
await expect(page.locator('meta[name="twitter:image"]')).toHaveAttribute("content", expectedUrl);
await expect(page.locator('meta[name="twitter:card"]')).toHaveAttribute("content", "summary_large_image");
});

test("Adds a repository to a workspace (large screen)", async ({ page }) => {
await page.goto("/s/open-sauced/app");

await page.getByRole("button", { name: "Add to Workspace", exact: true }).click();
const dialog = await page.getByRole("dialog", { name: "Add to workspace", exact: true });
await expect(dialog).toBeVisible();

await dialog.getByRole("button", { name: "Connect with GitHub", exact: true }).click();
await expect(page.url()).toContain("https://github.com/login");
});

test("Adds a repository SBOM to a workspace (large screen)", async ({ page }) => {
await page.goto("/s/open-sauced/app");

await page.getByRole("button", { name: "Workspace from SBOM", exact: true }).click();
const dialog = await page.getByRole("dialog", { name: "Add to workspace", exact: true });
await expect(dialog).toBeVisible();

await dialog.getByRole("button", { name: "Connect with GitHub", exact: true }).click();
await expect(page.url()).toContain("https://github.com/login");
});
///

0 comments on commit 382cc2d

Please sign in to comment.