Skip to content

Commit fad8bba

Browse files
test: add alert module tests for different welcome_message configurations (#3867)
In this way, all options for `welcome_message` are tested.
1 parent 4c0a468 commit fad8bba

File tree

5 files changed

+80
-8
lines changed

5 files changed

+80
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Thanks to: @dathbe.
3434
- Simplify DOM setup by removing unnecessary Promise/async patterns
3535
- Avoid potential port conflicts by using port 3001 for translator unit tests
3636
- Improve test reliability and maintainability
37+
- [tests] add alert module tests for different welcome_message configurations (#3867)
3738

3839
### Updated
3940

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
let config = {
2+
address: "0.0.0.0",
3+
ipWhitelist: [],
4+
modules: [
5+
{
6+
module: "alert",
7+
config: {
8+
display_time: 1000000,
9+
welcome_message: false
10+
}
11+
}
12+
]
13+
};
14+
15+
/*************** DO NOT EDIT THE LINE BELOW ***************/
16+
if (typeof module !== "undefined") {
17+
module.exports = config;
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
let config = {
2+
address: "0.0.0.0",
3+
ipWhitelist: [],
4+
modules: [
5+
{
6+
module: "alert",
7+
config: {
8+
display_time: 1000000,
9+
welcome_message: "Custom welcome message!"
10+
}
11+
}
12+
]
13+
};
14+
15+
/*************** DO NOT EDIT THE LINE BELOW ***************/
16+
if (typeof module !== "undefined") {
17+
module.exports = config;
18+
}
File renamed without changes.

tests/e2e/modules/alert_spec.js

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,52 @@
11
const helpers = require("../helpers/global-setup");
22

33
describe("Alert module", () => {
4-
beforeAll(async () => {
5-
await helpers.startApplication("tests/configs/modules/alert/default.js");
6-
await helpers.getDocument();
7-
});
84
afterAll(async () => {
95
await helpers.stopApplication();
106
});
117

12-
it("should show the welcome message", async () => {
13-
const elem = await helpers.waitForElement(".ns-box .ns-box-inner .light.bright.small");
14-
expect(elem).not.toBeNull();
15-
expect(elem.textContent).toContain("Welcome, start was successful!");
8+
describe("with welcome_message set to false", () => {
9+
beforeAll(async () => {
10+
await helpers.startApplication("tests/configs/modules/alert/welcome_false.js");
11+
await helpers.getDocument();
12+
});
13+
14+
it("should not show any welcome message", async () => {
15+
// Wait a bit to ensure no message appears
16+
await new Promise((resolve) => setTimeout(resolve, 1000));
17+
18+
// Check that no alert/notification elements are present
19+
const alertElements = document.querySelectorAll(".ns-box .ns-box-inner .light.bright.small");
20+
expect(alertElements).toHaveLength(0);
21+
});
22+
});
23+
24+
describe("with welcome_message set to true", () => {
25+
beforeAll(async () => {
26+
await helpers.startApplication("tests/configs/modules/alert/welcome_true.js");
27+
await helpers.getDocument();
28+
29+
// Wait for the application to initialize
30+
await new Promise((resolve) => setTimeout(resolve, 1000));
31+
});
32+
33+
it("should show the translated welcome message", async () => {
34+
const elem = await helpers.waitForElement(".ns-box .ns-box-inner .light.bright.small");
35+
expect(elem).not.toBeNull();
36+
expect(elem.textContent).toContain("Welcome, start was successful!");
37+
});
38+
});
39+
40+
describe("with welcome_message set to custom string", () => {
41+
beforeAll(async () => {
42+
await helpers.startApplication("tests/configs/modules/alert/welcome_string.js");
43+
await helpers.getDocument();
44+
});
45+
46+
it("should show the custom welcome message", async () => {
47+
const elem = await helpers.waitForElement(".ns-box .ns-box-inner .light.bright.small");
48+
expect(elem).not.toBeNull();
49+
expect(elem.textContent).toContain("Custom welcome message!");
50+
});
1651
});
1752
});

0 commit comments

Comments
 (0)