Skip to content

Commit af439d8

Browse files
committed
Fix flaky sorting tests
1 parent df6437d commit af439d8

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

src/Frontend/test/specs/monitoring/sorting-endpoints.spec.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { expect } from "vitest";
22
import { test, describe } from "../../drivers/vitest/driver";
3+
import { waitFor } from "@testing-library/vue";
34
import { groupEndpointsBy } from "./actions/groupEndpointsBy";
45
import { endpointGroupNames } from "./questions/endpointGroupNames";
56
import { endpointGroup } from "./questions/endpointGroup";
@@ -68,10 +69,12 @@ describe("FEATURE: Endpoint sorting", () => {
6869
await sortEndpointsBy({ column: columnName.ENDPOINTNAME });
6970

7071
//Assert
71-
expect(endpointGroupNames()).toEqual(["Universe.Solarsystem.Venus", "Universe.Solarsystem.Mercury", "Universe.Solarsystem.Earth"]);
72-
expect(endpointGroup("Universe.Solarsystem.Venus").Endpoints).toEqual(["Endpoint4", "Endpoint3"]);
73-
expect(endpointGroup("Universe.Solarsystem.Mercury").Endpoints).toEqual(["Endpoint2", "Endpoint1"]);
74-
expect(endpointGroup("Universe.Solarsystem.Earth").Endpoints).toEqual(["Endpoint6", "Endpoint5"]);
72+
await waitFor(() => {
73+
expect(endpointGroupNames()).toEqual(["Universe.Solarsystem.Venus", "Universe.Solarsystem.Mercury", "Universe.Solarsystem.Earth"]);
74+
expect(endpointGroup("Universe.Solarsystem.Venus").Endpoints).toEqual(["Endpoint4", "Endpoint3"]);
75+
expect(endpointGroup("Universe.Solarsystem.Mercury").Endpoints).toEqual(["Endpoint2", "Endpoint1"]);
76+
expect(endpointGroup("Universe.Solarsystem.Earth").Endpoints).toEqual(["Endpoint6", "Endpoint5"]);
77+
});
7578
});
7679

7780
test("EXAMPLE: Endpoints inside of the groups and group names should be sorted in ascending order when clicking twice on the endpoint name column title", async ({ driver }) => {
@@ -95,10 +98,12 @@ describe("FEATURE: Endpoint sorting", () => {
9598
await sortEndpointsBy({ column: columnName.ENDPOINTNAME }); //Click the column title again for ascending
9699

97100
//Assert
98-
expect(endpointGroupNames()).toEqual(["Universe.Solarsystem.Earth", "Universe.Solarsystem.Mercury", "Universe.Solarsystem.Venus"]);
99-
expect(endpointGroup("Universe.Solarsystem.Earth").Endpoints).toEqual(["Endpoint5", "Endpoint6"]);
100-
expect(endpointGroup("Universe.Solarsystem.Mercury").Endpoints).toEqual(["Endpoint1", "Endpoint2"]);
101-
expect(endpointGroup("Universe.Solarsystem.Venus").Endpoints).toEqual(["Endpoint3", "Endpoint4"]);
101+
await waitFor(() => {
102+
expect(endpointGroupNames()).toEqual(["Universe.Solarsystem.Earth", "Universe.Solarsystem.Mercury", "Universe.Solarsystem.Venus"]);
103+
expect(endpointGroup("Universe.Solarsystem.Earth").Endpoints).toEqual(["Endpoint5", "Endpoint6"]);
104+
expect(endpointGroup("Universe.Solarsystem.Mercury").Endpoints).toEqual(["Endpoint1", "Endpoint2"]);
105+
expect(endpointGroup("Universe.Solarsystem.Venus").Endpoints).toEqual(["Endpoint3", "Endpoint4"]);
106+
});
102107
});
103108
});
104109

0 commit comments

Comments
 (0)