mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-05-20 06:02:33 +02:00
feat(e2e): add friendly name e2e tests
- Using hostname as friendly name for DNS. - Using URL hostname as friendly name for HTTP. - Setting a custom friendly name for HTTP. - Using the default friendly name when no custom name is provided (for group monitors).
This commit is contained in:
parent
1019527d8c
commit
f01fdfee63
1 changed files with 83 additions and 0 deletions
83
test/e2e/specs/fridendly-name.spec.js
Normal file
83
test/e2e/specs/fridendly-name.spec.js
Normal file
|
@ -0,0 +1,83 @@
|
|||
import { expect, test } from "@playwright/test";
|
||||
import { login, restoreSqliteSnapshot, screenshot } from "../util-test";
|
||||
|
||||
test.describe("Friendly Name Tests", () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await restoreSqliteSnapshot(page);
|
||||
});
|
||||
|
||||
test("hostname", async ({ page }, testInfo) => {
|
||||
// Test DNS monitor with hostname
|
||||
await page.goto("./add");
|
||||
await login(page);
|
||||
await screenshot(testInfo, page);
|
||||
|
||||
await page.getByTestId("monitor-type-select").selectOption("dns");
|
||||
await page.getByTestId("hostname-input").fill("example.com");
|
||||
await screenshot(testInfo, page);
|
||||
|
||||
await page.getByTestId("save-button").click();
|
||||
await page.waitForURL("/dashboard/*");
|
||||
|
||||
expect(page.getByTestId("monitor-list")).toContainText("example.com");
|
||||
await screenshot(testInfo, page);
|
||||
});
|
||||
|
||||
test("URL hostname", async ({ page }, testInfo) => {
|
||||
// Test HTTP monitor with URL
|
||||
await page.goto("./add");
|
||||
await login(page);
|
||||
await screenshot(testInfo, page);
|
||||
|
||||
await page.getByTestId("monitor-type-select").selectOption("http");
|
||||
await page.getByTestId("url-input").fill("https://www.example.com/");
|
||||
await screenshot(testInfo, page);
|
||||
|
||||
await page.getByTestId("save-button").click();
|
||||
await page.waitForURL("/dashboard/*");
|
||||
|
||||
expect(page.getByTestId("monitor-list")).toContainText("www.example.com");
|
||||
await screenshot(testInfo, page);
|
||||
});
|
||||
|
||||
test("custom friendly name", async ({ page }, testInfo) => {
|
||||
// Test custom friendly name for HTTP monitor
|
||||
await page.goto("./add");
|
||||
await login(page);
|
||||
await screenshot(testInfo, page);
|
||||
|
||||
await page.getByTestId("monitor-type-select").selectOption("http");
|
||||
await page.getByTestId("url-input").fill("https://www.example.com/");
|
||||
|
||||
// Check if the friendly name placeholder is set to the hostname
|
||||
const friendlyNameInput = page.getByTestId("friendly-name-input");
|
||||
expect(friendlyNameInput).toHaveAttribute("placeholder", "www.example.com");
|
||||
await screenshot(testInfo, page);
|
||||
|
||||
const customName = "Example Monitor";
|
||||
await friendlyNameInput.fill(customName);
|
||||
await screenshot(testInfo, page);
|
||||
|
||||
await page.getByTestId("save-button").click();
|
||||
await page.waitForURL("/dashboard/*");
|
||||
|
||||
expect(page.getByTestId("monitor-list")).toContainText(customName);
|
||||
await screenshot(testInfo, page);
|
||||
});
|
||||
|
||||
test("default friendly name", async ({ page }, testInfo) => {
|
||||
// Test default friendly name when no custom name is provided
|
||||
await page.goto("./add");
|
||||
await login(page);
|
||||
await screenshot(testInfo, page);
|
||||
|
||||
await page.getByTestId("monitor-type-select").selectOption("group");
|
||||
await screenshot(testInfo, page);
|
||||
|
||||
await page.getByTestId("save-button").click();
|
||||
await page.waitForURL("/dashboard/*");
|
||||
|
||||
expect(page.getByTestId("monitor-list")).toContainText("New Monitor");
|
||||
await screenshot(testInfo, page);
|
||||
});
|
||||
});
|
Loading…
Add table
Reference in a new issue