Skip to content

Commit

Permalink
try to stabilize graphiql playwright test
Browse files Browse the repository at this point in the history
  • Loading branch information
nilshartmann committed Nov 23, 2023
1 parent 559e85a commit dd0ce59
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion e2e-tests/tests/graphiql.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import os from "os";
import { test, expect } from "@playwright/test";

const graphiqlUrl = process.env.PW_GRAPHIQL_URL || "http://localhost:9977";

const platform = os.platform();

// https://github.com/microsoft/playwright/issues/16459#issuecomment-1242423005
const controlKey = platform === "darwin" ? "Meta" : "Control";
console.log("platform", platform, "using controlkey", controlKey);

test(`customized graphiql at '${graphiqlUrl}' works`, async ({ page }) => {
await page.goto(graphiqlUrl);

Expand All @@ -12,9 +19,24 @@ test(`customized graphiql at '${graphiqlUrl}' works`, async ({ page }) => {
await page.getByRole("button", { name: /login/i }).click();
await page.getByRole("button", { name: /Prettify query/i }).click();

await expect(page.getByText(/query me/i)).toHaveCount(1);
await expect(page.getByText(/query twoowners/i)).toHaveCount(1);

// Clear editor
// await page.getByLabel(/query editor/i).click();
await page.getByLabel("Query Editor").getByRole("textbox").fill(`
query MyUsername {
me {
username
}
}
`);

await page.getByRole("button", { name: /headers/i }).click();
await page.getByRole("button", { name: /execute query/i }).click();

await expect(page.getByText(/"username"/i)).toHaveCount(1);
await expect(page.getByRole("menuitem", { name: "MyUsername" })).toBeVisible();
await page.getByRole("menuitem", { name: "MyUsername" }).click();

await expect(page.getByLabel("Result Window")).toHaveText(/"username": "susi"/i);
});

0 comments on commit dd0ce59

Please sign in to comment.