Skip to content

Commit c581c85

Browse files
committed
fix: wrap filter and sort validation with functionWaitedAssert
1 parent cfd329a commit c581c85

File tree

1 file changed

+44
-35
lines changed

1 file changed

+44
-35
lines changed

tests/govtool-frontend/playwright/lib/pages/governanceActionsPage.ts

Lines changed: 44 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { GovernanceActionType, IProposal } from "@types";
44
import environments from "lib/constants/environments";
55
import GovernanceActionDetailsPage from "./governanceActionDetailsPage";
66
import { getEnumKeyByValue } from "@helpers/enum";
7-
import { waitedLoop } from "@helpers/waitedLoop";
7+
import { functionWaitedAssert, waitedLoop } from "@helpers/waitedLoop";
88

99
const MAX_SLIDES_DISPLAY_PER_TYPE = 6;
1010

@@ -106,18 +106,20 @@ export default class GovernanceActionsPage {
106106
}
107107

108108
async validateFilters(filters: string[]) {
109-
const proposalCards = await this.getAllProposals();
110-
111-
for (const proposalCard of proposalCards) {
112-
const hasFilter = await this._validateFiltersInProposalCard(
113-
proposalCard,
114-
filters
115-
);
116-
expect(
117-
hasFilter,
118-
"A proposal card does not contain any of the filters"
119-
).toBe(true);
120-
}
109+
await functionWaitedAssert(async () => {
110+
const proposalCards = await this.getAllProposals();
111+
112+
for (const proposalCard of proposalCards) {
113+
const hasFilter = await this._validateFiltersInProposalCard(
114+
proposalCard,
115+
filters
116+
);
117+
expect(
118+
hasFilter,
119+
`A proposal card does not contain any of the ${filters}`
120+
).toBe(true);
121+
}
122+
});
121123
}
122124

123125
async sortProposal(option: string) {
@@ -167,29 +169,36 @@ export default class GovernanceActionsPage {
167169
this.page.getByRole("progressbar").getByRole("img")
168170
).toBeHidden({ timeout: 20_000 });
169171

170-
// Frontend validation
171-
for (let dIdx = 0; dIdx <= proposalsByType.length - 1; dIdx++) {
172-
const proposals = proposalsByType[0] as IProposal[];
173-
const filterOptionKey = getEnumKeyByValue(
174-
GovernanceActionType,
175-
proposals[0].type
176-
);
177-
178-
const slides = await this.page
179-
.locator(`[data-testid="govaction-${filterOptionKey}-card"]`)
180-
.all();
181-
182-
const actualSlidesInDisplay =
183-
proposals.length > MAX_SLIDES_DISPLAY_PER_TYPE
184-
? MAX_SLIDES_DISPLAY_PER_TYPE
185-
: proposals.length;
186-
187-
expect(slides).toHaveLength(actualSlidesInDisplay);
188-
189-
for (let i = 0; i <= slides.length - 1; i++) {
190-
await expect(slides[i]).toContainText(`${proposals[i].txHash}`);
172+
await functionWaitedAssert(
173+
async () => {
174+
// Frontend validation
175+
for (let dIdx = 0; dIdx <= proposalsByType.length - 1; dIdx++) {
176+
const proposals = proposalsByType[0] as IProposal[];
177+
const filterOptionKey = getEnumKeyByValue(
178+
GovernanceActionType,
179+
proposals[0].type
180+
);
181+
182+
const slides = await this.page
183+
.locator(`[data-testid="govaction-${filterOptionKey}-card"]`)
184+
.all();
185+
186+
const actualSlidesInDisplay =
187+
proposals.length > MAX_SLIDES_DISPLAY_PER_TYPE
188+
? MAX_SLIDES_DISPLAY_PER_TYPE
189+
: proposals.length;
190+
191+
expect(slides).toHaveLength(actualSlidesInDisplay);
192+
193+
for (let i = 0; i <= slides.length - 1; i++) {
194+
await expect(slides[i]).toContainText(`${proposals[i].txHash}`);
195+
}
196+
}
197+
},
198+
{
199+
name: `frontend sort validation of ${sortOption} and filter ${filterKeys}`,
191200
}
192-
}
201+
);
193202
}
194203

195204
async _validateFiltersInProposalCard(

0 commit comments

Comments
 (0)