Skip to content

Commit 0336bf9

Browse files
committed
Acceptance tests for configuration
1 parent 2b77359 commit 0336bf9

File tree

6 files changed

+103
-67
lines changed

6 files changed

+103
-67
lines changed

src/Frontend/src/components/configuration/PlatformLicense.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,22 @@ const loading = computed(() => {
3131
<div class="box">
3232
<div class="row">
3333
<div class="license-info">
34-
<div><b>Platform license type:</b> <span role="displayText" aria-label="license-type">{{ license.license_type }}{{ license.licenseEdition }}</span></div>
34+
<div>
35+
<b>Platform license type:</b> <span role="note" aria-label="license-type">{{ license.license_type }}{{ license.licenseEdition }}</span>
36+
</div>
3537

3638
<template v-if="licenseStatus.isSubscriptionLicense">
3739
<div>
3840
<b>License expiry date: </b>
3941
<span
42+
role="note"
43+
aria-label="licenseExpiryDate"
4044
:class="{
4145
'license-expired': licenseStatus.isPlatformExpired,
4246
}"
4347
>
4448
{{ license.formattedExpirationDate }}
45-
{{ licenseStatus.subscriptionDaysLeft }}
49+
<span role="note" aria-label="licenseExpiryDaysLeft">{{ licenseStatus.subscriptionDaysLeft }}</span>
4650
<exclamation-mark :type="convertToWarningLevel(licenseStatus.warningLevel)" />
4751
</span>
4852
<div class="license-expired-text" v-if="licenseStatus.isPlatformExpired">Your license expired. Please update the license to continue using the Particular Service Platform.</div>

src/Frontend/test/mocks/license-response-template.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import LicenseInfo, { LicenseStatus } from "@/resources/LicenseInfo";
33
export const activeLicenseResponse = <LicenseInfo>{
44
registered_to: "ACME Software",
55
edition: "Enterprise",
6-
expiration_date: "",
7-
upgrade_protection_expiration: "2050-01-01T00:00:00.0000000Z",
6+
expiration_date: "2026-01-23T00:00:00.0000000Z",
7+
upgrade_protection_expiration: "",
88
license_type: "Commercial",
99
instance_name: "Particular.ServiceControl",
1010
trial_license: false,
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { screen } from "@testing-library/vue";
2+
3+
export async function licenseExpiryDate() {
4+
const licenseExpiryDate = await screen.findByRole("note", { name: "licenseExpiryDate" });
5+
console.log(licenseExpiryDate.textContent);
6+
return licenseExpiryDate.textContent;
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { screen } from "@testing-library/vue";
2+
3+
export async function licenseExpiryDaysLeft() {
4+
const licenseExpiryDaysLeft = await screen.findByRole("note", { name: "licenseExpiryDaysLeft" });
5+
console.log(licenseExpiryDaysLeft.textContent);
6+
return licenseExpiryDaysLeft.textContent;
7+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { screen } from "@testing-library/vue";
22

33
export async function licenseTypeDetails() {
4-
const licenseType = await screen.findByRole("displayText", { name: "license-type" });
4+
const licenseType = await screen.findByRole("note", { name: "license-type" });
55
return licenseType.textContent;
66
}
Lines changed: 80 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,99 @@
1-
import { expect, vi } from "vitest";
1+
import { expect } from "vitest";
22
import { test, describe } from "../../drivers/vitest/driver";
33
import * as precondition from "../../preconditions";
44
import { licenseTypeDetails } from "./questions/licenseTypeDetails";
5+
import { licenseExpiryDate } from "./questions/licenseExpiryDate";
6+
import { licenseExpiryDaysLeft } from "./questions/licenseExpiryDaysLeft";
7+
import { waitFor } from "@testing-library/vue";
58

69
describe("FEATURE: License", () => {
710
describe("RULE: Platform license type should be shown shown", () => {
811
test("EXAMPLE: Valid platform license type should be shown", async ({ driver }) => {
9-
10-
/* SCENARIO
11-
Given the platform license is valid
12-
Then the platform license type is shown
13-
*/
12+
await driver.setUp(precondition.serviceControlWithMonitoring);
1413
await driver.setUp(precondition.hasActiveLicense);
1514
await driver.goTo("/configuration/license");
16-
17-
expect(await licenseTypeDetails()).toBe("Commercial, Enterprise");
18-
19-
20-
15+
waitFor(async () => {
16+
expect(await licenseTypeDetails()).toBe("Commercial, Enterprise");
17+
});
2118
});
22-
describe("RULE: License expiry date should be shown", () => {
23-
test.todo("EXAMPLE: Valid license expiry date should be shown");
24-
25-
/* SCENARIO
26-
Given a valid platform license
27-
Then the license expiry date is shown
28-
*/
19+
});
20+
describe("RULE: License expiry date should be shown", () => {
21+
test("EXAMPLE: Valid license expiry date should be shown", async ({ driver }) => {
22+
await driver.setUp(precondition.serviceControlWithMonitoring);
23+
await driver.setUp(precondition.hasActiveLicense);
24+
await driver.goTo("/configuration/license");
25+
waitFor(async () => {
26+
expect(await licenseExpiryDate()).toBeVisible();
27+
});
2928
});
30-
describe("RULE: Remaining license period should be displayed", () => {
31-
test.todo("EXAMPLE: An expired license should show 'expired'");
32-
33-
/* SCENARIO
29+
});
30+
describe("RULE: Remaining license period should be displayed", () => {
31+
test.todo("EXAMPLE: An expired license should show 'expired'");
32+
/* SCENARIO
3433
Expired license
35-
34+
3635
Given an expired platform license
37-
Then "expired" is shown
38-
*/
39-
40-
test.todo("EXAMPLE: License expiring with 10 days should show 'expiring in X days'");
41-
/* SCENARIO
42-
License expiring soon
43-
44-
Given a platform license with an expiry date within 10 days
45-
Then "expiring in X days" is shown
36+
Then "expired" is shown
4637
*/
47-
48-
test.todo("EXAMPLE: License expiring tomorrow should show 'expiring tomorrow'");
49-
/* SCENARIO
50-
License expiring tomorrow
51-
52-
Given a platform license which expires tomorrow
53-
Then "expiring tomorrow" is shown
54-
*/
55-
56-
test.todo("EXAMPLE: License expiring today should show 'expiring today'");
57-
/* SCENARIO
58-
License expiring today
59-
60-
Given a platform license which expires today
61-
Then "expiring today" is shown
62-
*/
63-
64-
test.todo("EXAMPLE: License expiring in more than 10 days should show 'X days left");
38+
});
39+
describe("RULE: License expiring soon must be displayed", () => {
40+
test("EXAMPLE: License expiring with 10 days should show 'expiring in X days'", async ({ driver }) => {
6541
/* SCENARIO
66-
License expiring in the future
67-
68-
Given a platform license which expires more than 10 days from now
69-
Then "X days left" is shown
70-
*/
42+
License expiring soon
43+
44+
Given a platform license with an expiry date within 10 days
45+
Then "expiring in X days" is shown
46+
*/
47+
await driver.setUp(precondition.serviceControlWithMonitoring);
48+
const x = precondition.hasExpiringLicense(precondition.LicenseType.Subscription);
49+
console.log(x);
50+
await driver.setUp(precondition.hasExpiringLicense(precondition.LicenseType.Subscription));
51+
await driver.goTo("/configuration/license");
52+
waitFor(async () => {
53+
expect(await licenseExpiryDaysLeft()).toBeVisible();
54+
});
7155
});
72-
describe("RULE: Non-license options should be hidden if license has expired", () => {
73-
test.todo("EXAMPLE: Only 'LICENSE' tab is visible when license has expired");
74-
56+
});
57+
describe("RULE: ABC", () => {
58+
test.todo("EXAMPLE: License expiring tomorrow should show 'expiring tomorrow'");
59+
/* SCENARIO
60+
License expiring tomorrow
61+
62+
Given a platform license which expires tomorrow
63+
Then "expiring tomorrow" is shown
64+
*/
65+
});
66+
describe("RULE: EFG", () => {
67+
test.todo("EXAMPLE: License expiring today should show 'expiring today'");
68+
/* SCENARIO
69+
License expiring today
70+
71+
Given a platform license which expires today
72+
Then "expiring today" is shown
73+
*/
74+
});
75+
describe("RULE: Remaining license period should be displayed", () => {
76+
test("EXAMPLE: License expiring in more than 10 days should show 'X days left", async ({ driver }) => {
7577
/* SCENARIO
76-
Given an expired license
77-
Then "LICENSE" is the only visible tab in the Configuration screen
78-
*/
78+
License expiring in the future
79+
80+
Given a platform license which expires more than 10 days from now
81+
Then "X days left" is shown
82+
*/
83+
await driver.setUp(precondition.serviceControlWithMonitoring);
84+
await driver.setUp(precondition.hasActiveLicense);
85+
await driver.goTo("/configuration/license");
86+
waitFor(async () => {
87+
expect(await licenseExpiryDaysLeft()).toContain("days left");
88+
});
7989
});
8090
});
81-
});
91+
describe("RULE: Non-license options should be hidden if license has expired", () => {
92+
test.todo("EXAMPLE: Only 'LICENSE' tab is visible when license has expired");
93+
94+
/* SCENARIO
95+
Given an expired license
96+
Then "LICENSE" is the only visible tab in the Configuration screen
97+
*/
98+
});
99+
});

0 commit comments

Comments
 (0)