Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hughcrt committed Oct 10, 2024
1 parent 97997c0 commit 5ace3d1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
41 changes: 21 additions & 20 deletions e2e/logs.spec.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
import { expect, test } from "@playwright/test"
import { expect, test } from "@playwright/test";

test.describe.configure({ mode: "serial" })
test.describe.configure({ mode: "serial" });

let publicLogUrl: string
let publicLogUrl: string;

test("make a log public", async ({ page, context }) => {
await context.grantPermissions(["clipboard-read", "clipboard-write"])
await context.grantPermissions(["clipboard-read", "clipboard-write"]);

await page.goto("/logs")
await page.goto("/logs");

await page.waitForLoadState("networkidle")
await page.waitForLoadState("networkidle");

await page.getByText("xyzTESTxyz").click()
await page.getByText("xyzTESTxyz").click();

await page.getByTestId("make-log-public-switch").click()
await page.getByTestId("selected-run-menu").click();
await page.getByTestId("toggle-run-visibility").click();

publicLogUrl = await page.evaluate(() => {
const urlParams = new URLSearchParams(window.location.search)
const selected = urlParams.get("selected")
return `${window.location.origin}/logs/${selected}`
})
})
const urlParams = new URLSearchParams(window.location.search);
const selected = urlParams.get("selected");
return `${window.location.origin}/logs/${selected}`;
});
});

test("unauthenticated user can access public log URL", async ({ browser }) => {
const context = await browser.newContext()
const page = await context.newPage()
const context = await browser.newContext();
const page = await context.newPage();

await page.goto(publicLogUrl)
await page.waitForLoadState("networkidle")
await page.goto(publicLogUrl);
await page.waitForLoadState("networkidle");

await expect(page.getByText("xyzTESTxyz")).toBeVisible()
await expect(page.getByText("xyzTESTxyz")).toBeVisible();

await context.close()
})
await context.close();
});
3 changes: 2 additions & 1 deletion packages/frontend/components/blocks/RunInputOutput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -274,14 +274,15 @@ export default function RunInputOutput({
)}

{hasAccess(user.role, "logs", "update") && (
<Menu>
<Menu data-testid="selected-run-menu">
<Menu.Target>
<ActionIcon variant="default">
<IconDots size={16} />
</ActionIcon>
</Menu.Target>
<Menu.Dropdown>
<Menu.Item
data-testid="toggle-run-visibility"
leftSection={
run.isPublic ? (
<IconEyeClosed size={16} />
Expand Down

0 comments on commit 5ace3d1

Please sign in to comment.