Skip to content

Commit 421f155

Browse files
committed
Fix a test
1 parent 0972e5c commit 421f155

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

src/Frontend/src/components/TimeSince.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ onUnmounted(() => window.clearInterval(interval));
3939
<template #content>
4040
<div v-for="row in title" :key="row">{{ row }}</div>
4141
</template>
42-
<span>{{ text }}</span>
42+
<span role="timer" :aria-label="title.join('\n')">{{ text }}</span>
4343
</Tippy>
4444
</template>

src/Frontend/src/components/customchecks/CustomCheckView.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const store = useCustomChecksStore();
2323
<span class="metadata"><i aria-hidden="true" class="fa fa-list"></i> Category: {{ customCheck.category }}</span>
2424
<span class="metadata"><i aria-hidden="true" class="fa pa-endpoint"></i> Endpoint: {{ customCheck.originating_endpoint.name }}</span>
2525
<span class="metadata"><i aria-hidden="true" class="fa fa-server"></i> Host: {{ customCheck.originating_endpoint.host }}</span>
26-
<span class="metadata"><i aria-hidden="true" class="fa fa-clock-o"></i> Last checked: <TimeSince :date-utc="customCheck.reported_at" role="note" aria-label="custom-check-reported-date"></TimeSince></span>
26+
<span class="metadata" role="note" aria-label="custom-check-reported-date"><i aria-hidden="true" class="fa fa-clock-o"></i> Last checked: <TimeSince :date-utc="customCheck.reported_at"></TimeSince></span>
2727
</p>
2828
</div>
2929
</div>

src/Frontend/test/specs/customchecks/questions/failedCustomChecks.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { screen } from "@testing-library/vue";
1+
import { screen, within } from "@testing-library/vue";
22
import moment from "moment";
33

44
export function customChecksMessageElement() {
@@ -25,11 +25,13 @@ export function customChecksListPaginationElement() {
2525
const customChecksListPaginationElement = screen.queryByRole("row", { name: "custom-check-pagination" });
2626
return customChecksListPaginationElement;
2727
}
28-
export async function customChecksReportedDateList() {
29-
const timeElements = await screen.getAllByRole("note", { name: "custom-check-reported-date" });
28+
export function customChecksReportedDateList() {
29+
const timeElements = screen.getAllByRole("note", { name: "custom-check-reported-date" });
3030

3131
const timeStamps = timeElements.map((el) => {
32-
const utcDateString = el.title.match(/(\w+day, \w+ \d+, \d+ \d+:\d+ [APM]+ \(UTC\))/);
32+
const utcDateString = within(el)
33+
.getByRole("timer")
34+
?.ariaLabel?.match(/(\w+day, \w+ \d+, \d+ \d+:\d+ [APM]+ \(UTC\))/);
3335

3436
const finalUtcString = utcDateString ? utcDateString[0] : moment.utc().format("dddd, MMMM D, YYYY h:mm A (UTC)");
3537

src/Frontend/test/specs/customchecks/viewing-failing-custom-checks.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ describe("FEATURE: Failing custom checks", () => {
7272
});
7373
});
7474
describe("RULE: Failed custom checks should be shown in descending order of last checked", () => {
75-
test("EXAMPLE:Three failed custom checks is displayed in descending order of last checked on the custom checks tab", async ({ driver }) => {
75+
test("EXAMPLE:Three failed custom checks are displayed in descending order of last checked on the custom checks tab", async ({ driver }) => {
7676
const failingCustomCheckCount = 5;
7777
const passingCustomCheckCount = 3;
7878

@@ -82,13 +82,13 @@ describe("FEATURE: Failing custom checks", () => {
8282
await driver.goTo("/custom-checks");
8383

8484
await waitFor(async () => {
85-
expect(await customChecksListElement()).toBeInTheDocument(); //failed list is visisble
85+
expect(await customChecksListElement()).toBeInTheDocument(); //failed list is visible
8686
});
8787
await waitFor(async () => {
8888
expect(await customChecksFailedRowsList()).toHaveLength(failingCustomCheckCount); //count of failed checks matches failing count set
8989
});
9090

91-
const timestamps = await customChecksReportedDateList(); // Ensure this is awaited correctly
91+
const timestamps = customChecksReportedDateList(); // Ensure this is awaited correctly
9292

9393
// Ensure that the times are in descending order
9494
for (let i = 0; i < timestamps.length - 1; i++) {

0 commit comments

Comments
 (0)