Skip to content

Commit

Permalink
Status Page E2E spec (louislam#5068)
Browse files Browse the repository at this point in the history
  • Loading branch information
simshaun authored Sep 1, 2024
1 parent ba46945 commit c567e8e
Show file tree
Hide file tree
Showing 9 changed files with 185 additions and 48 deletions.
2 changes: 1 addition & 1 deletion config/playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default defineConfig({

// Run your local dev server before starting the tests.
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,
reuseExistingServer: false,
cwd: "../",
Expand Down
2 changes: 1 addition & 1 deletion src/components/MonitorList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
</span>
</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">
{{ $t("No Monitors, please") }} <router-link to="/add">{{ $t("add one") }}</router-link>
</div>
Expand Down
11 changes: 6 additions & 5 deletions src/components/PublicGroupList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
:animation="100"
>
<template #item="group">
<div class="mb-5 ">
<div class="mb-5" data-testid="group">
<!-- 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" 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>

<div class="shadow-box monitor-list mt-4 position-relative">
Expand All @@ -31,7 +31,7 @@
item-key="id"
>
<template #item="monitor">
<div class="item">
<div class="item" data-testid="monitor">
<div class="row">
<div class="col-6 col-md-4 small-padding">
<div class="info">
Expand All @@ -45,10 +45,11 @@
class="item-name"
target="_blank"
rel="noopener noreferrer"
data-testid="monitor-name"
>
{{ monitor.element.name }}
</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
title="Setting"
Expand All @@ -66,7 +67,7 @@
<Tag :item="{name: $t('Cert Exp.'), value: formattedCertExpiryMessage(monitor), color: certExpiryColor(monitor)}" :size="'sm'" />
</div>
<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>
Expand Down
5 changes: 5 additions & 0 deletions src/components/TagsManager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
type="button"
class="btn btn-outline-secondary btn-add"
:disabled="processing"
data-testid="add-tag-button"
@click.stop="showAddDialog"
>
<font-awesome-icon class="me-1" icon="plus" /> {{ $t("Add") }}
Expand Down Expand Up @@ -59,6 +60,7 @@
v-model="newDraftTag.name" class="form-control"
:class="{'is-invalid': validateDraftTag.nameInvalid}"
:placeholder="$t('Name')"
data-testid="tag-name-input"
@keydown.enter.prevent="onEnter"
/>
<div class="invalid-feedback">
Expand All @@ -76,6 +78,7 @@
label="name"
select-label=""
deselect-label=""
data-testid="tag-color-select"
>
<template #option="{ option }">
<div
Expand Down Expand Up @@ -103,6 +106,7 @@
v-model="newDraftTag.value" class="form-control"
:class="{'is-invalid': validateDraftTag.valueInvalid}"
:placeholder="$t('value (optional)')"
data-testid="tag-value-input"
@keydown.enter.prevent="onEnter"
/>
<div class="invalid-feedback">
Expand All @@ -114,6 +118,7 @@
type="button"
class="btn btn-secondary float-end"
:disabled="processing || validateDraftTag.invalid"
data-testid="tag-submit-button"
@click.stop="addDraftTag"
>
{{ $t("Add") }}
Expand Down
6 changes: 3 additions & 3 deletions src/pages/AddStatusPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
<div class="shadow-box">
<div class="mb-3">
<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 class="mb-4">
<label for="slug" class="form-label">{{ $t("Slug") }}</label>
<div class="input-group">
<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 class="form-text">
<ul>
Expand All @@ -33,7 +33,7 @@
</div>

<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>
</form>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/EditMonitor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
<!-- URL -->
<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>
<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>

<!-- gRPC URL -->
Expand Down
51 changes: 26 additions & 25 deletions src/pages/StatusPage.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div v-if="loadedTheme" class="container mt-3">
<!-- 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="my-3">
<label for="slug" class="form-label">{{ $t("Slug") }}</label>
Expand All @@ -19,7 +19,7 @@
<!-- Description -->
<div class="my-3">
<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">
{{ $t("markdownSupported") }}
</div>
Expand All @@ -28,43 +28,43 @@
<!-- Footer Text -->
<div class="my-3">
<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">
{{ $t("markdownSupported") }}
</div>
</div>

<div class="my-3">
<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">
{{ $t("Refresh Interval Description", [config.autoRefreshInterval]) }}
</div>
</div>

<div class="my-3">
<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="light">{{ $t("Light") }}</option>
<option value="dark">{{ $t("Dark") }}</option>
</select>
</div>

<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>
</div>

<!-- Show Powered By -->
<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>
</div>

<!-- Show certificate expiry -->
<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>
</div>

Expand Down Expand Up @@ -95,13 +95,13 @@
<!-- Google Analytics -->
<div class="my-3">
<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>

<!-- Custom CSS -->
<div class="my-3">
<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 class="danger-zone">
Expand All @@ -114,7 +114,7 @@

<!-- 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" />
{{ $t("Save") }}
</button>
Expand Down Expand Up @@ -157,7 +157,7 @@
<!-- Admin functions -->
<div v-if="hasToken" class="mb-4">
<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" />
{{ $t("Edit Status Page") }}
</button>
Expand All @@ -169,25 +169,25 @@
</div>

<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" />
{{ $t("Create Incident") }}
</button>
</div>
</div>

<!-- 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>
<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>
<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">
{{ $t("markdownSupported") }}
</div>
<!-- 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 -->
<div class="date mt-3">
Expand All @@ -198,7 +198,7 @@
</div>

<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" />
{{ $t("Post") }}
</button>
Expand Down Expand Up @@ -283,13 +283,13 @@

<!-- Description -->
<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-->
<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>
<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" />
{{ $t("Add Group") }}
</button>
Expand All @@ -307,6 +307,7 @@
label="name"
trackBy="name"
class="mt-3"
data-testid="monitor-select"
>
<template #option="{ option }">
<div class="d-inline-flex">
Expand Down Expand Up @@ -334,17 +335,17 @@
<div class="custom-footer-text text-start">
<strong v-if="enableEditMode">{{ $t("Custom Footer") }}:</strong>
</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-->
<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>
</p>

<div class="refresh-info mb-2">
<div>{{ $t("Last Updated") }}: {{ lastUpdateTimeDisplay }}</div>
<div>{{ $tc("statusPageRefreshIn", [ updateCountdownText]) }}</div>
<div data-testid="update-countdown-text">{{ $tc("statusPageRefreshIn", [ updateCountdownText]) }}</div>
</div>
</footer>
</div>
Expand Down
Loading

0 comments on commit c567e8e

Please sign in to comment.