Skip to content

Commit

Permalink
Added UI tests for global rules and settings pages (#3941)
Browse files Browse the repository at this point in the history
  • Loading branch information
EricWittmann authored Nov 7, 2023
1 parent b4bee53 commit 39437e5
Show file tree
Hide file tree
Showing 18 changed files with 274 additions and 672 deletions.
13 changes: 7 additions & 6 deletions ui/tests/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { defineConfig, devices } from "@playwright/test";
export default defineConfig({
testDir: "./specs",
/* Run tests in files in parallel */
fullyParallel: true,
fullyParallel: false,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
Expand All @@ -21,13 +21,14 @@ export default defineConfig({
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: [ ["html", { open: "never" }] ],
timeout: 15000,
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: "on-first-retry",
trace: process.env.CI ? "on-first-retry" : "on",
},

/* Configure projects for major browsers */
Expand All @@ -37,10 +38,10 @@ export default defineConfig({
use: { ...devices["Desktop Chrome"] },
},

{
name: "firefox",
use: { ...devices["Desktop Firefox"] },
},
// {
// name: "firefox",
// use: { ...devices["Desktop Firefox"] },
// },
],

/* Run your local dev server before starting the tests */
Expand Down
59 changes: 58 additions & 1 deletion ui/tests/specs/globalRules.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,73 @@ import { test, expect } from "@playwright/test";

const REGISTRY_UI_URL: string = process.env["REGISTRY_UI_URL"] || "http://localhost:8888";

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

test.beforeEach(async ({ page }) => {
await page.goto(REGISTRY_UI_URL);
await expect(page).toHaveTitle(/Apicurio Registry/);
await page.getByTestId("rules-tab").click();
});


test("Global Rules - List Rules", async ({ page }) => {
await expect(page.locator("#validity-rule-name")).toContainText("Validity rule");
await expect(page.locator("#compatibility-rule-name")).toContainText("Compatibility rule");
await expect(page.locator("#integrity-rule-name")).toContainText("Integrity rule");
});

test("Global Rules - Enable Validity Rule", async ({ page }) => {
await expect(page.locator("#validity-rule-name")).toContainText("Validity rule");

// Enable the Rule
await page.getByTestId("rules-validity-enable").click();
expect(page.getByTestId("rules-validity-config-toggle")).toBeDefined();

// Click the Rule Configuration toggle
await page.getByTestId("rules-validity-config-toggle").click();
expect(page.getByTestId("rules-validity-config-syntaxOnly")).toBeDefined();

// Select "syntax only" config option
await page.getByTestId("validity-config-syntax").click();
expect(page.getByTestId("rules-validity-disable")).toBeDefined();

// Disable the rule (back to original state)
await page.getByTestId("rules-validity-disable").click();
});

test("Global Rules - Enable Compatibility Rule", async ({ page }) => {
await expect(page.locator("#compatibility-rule-name")).toContainText("Compatibility rule");

// Enable the Rule
await page.getByTestId("rules-compatibility-enable").click();
expect(page.getByTestId("rules-compatibility-config-toggle")).toBeDefined();

// Click the Rule Configuration toggle
await page.getByTestId("rules-compatibility-config-toggle").click();
expect(page.getByTestId("rules-compatibility-config-forward")).toBeDefined();

// Select "forward" config option
await page.getByTestId("compatibility-config-forward").click();
expect(page.getByTestId("rules-compatibility-disable")).toBeDefined();

// Disable the rule (back to original state)
await page.getByTestId("rules-compatibility-disable").click();
});

test("Global Rules - Enable Integrity Rule", async ({ page }) => {
await expect(page.locator("#integrity-rule-name")).toContainText("Integrity rule");

// Enable the Rule
await page.getByTestId("rules-integrity-enable").click();
expect(page.getByTestId("rules-integrity-config-toggle")).toBeDefined();

// Click the Rule Configuration toggle
await page.getByTestId("rules-integrity-config-toggle").click();
expect(page.getByTestId("integrity-config-full")).toBeDefined();

// Select "none" config option
await page.getByTestId("integrity-config-none").locator("input").click();
expect(page.getByTestId("rules-integrity-disable")).toBeDefined();

// Disable the rule (back to original state)
await page.getByTestId("rules-integrity-disable").click();
});
22 changes: 22 additions & 0 deletions ui/tests/specs/settings.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { test, expect } from "@playwright/test";

const REGISTRY_UI_URL: string = process.env["REGISTRY_UI_URL"] || "http://localhost:8888";


test.beforeEach(async ({ page }) => {
await page.goto(REGISTRY_UI_URL);
await expect(page).toHaveTitle(/Apicurio Registry/);
await page.getByTestId("settings-tab").click();
});

test("Settings - Filter", async ({ page }) => {
await expect(page.getByTestId("settings-search-widget").locator("input")).toBeEmpty();
expect(page.getByTestId("config-groups")).toBeDefined();
await expect(page.getByTestId("config-groups").locator(".configuration-property")).toHaveCount(4);

await page.getByTestId("settings-search-widget").locator("input").fill("legacy");
await expect(page.getByTestId("settings-search-widget").locator("input")).toHaveValue("legacy");
await page.getByTestId("settings-search-widget").locator("button[type=submit]").click();

await expect(page.getByTestId("config-groups").locator(".configuration-property")).toHaveCount(1);
});
Loading

0 comments on commit 39437e5

Please sign in to comment.