Skip to content

Commit f82d26d

Browse files
committed
check for DOM element visibility
1 parent e994606 commit f82d26d

File tree

4 files changed

+23
-25
lines changed

4 files changed

+23
-25
lines changed

src/Frontend/test/preconditions/licensing.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const getLicenseMockedResponse =
6060

6161
const response = {
6262
...licenseResponseTemplate,
63-
license_type: licenseType,
63+
license_type: status === LicenseStatus.ValidWithExpiringTrial || status === LicenseStatus.InvalidDueToExpiredTrial ? "Trial" : "Commercial",
6464
trial_license: trialLicense,
6565
expiration_date: expirationDate,
6666
upgrade_protection_expiration: upgradeProtectionExpiration,
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { screen } from "@testing-library/vue";
22

33
export async function licenseExpiryDate() {
4-
const licenseExpiryDate = await screen.findByRole("note", { name: "license-expiry-date" });
5-
return licenseExpiryDate.textContent?.trim;
4+
const licenseExpiryDateElement = await screen.findByRole("note", { name: "license-expiry-date" });
5+
return licenseExpiryDateElement;
66
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { screen } from "@testing-library/vue";
22

33
export async function licenseExpiryDaysLeft() {
4-
const licenseExpiryDaysLeft = await screen.findByRole("note", { name: "license-days-left" });
5-
return licenseExpiryDaysLeft.textContent?.trim;
4+
const licenseExpiryDaysLeftElement = await screen.findByRole("note", { name: "license-days-left" });
5+
return licenseExpiryDaysLeftElement;
66
}

src/Frontend/test/specs/configuration/viewing-license.spec.ts

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ describe("FEATURE: License", () => {
4040
expect(await licenseExpired()).toBe("Your license expired. Please update the license to continue using the Particular Service Platform.");
4141
});
4242
});
43+
test.todo("EXAMPLE: Only 'LICENSE' tab is visible when license has expired");
44+
45+
/* SCENARIO
46+
Given an expired license
47+
Then "LICENSE" is the only visible tab in the Configuration screen
48+
*/
4349
});
4450

4551
describe("RULE: License expiring soon must be displayed", () => {
@@ -48,26 +54,26 @@ describe("FEATURE: License", () => {
4854
await driver.setUp(precondition.hasExpiringLicense(LicenseType.Subscription, 10));
4955
await driver.goTo("/configuration/license");
5056
await waitFor(async () => {
51-
// expect(await licenseExpiryDaysLeft()).toBeVisible(); //License expiry date: 2/5/2025 - expiring in 11 days
52-
expect(await licenseExpiryDaysLeft()).toContain("expiring in"); //License expiry date: 2/5/2025 - expiring in 11 days
57+
expect(await licenseExpiryDaysLeft()).toBeVisible(); //License expiry date: 2/5/2025 - expiring in 11 days
58+
expect((await licenseExpiryDaysLeft()).textContent).toContain("expiring in"); //License expiry date: 2/5/2025 - expiring in 11 days
5359
});
5460
});
5561
test("EXAMPLE: License expiring tomorrow should show 'expiring tomorrow'", async ({ driver }) => {
5662
await driver.setUp(precondition.serviceControlWithMonitoring);
5763
await driver.setUp(precondition.hasExpiringLicense(LicenseType.Subscription, 0));
5864
await driver.goTo("/configuration/license");
5965
await waitFor(async () => {
60-
// expect(await licenseExpiryDaysLeft()).toBeVisible();
61-
expect(await licenseExpiryDaysLeft()).toContain("expiring tomorrow");
66+
expect(await licenseExpiryDaysLeft()).toBeVisible();
67+
expect((await licenseExpiryDaysLeft()).textContent).toContain("expiring tomorrow");
6268
});
6369
});
6470
test("EXAMPLE: License expiring today should show 'expiring today'", async ({ driver }) => {
6571
await driver.setUp(precondition.serviceControlWithMonitoring);
6672
await driver.setUp(precondition.hasExpiringLicense(LicenseType.Subscription, -1));
6773
await driver.goTo("/configuration/license");
6874
await waitFor(async () => {
69-
//expect(await licenseExpiryDaysLeft()).toBeVisible();
70-
expect(await licenseExpiryDaysLeft()).toContain("expiring today");
75+
expect(await licenseExpiryDaysLeft()).toBeVisible();
76+
expect((await licenseExpiryDaysLeft()).textContent).toContain("expiring today");
7177
});
7278
});
7379
});
@@ -78,35 +84,27 @@ describe("FEATURE: License", () => {
7884
await driver.setUp(precondition.hasExpiringLicense(LicenseType.UpgradeProtection, 10));
7985
await driver.goTo("/configuration/license");
8086
await waitFor(async () => {
81-
// expect(await licenseExpiryDaysLeft()).toBeVisible(); //License expiry date: 2/5/2025 - expiring in 11 days
82-
expect(await licenseExpiryDaysLeft()).toContain("days left"); //License expiry date: 2/5/2025 - expiring in 11 days
87+
expect(await licenseExpiryDaysLeft()).toBeVisible(); //License expiry date: 2/5/2025 - expiring in 11 days
88+
expect((await licenseExpiryDaysLeft()).textContent).toContain("days left"); //License expiry date: 2/5/2025 - expiring in 11 days
8389
});
8490
});
8591
test("EXAMPLE: Upgrade Protection license expiring tomorrow should show 'expiring tomorrow'", async ({ driver }) => {
8692
await driver.setUp(precondition.serviceControlWithMonitoring);
8793
await driver.setUp(precondition.hasExpiringLicense(LicenseType.UpgradeProtection, 0));
8894
await driver.goTo("/configuration/license");
8995
await waitFor(async () => {
90-
// expect(await licenseExpiryDaysLeft()).toBeVisible();
91-
expect(await licenseExpiryDaysLeft()).toContain("1 day left");
96+
expect(await licenseExpiryDaysLeft()).toBeVisible();
97+
expect((await licenseExpiryDaysLeft()).textContent).toContain("1 day left");
9298
});
9399
});
94100
test("EXAMPLE: Upgrade Protection license expiring today should show 'expired'", async ({ driver }) => {
95101
await driver.setUp(precondition.serviceControlWithMonitoring);
96102
await driver.setUp(precondition.hasExpiringLicense(LicenseType.UpgradeProtection, -1));
97103
await driver.goTo("/configuration/license");
98104
await waitFor(async () => {
99-
//expect(await licenseExpiryDaysLeft()).toBeVisible();
100-
expect(await licenseExpiryDaysLeft()).toContain("expired");
105+
expect(await licenseExpiryDaysLeft()).toBeVisible();
106+
expect((await licenseExpiryDaysLeft()).textContent).toContain("expired");
101107
});
102108
});
103109
});
104-
describe("RULE: Non-license options should be hidden if license has expired", () => {
105-
test.todo("EXAMPLE: Only 'LICENSE' tab is visible when license has expired");
106-
107-
/* SCENARIO
108-
Given an expired license
109-
Then "LICENSE" is the only visible tab in the Configuration screen
110-
*/
111-
});
112110
});

0 commit comments

Comments
 (0)