Skip to content

Commit

Permalink
Add SPARQLet CRUD test
Browse files Browse the repository at this point in the history
  • Loading branch information
darashi committed Mar 8, 2024
1 parent cb4379a commit b3fd41c
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions e2e/edit.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { test, expect } from "@playwright/test";

test("create, edit and delete", async ({ page, baseURL }) => {
await page.goto("/");

const sparqletId = `test-${new Date().getTime()}`;

await expect(page.getByRole("navigation")).toContainText("SPARQList");
await page.getByRole("Link", { name: "New SPARQLet" }).click();

await page.fill("input[id=password]", "admin-password");
await page.getByRole("button", { name: "Login" }).click();

// create
await page.fill("input[class=form-control]", sparqletId);

await page.locator(".CodeMirror textarea").fill("# Foo SPARQLet");
await page.click("text=Save");

// view
await expect(page).toHaveURL(`/${sparqletId}`);
await expect(page.getByRole("heading").first()).toHaveText("Foo SPARQLet");

await expect(
page
.getByRole("paragraph")
.getByRole("link", { name: `${baseURL}/api/${sparqletId}` }),
).toBeVisible();

// execute
await page.click("text=Execute");
await expect(
page.getByRole("heading", { name: "Response 200 OK" }),
).toBeVisible();

// switch to markdown view
await page.getByRole("link", { name: "Markdown" }).click();
await expect(page.locator("pre code").last()).toHaveText("# Foo SPARQLet");

// edit
await page.click("text=Edit");
await page.locator(".CodeMirror textarea").focus();
await page.keyboard.press("Control+A");
await page.locator(".CodeMirror-code").pressSequentially("# Bar SPARQLet");
await page.click("text=Save");

await expect(page).toHaveURL(`/${sparqletId}`);
await expect(page.getByRole("heading").first()).toHaveText("Bar SPARQLet");

// delete
page.on("dialog", (dialog) => dialog.accept());
await page.click("text=Delete");
await expect(page).toHaveURL("/");
});

0 comments on commit b3fd41c

Please sign in to comment.