-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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("/"); | ||
}); |