Status Page E2E spec (#5068)
Some checks are pending
Auto Test / auto-test (18, ARM64) (push) Blocked by required conditions
Auto Test / auto-test (18, macos-latest) (push) Blocked by required conditions
Auto Test / auto-test (18, ubuntu-latest) (push) Blocked by required conditions
Auto Test / auto-test (18, windows-latest) (push) Blocked by required conditions
Auto Test / auto-test (20.5, ARM64) (push) Blocked by required conditions
Auto Test / auto-test (20.5, macos-latest) (push) Blocked by required conditions
Auto Test / auto-test (20.5, ubuntu-latest) (push) Blocked by required conditions
Auto Test / auto-test (20.5, windows-latest) (push) Blocked by required conditions
Auto Test / armv7-simple-test (18, ARMv7) (push) Blocked by required conditions
Auto Test / armv7-simple-test (20, ARMv7) (push) Blocked by required conditions
Auto Test / check-linters (push) Waiting to run
Auto Test / e2e-test (push) Blocked by required conditions
CodeQL / Analyze (go) (push) Waiting to run
CodeQL / Analyze (javascript-typescript) (push) Waiting to run
Merge Conflict Labeler / Labeling (push) Waiting to run
json-yaml-validate / json-yaml-validate (push) Waiting to run

This commit is contained in:
Shaun 2024-08-31 20:20:55 -04:00 committed by GitHub
parent ba46945ea9
commit c567e8eb8e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 185 additions and 48 deletions

View file

@ -58,7 +58,7 @@ export default defineConfig({
// Run your local dev server before starting the tests. // Run your local dev server before starting the tests.
webServer: { webServer: {
command: `node extra/remove-playwright-test-data.js && node server/server.js --port=${port} --data-dir=./data/playwright-test`, command: `node extra/remove-playwright-test-data.js && cross-env NODE_ENV=development node server/server.js --port=${port} --data-dir=./data/playwright-test`,
url, url,
reuseExistingServer: false, reuseExistingServer: false,
cwd: "../", cwd: "../",

View file

@ -45,7 +45,7 @@
</span> </span>
</div> </div>
</div> </div>
<div ref="monitorList" class="monitor-list" :class="{ scrollbar: scrollbar }" :style="monitorListStyle"> <div ref="monitorList" class="monitor-list" :class="{ scrollbar: scrollbar }" :style="monitorListStyle" data-testid="monitor-list">
<div v-if="Object.keys($root.monitorList).length === 0" class="text-center mt-3"> <div v-if="Object.keys($root.monitorList).length === 0" class="text-center mt-3">
{{ $t("No Monitors, please") }} <router-link to="/add">{{ $t("add one") }}</router-link> {{ $t("No Monitors, please") }} <router-link to="/add">{{ $t("add one") }}</router-link>
</div> </div>

View file

@ -7,12 +7,12 @@
:animation="100" :animation="100"
> >
<template #item="group"> <template #item="group">
<div class="mb-5 "> <div class="mb-5" data-testid="group">
<!-- Group Title --> <!-- Group Title -->
<h2 class="group-title"> <h2 class="group-title">
<font-awesome-icon v-if="editMode && showGroupDrag" icon="arrows-alt-v" class="action drag me-3" /> <font-awesome-icon v-if="editMode && showGroupDrag" icon="arrows-alt-v" class="action drag me-3" />
<font-awesome-icon v-if="editMode" icon="times" class="action remove me-3" @click="removeGroup(group.index)" /> <font-awesome-icon v-if="editMode" icon="times" class="action remove me-3" @click="removeGroup(group.index)" />
<Editable v-model="group.element.name" :contenteditable="editMode" tag="span" /> <Editable v-model="group.element.name" :contenteditable="editMode" tag="span" data-testid="group-name" />
</h2> </h2>
<div class="shadow-box monitor-list mt-4 position-relative"> <div class="shadow-box monitor-list mt-4 position-relative">
@ -31,7 +31,7 @@
item-key="id" item-key="id"
> >
<template #item="monitor"> <template #item="monitor">
<div class="item"> <div class="item" data-testid="monitor">
<div class="row"> <div class="row">
<div class="col-6 col-md-4 small-padding"> <div class="col-6 col-md-4 small-padding">
<div class="info"> <div class="info">
@ -45,10 +45,11 @@
class="item-name" class="item-name"
target="_blank" target="_blank"
rel="noopener noreferrer" rel="noopener noreferrer"
data-testid="monitor-name"
> >
{{ monitor.element.name }} {{ monitor.element.name }}
</a> </a>
<p v-else class="item-name"> {{ monitor.element.name }} </p> <p v-else class="item-name" data-testid="monitor-name"> {{ monitor.element.name }} </p>
<span <span
title="Setting" title="Setting"
@ -66,7 +67,7 @@
<Tag :item="{name: $t('Cert Exp.'), value: formattedCertExpiryMessage(monitor), color: certExpiryColor(monitor)}" :size="'sm'" /> <Tag :item="{name: $t('Cert Exp.'), value: formattedCertExpiryMessage(monitor), color: certExpiryColor(monitor)}" :size="'sm'" />
</div> </div>
<div v-if="showTags"> <div v-if="showTags">
<Tag v-for="tag in monitor.element.tags" :key="tag" :item="tag" :size="'sm'" /> <Tag v-for="tag in monitor.element.tags" :key="tag" :item="tag" :size="'sm'" data-testid="monitor-tag" />
</div> </div>
</div> </div>
</div> </div>

View file

@ -14,6 +14,7 @@
type="button" type="button"
class="btn btn-outline-secondary btn-add" class="btn btn-outline-secondary btn-add"
:disabled="processing" :disabled="processing"
data-testid="add-tag-button"
@click.stop="showAddDialog" @click.stop="showAddDialog"
> >
<font-awesome-icon class="me-1" icon="plus" /> {{ $t("Add") }} <font-awesome-icon class="me-1" icon="plus" /> {{ $t("Add") }}
@ -59,6 +60,7 @@
v-model="newDraftTag.name" class="form-control" v-model="newDraftTag.name" class="form-control"
:class="{'is-invalid': validateDraftTag.nameInvalid}" :class="{'is-invalid': validateDraftTag.nameInvalid}"
:placeholder="$t('Name')" :placeholder="$t('Name')"
data-testid="tag-name-input"
@keydown.enter.prevent="onEnter" @keydown.enter.prevent="onEnter"
/> />
<div class="invalid-feedback"> <div class="invalid-feedback">
@ -76,6 +78,7 @@
label="name" label="name"
select-label="" select-label=""
deselect-label="" deselect-label=""
data-testid="tag-color-select"
> >
<template #option="{ option }"> <template #option="{ option }">
<div <div
@ -103,6 +106,7 @@
v-model="newDraftTag.value" class="form-control" v-model="newDraftTag.value" class="form-control"
:class="{'is-invalid': validateDraftTag.valueInvalid}" :class="{'is-invalid': validateDraftTag.valueInvalid}"
:placeholder="$t('value (optional)')" :placeholder="$t('value (optional)')"
data-testid="tag-value-input"
@keydown.enter.prevent="onEnter" @keydown.enter.prevent="onEnter"
/> />
<div class="invalid-feedback"> <div class="invalid-feedback">
@ -114,6 +118,7 @@
type="button" type="button"
class="btn btn-secondary float-end" class="btn btn-secondary float-end"
:disabled="processing || validateDraftTag.invalid" :disabled="processing || validateDraftTag.invalid"
data-testid="tag-submit-button"
@click.stop="addDraftTag" @click.stop="addDraftTag"
> >
{{ $t("Add") }} {{ $t("Add") }}

View file

@ -9,14 +9,14 @@
<div class="shadow-box"> <div class="shadow-box">
<div class="mb-3"> <div class="mb-3">
<label for="name" class="form-label">{{ $t("Name") }}</label> <label for="name" class="form-label">{{ $t("Name") }}</label>
<input id="name" v-model="title" type="text" class="form-control" required> <input id="name" v-model="title" type="text" class="form-control" required data-testid="name-input">
</div> </div>
<div class="mb-4"> <div class="mb-4">
<label for="slug" class="form-label">{{ $t("Slug") }}</label> <label for="slug" class="form-label">{{ $t("Slug") }}</label>
<div class="input-group"> <div class="input-group">
<span id="basic-addon3" class="input-group-text">/status/</span> <span id="basic-addon3" class="input-group-text">/status/</span>
<input id="slug" v-model="slug" type="text" class="form-control" required> <input id="slug" v-model="slug" type="text" class="form-control" required data-testid="slug-input">
</div> </div>
<div class="form-text"> <div class="form-text">
<ul> <ul>
@ -33,7 +33,7 @@
</div> </div>
<div class="mt-2 mb-1"> <div class="mt-2 mb-1">
<button id="monitor-submit-btn" class="btn btn-primary w-100" type="submit" :disabled="processing">{{ $t("Next") }}</button> <button id="monitor-submit-btn" class="btn btn-primary w-100" type="submit" :disabled="processing" data-testid="submit-button">{{ $t("Next") }}</button>
</div> </div>
</div> </div>
</form> </form>

View file

@ -105,7 +105,7 @@
<!-- URL --> <!-- URL -->
<div v-if="monitor.type === 'http' || monitor.type === 'keyword' || monitor.type === 'json-query' || monitor.type === 'real-browser' " class="my-3"> <div v-if="monitor.type === 'http' || monitor.type === 'keyword' || monitor.type === 'json-query' || monitor.type === 'real-browser' " class="my-3">
<label for="url" class="form-label">{{ $t("URL") }}</label> <label for="url" class="form-label">{{ $t("URL") }}</label>
<input id="url" v-model="monitor.url" type="url" class="form-control" pattern="https?://.+" required> <input id="url" v-model="monitor.url" type="url" class="form-control" pattern="https?://.+" required data-testid="url-input">
</div> </div>
<!-- gRPC URL --> <!-- gRPC URL -->

View file

@ -1,7 +1,7 @@
<template> <template>
<div v-if="loadedTheme" class="container mt-3"> <div v-if="loadedTheme" class="container mt-3">
<!-- Sidebar for edit mode --> <!-- Sidebar for edit mode -->
<div v-if="enableEditMode" class="sidebar"> <div v-if="enableEditMode" class="sidebar" data-testid="edit-sidebar">
<div class="sidebar-body"> <div class="sidebar-body">
<div class="my-3"> <div class="my-3">
<label for="slug" class="form-label">{{ $t("Slug") }}</label> <label for="slug" class="form-label">{{ $t("Slug") }}</label>
@ -19,7 +19,7 @@
<!-- Description --> <!-- Description -->
<div class="my-3"> <div class="my-3">
<label for="description" class="form-label">{{ $t("Description") }}</label> <label for="description" class="form-label">{{ $t("Description") }}</label>
<textarea id="description" v-model="config.description" class="form-control"></textarea> <textarea id="description" v-model="config.description" class="form-control" data-testid="description-input"></textarea>
<div class="form-text"> <div class="form-text">
{{ $t("markdownSupported") }} {{ $t("markdownSupported") }}
</div> </div>
@ -28,7 +28,7 @@
<!-- Footer Text --> <!-- Footer Text -->
<div class="my-3"> <div class="my-3">
<label for="footer-text" class="form-label">{{ $t("Footer Text") }}</label> <label for="footer-text" class="form-label">{{ $t("Footer Text") }}</label>
<textarea id="footer-text" v-model="config.footerText" class="form-control"></textarea> <textarea id="footer-text" v-model="config.footerText" class="form-control" data-testid="footer-text-input"></textarea>
<div class="form-text"> <div class="form-text">
{{ $t("markdownSupported") }} {{ $t("markdownSupported") }}
</div> </div>
@ -36,7 +36,7 @@
<div class="my-3"> <div class="my-3">
<label for="auto-refresh-interval" class="form-label">{{ $t("Refresh Interval") }}</label> <label for="auto-refresh-interval" class="form-label">{{ $t("Refresh Interval") }}</label>
<input id="auto-refresh-interval" v-model="config.autoRefreshInterval" type="number" class="form-control" :min="5"> <input id="auto-refresh-interval" v-model="config.autoRefreshInterval" type="number" class="form-control" :min="5" data-testid="refresh-interval-input">
<div class="form-text"> <div class="form-text">
{{ $t("Refresh Interval Description", [config.autoRefreshInterval]) }} {{ $t("Refresh Interval Description", [config.autoRefreshInterval]) }}
</div> </div>
@ -44,7 +44,7 @@
<div class="my-3"> <div class="my-3">
<label for="switch-theme" class="form-label">{{ $t("Theme") }}</label> <label for="switch-theme" class="form-label">{{ $t("Theme") }}</label>
<select id="switch-theme" v-model="config.theme" class="form-select"> <select id="switch-theme" v-model="config.theme" class="form-select" data-testid="theme-select">
<option value="auto">{{ $t("Auto") }}</option> <option value="auto">{{ $t("Auto") }}</option>
<option value="light">{{ $t("Light") }}</option> <option value="light">{{ $t("Light") }}</option>
<option value="dark">{{ $t("Dark") }}</option> <option value="dark">{{ $t("Dark") }}</option>
@ -52,19 +52,19 @@
</div> </div>
<div class="my-3 form-check form-switch"> <div class="my-3 form-check form-switch">
<input id="showTags" v-model="config.showTags" class="form-check-input" type="checkbox"> <input id="showTags" v-model="config.showTags" class="form-check-input" type="checkbox" data-testid="show-tags-checkbox">
<label class="form-check-label" for="showTags">{{ $t("Show Tags") }}</label> <label class="form-check-label" for="showTags">{{ $t("Show Tags") }}</label>
</div> </div>
<!-- Show Powered By --> <!-- Show Powered By -->
<div class="my-3 form-check form-switch"> <div class="my-3 form-check form-switch">
<input id="show-powered-by" v-model="config.showPoweredBy" class="form-check-input" type="checkbox"> <input id="show-powered-by" v-model="config.showPoweredBy" class="form-check-input" type="checkbox" data-testid="show-powered-by-checkbox">
<label class="form-check-label" for="show-powered-by">{{ $t("Show Powered By") }}</label> <label class="form-check-label" for="show-powered-by">{{ $t("Show Powered By") }}</label>
</div> </div>
<!-- Show certificate expiry --> <!-- Show certificate expiry -->
<div class="my-3 form-check form-switch"> <div class="my-3 form-check form-switch">
<input id="show-certificate-expiry" v-model="config.showCertificateExpiry" class="form-check-input" type="checkbox"> <input id="show-certificate-expiry" v-model="config.showCertificateExpiry" class="form-check-input" type="checkbox" data-testid="show-certificate-expiry-checkbox">
<label class="form-check-label" for="show-certificate-expiry">{{ $t("showCertificateExpiry") }}</label> <label class="form-check-label" for="show-certificate-expiry">{{ $t("showCertificateExpiry") }}</label>
</div> </div>
@ -95,13 +95,13 @@
<!-- Google Analytics --> <!-- Google Analytics -->
<div class="my-3"> <div class="my-3">
<label for="googleAnalyticsTag" class="form-label">{{ $t("Google Analytics ID") }}</label> <label for="googleAnalyticsTag" class="form-label">{{ $t("Google Analytics ID") }}</label>
<input id="googleAnalyticsTag" v-model="config.googleAnalyticsId" type="text" class="form-control"> <input id="googleAnalyticsTag" v-model="config.googleAnalyticsId" type="text" class="form-control" data-testid="google-analytics-input">
</div> </div>
<!-- Custom CSS --> <!-- Custom CSS -->
<div class="my-3"> <div class="my-3">
<div class="mb-1">{{ $t("Custom CSS") }}</div> <div class="mb-1">{{ $t("Custom CSS") }}</div>
<prism-editor v-model="config.customCSS" class="css-editor" :highlight="highlighter" line-numbers></prism-editor> <prism-editor v-model="config.customCSS" class="css-editor" data-testid="custom-css-input" :highlight="highlighter" line-numbers></prism-editor>
</div> </div>
<div class="danger-zone"> <div class="danger-zone">
@ -114,7 +114,7 @@
<!-- Sidebar Footer --> <!-- Sidebar Footer -->
<div class="sidebar-footer"> <div class="sidebar-footer">
<button class="btn btn-success me-2" :disabled="loading" @click="save"> <button class="btn btn-success me-2" :disabled="loading" data-testid="save-button" @click="save">
<font-awesome-icon icon="save" /> <font-awesome-icon icon="save" />
{{ $t("Save") }} {{ $t("Save") }}
</button> </button>
@ -157,7 +157,7 @@
<!-- Admin functions --> <!-- Admin functions -->
<div v-if="hasToken" class="mb-4"> <div v-if="hasToken" class="mb-4">
<div v-if="!enableEditMode"> <div v-if="!enableEditMode">
<button class="btn btn-info me-2" @click="edit"> <button class="btn btn-info me-2" data-testid="edit-button" @click="edit">
<font-awesome-icon icon="edit" /> <font-awesome-icon icon="edit" />
{{ $t("Edit Status Page") }} {{ $t("Edit Status Page") }}
</button> </button>
@ -169,7 +169,7 @@
</div> </div>
<div v-else> <div v-else>
<button class="btn btn-primary btn-add-group me-2" @click="createIncident"> <button class="btn btn-primary btn-add-group me-2" data-testid="create-incident-button" @click="createIncident">
<font-awesome-icon icon="bullhorn" /> <font-awesome-icon icon="bullhorn" />
{{ $t("Create Incident") }} {{ $t("Create Incident") }}
</button> </button>
@ -177,17 +177,17 @@
</div> </div>
<!-- Incident --> <!-- Incident -->
<div v-if="incident !== null" class="shadow-box alert mb-4 p-4 incident" role="alert" :class="incidentClass"> <div v-if="incident !== null" class="shadow-box alert mb-4 p-4 incident" role="alert" :class="incidentClass" data-testid="incident">
<strong v-if="editIncidentMode">{{ $t("Title") }}:</strong> <strong v-if="editIncidentMode">{{ $t("Title") }}:</strong>
<Editable v-model="incident.title" tag="h4" :contenteditable="editIncidentMode" :noNL="true" class="alert-heading" /> <Editable v-model="incident.title" tag="h4" :contenteditable="editIncidentMode" :noNL="true" class="alert-heading" data-testid="incident-title" />
<strong v-if="editIncidentMode">{{ $t("Content") }}:</strong> <strong v-if="editIncidentMode">{{ $t("Content") }}:</strong>
<Editable v-if="editIncidentMode" v-model="incident.content" tag="div" :contenteditable="editIncidentMode" class="content" /> <Editable v-if="editIncidentMode" v-model="incident.content" tag="div" :contenteditable="editIncidentMode" class="content" data-testid="incident-content-editable" />
<div v-if="editIncidentMode" class="form-text"> <div v-if="editIncidentMode" class="form-text">
{{ $t("markdownSupported") }} {{ $t("markdownSupported") }}
</div> </div>
<!-- eslint-disable-next-line vue/no-v-html--> <!-- eslint-disable-next-line vue/no-v-html-->
<div v-if="! editIncidentMode" class="content" v-html="incidentHTML"></div> <div v-if="! editIncidentMode" class="content" data-testid="incident-content" v-html="incidentHTML"></div>
<!-- Incident Date --> <!-- Incident Date -->
<div class="date mt-3"> <div class="date mt-3">
@ -198,7 +198,7 @@
</div> </div>
<div v-if="editMode" class="mt-3"> <div v-if="editMode" class="mt-3">
<button v-if="editIncidentMode" class="btn btn-light me-2" @click="postIncident"> <button v-if="editIncidentMode" class="btn btn-light me-2" data-testid="post-incident-button" @click="postIncident">
<font-awesome-icon icon="bullhorn" /> <font-awesome-icon icon="bullhorn" />
{{ $t("Post") }} {{ $t("Post") }}
</button> </button>
@ -283,13 +283,13 @@
<!-- Description --> <!-- Description -->
<strong v-if="editMode">{{ $t("Description") }}:</strong> <strong v-if="editMode">{{ $t("Description") }}:</strong>
<Editable v-if="enableEditMode" v-model="config.description" :contenteditable="editMode" tag="div" class="mb-4 description" /> <Editable v-if="enableEditMode" v-model="config.description" :contenteditable="editMode" tag="div" class="mb-4 description" data-testid="description-editable" />
<!-- eslint-disable-next-line vue/no-v-html--> <!-- eslint-disable-next-line vue/no-v-html-->
<div v-if="! enableEditMode" class="alert-heading p-2" v-html="descriptionHTML"></div> <div v-if="! enableEditMode" class="alert-heading p-2" data-testid="description" v-html="descriptionHTML"></div>
<div v-if="editMode" class="mb-4"> <div v-if="editMode" class="mb-4">
<div> <div>
<button class="btn btn-primary btn-add-group me-2" @click="addGroup"> <button class="btn btn-primary btn-add-group me-2" data-testid="add-group-button" @click="addGroup">
<font-awesome-icon icon="plus" /> <font-awesome-icon icon="plus" />
{{ $t("Add Group") }} {{ $t("Add Group") }}
</button> </button>
@ -307,6 +307,7 @@
label="name" label="name"
trackBy="name" trackBy="name"
class="mt-3" class="mt-3"
data-testid="monitor-select"
> >
<template #option="{ option }"> <template #option="{ option }">
<div class="d-inline-flex"> <div class="d-inline-flex">
@ -334,17 +335,17 @@
<div class="custom-footer-text text-start"> <div class="custom-footer-text text-start">
<strong v-if="enableEditMode">{{ $t("Custom Footer") }}:</strong> <strong v-if="enableEditMode">{{ $t("Custom Footer") }}:</strong>
</div> </div>
<Editable v-if="enableEditMode" v-model="config.footerText" tag="div" :contenteditable="enableEditMode" :noNL="false" class="alert-heading p-2" /> <Editable v-if="enableEditMode" v-model="config.footerText" tag="div" :contenteditable="enableEditMode" :noNL="false" class="alert-heading p-2" data-testid="custom-footer-editable" />
<!-- eslint-disable-next-line vue/no-v-html--> <!-- eslint-disable-next-line vue/no-v-html-->
<div v-if="! enableEditMode" class="alert-heading p-2" v-html="footerHTML"></div> <div v-if="! enableEditMode" class="alert-heading p-2" data-testid="footer-text" v-html="footerHTML"></div>
<p v-if="config.showPoweredBy"> <p v-if="config.showPoweredBy" data-testid="powered-by">
{{ $t("Powered by") }} <a target="_blank" rel="noopener noreferrer" href="https://github.com/louislam/uptime-kuma">{{ $t("Uptime Kuma" ) }}</a> {{ $t("Powered by") }} <a target="_blank" rel="noopener noreferrer" href="https://github.com/louislam/uptime-kuma">{{ $t("Uptime Kuma" ) }}</a>
</p> </p>
<div class="refresh-info mb-2"> <div class="refresh-info mb-2">
<div>{{ $t("Last Updated") }}: {{ lastUpdateTimeDisplay }}</div> <div>{{ $t("Last Updated") }}: {{ lastUpdateTimeDisplay }}</div>
<div>{{ $tc("statusPageRefreshIn", [ updateCountdownText]) }}</div> <div data-testid="update-countdown-text">{{ $tc("statusPageRefreshIn", [ updateCountdownText]) }}</div>
</div> </div>
</footer> </footer>
</div> </div>

View file

@ -13,25 +13,26 @@ test.describe("Example Spec", () => {
await screenshot(testInfo, page); await screenshot(testInfo, page);
}); });
test("change display timezone", async ({ page }, testInfo) => { test("set up monitor", async ({ page }, testInfo) => {
await page.goto("./settings/general"); await page.goto("./add");
await login(page); await login(page);
await page.getByLabel("Display Timezone").selectOption("Pacific/Fiji");
await page.getByRole("button", { name: "Save" }).click();
await screenshot(testInfo, page);
await page.goto("./dashboard"); await expect(page.getByTestId("monitor-type-select")).toBeVisible();
await page.goto("./settings/general"); await page.getByTestId("monitor-type-select").selectOption("http");
await expect(page.getByLabel("Display Timezone")).toHaveValue("Pacific/Fiji"); await page.getByTestId("friendly-name-input").fill("example.com");
await page.getByTestId("url-input").fill("https://www.example.com/");
await page.getByTestId("save-button").click();
await page.waitForURL("/dashboard/*"); // wait for the monitor to be created
await expect(page.getByTestId("monitor-list")).toContainText("example.com");
await screenshot(testInfo, page);
}); });
test("database is reset after previous test", async ({ page }, testInfo) => { test("database is reset after previous test", async ({ page }, testInfo) => {
await page.goto("./settings/general"); await page.goto("./dashboard");
await login(page); await login(page);
const timezoneEl = page.getByLabel("Display Timezone"); await expect(page.getByTestId("monitor-list")).not.toContainText("example.com");
await expect(timezoneEl).toBeVisible();
await expect(timezoneEl).toHaveValue("auto");
await screenshot(testInfo, page); await screenshot(testInfo, page);
}); });

View file

@ -0,0 +1,129 @@
import { expect, test } from "@playwright/test";
import { login, restoreSqliteSnapshot, screenshot } from "../util-test";
test.describe("Status Page", () => {
test.beforeEach(async ({ page }) => {
await restoreSqliteSnapshot(page);
});
test("create and edit", async ({ page }, testInfo) => {
// Monitor
const monitorName = "Monitor for Status Page";
const tagName = "Client";
const tagValue = "Acme Inc";
// Status Page
const footerText = "This is footer text.";
const refreshInterval = 30;
const theme = "dark";
const googleAnalyticsId = "G-123";
const customCss = "body { background: rgb(0, 128, 128) !important; }";
const descriptionText = "This is an example status page.";
const incidentTitle = "Example Outage Incident";
const incidentContent = "Sample incident message.";
const groupName = "Example Group 1";
// Set up a monitor that can be added to the Status Page
await page.goto("./add");
await login(page);
await expect(page.getByTestId("monitor-type-select")).toBeVisible();
await page.getByTestId("monitor-type-select").selectOption("http");
await page.getByTestId("friendly-name-input").fill(monitorName);
await page.getByTestId("url-input").fill("https://www.example.com/");
await page.getByTestId("add-tag-button").click();
await page.getByTestId("tag-name-input").fill(tagName);
await page.getByTestId("tag-value-input").fill(tagValue);
await page.getByTestId("tag-color-select").click(); // Vue-Multiselect component
await page.getByTestId("tag-color-select").getByRole("option", { name: "Orange" }).click();
await page.getByTestId("tag-submit-button").click();
await page.getByTestId("save-button").click();
await page.waitForURL("/dashboard/*"); // wait for the monitor to be created
// Create a new status page
await page.goto("./add-status-page");
await screenshot(testInfo, page);
await page.getByTestId("name-input").fill("Example");
await page.getByTestId("slug-input").fill("example");
await page.getByTestId("submit-button").click();
await page.waitForURL("/status/example?edit"); // wait for the page to be created
// Fill in some details
await page.getByTestId("description-input").fill(descriptionText);
await page.getByTestId("footer-text-input").fill(footerText);
await page.getByTestId("refresh-interval-input").fill(String(refreshInterval));
await page.getByTestId("theme-select").selectOption(theme);
await page.getByTestId("show-tags-checkbox").uncheck();
await page.getByTestId("show-powered-by-checkbox").uncheck();
await page.getByTestId("show-certificate-expiry-checkbox").uncheck();
await page.getByTestId("google-analytics-input").fill(googleAnalyticsId);
await page.getByTestId("custom-css-input").getByTestId("textarea").fill(customCss); // Prism
await expect(page.getByTestId("description-editable")).toHaveText(descriptionText);
await expect(page.getByTestId("custom-footer-editable")).toHaveText(footerText);
// Add an incident
await page.getByTestId("create-incident-button").click();
await page.getByTestId("incident-title").isEditable();
await page.getByTestId("incident-title").fill(incidentTitle);
await page.getByTestId("incident-content-editable").fill(incidentContent);
await page.getByTestId("post-incident-button").click();
// Add a group
await page.getByTestId("add-group-button").click();
await page.getByTestId("group-name").isEditable();
await page.getByTestId("group-name").fill(groupName);
// Add the monitor
await page.getByTestId("monitor-select").click(); // Vue-Multiselect component
await page.getByTestId("monitor-select").getByRole("option", { name: monitorName }).click();
await expect(page.getByTestId("monitor")).toHaveCount(1);
await expect(page.getByTestId("monitor-name")).toContainText(monitorName);
// Save the changes
await screenshot(testInfo, page);
await page.getByTestId("save-button").click();
await expect(page.getByTestId("edit-sidebar")).toHaveCount(0);
// Ensure changes are visible
await expect(page.getByTestId("incident")).toHaveCount(1);
await expect(page.getByTestId("incident-title")).toContainText(incidentTitle);
await expect(page.getByTestId("incident-content")).toContainText(incidentContent);
await expect(page.getByTestId("description")).toContainText(descriptionText);
await expect(page.getByTestId("group-name")).toContainText(groupName);
await expect(page.getByTestId("footer-text")).toContainText(footerText);
await expect(page.getByTestId("powered-by")).toHaveCount(0);
await expect(page.getByTestId("update-countdown-text")).toContainText("00:");
const updateCountdown = Number((await page.getByTestId("update-countdown-text").textContent()).match(/(\d+):(\d+)/)[2]) ;
expect(updateCountdown).toBeGreaterThanOrEqual(refreshInterval); // cant be certain when the timer will start, so ensure it's within expected range
expect(updateCountdown).toBeLessThanOrEqual(refreshInterval + 10);
await expect(page.locator("body")).toHaveClass(theme);
expect(await page.locator("head").innerHTML()).toContain(googleAnalyticsId);
const backgroundColor = await page.evaluate(() => window.getComputedStyle(document.body).backgroundColor);
expect(backgroundColor).toEqual("rgb(0, 128, 128)");
await screenshot(testInfo, page);
// Flip the "Show Tags" and "Show Powered By" switches:
await page.getByTestId("edit-button").click();
await expect(page.getByTestId("edit-sidebar")).toHaveCount(1);
await page.getByTestId("show-tags-checkbox").setChecked(true);
await page.getByTestId("show-powered-by-checkbox").setChecked(true);
await screenshot(testInfo, page);
await page.getByTestId("save-button").click();
await expect(page.getByTestId("edit-sidebar")).toHaveCount(0);
await expect(page.getByTestId("powered-by")).toContainText("Powered by");
await expect(page.getByTestId("monitor-tag")).toContainText(tagValue);
await screenshot(testInfo, page);
});
// @todo Test certificate expiry
// @todo Test domain names
});