Skip to content

Commit 5f6bf60

Browse files
authored
Merge pull request #3732 from IntersectMBO/fix/proposal-sorting-test
Fix: proposal sorting test
2 parents 6f1c515 + cefdd7f commit 5f6bf60

File tree

6 files changed

+55
-24
lines changed

6 files changed

+55
-24
lines changed

tests/govtool-frontend/playwright/lib/helpers/transaction.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export async function waitForTxConfirmation(
7777
.getByTestId("alert-warning")
7878
.getByText("Transaction in progress", { exact: false })
7979
).toBeVisible({
80-
timeout: 60_000,
80+
timeout: 90_000,
8181
});
8282
const url = (await transactionStatusPromise).url();
8383
const regex = /\/transaction\/status\/([^\/]+)$/;
@@ -90,7 +90,7 @@ export async function waitForTxConfirmation(
9090
await pollTransaction(transactionHash);
9191
await expect(
9292
page.getByText("In Progress", { exact: true }).first() //FIXME: Only one element needs to be displayed
93-
).not.toBeVisible({ timeout: 60_000 });
93+
).not.toBeVisible({ timeout: 90_000 });
9494
}
9595
} catch (error) {
9696
Logger.fail(error.message);

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,11 @@ export default class BudgetDiscussionPage {
174174
// API validation
175175
for (let i = 0; i <= proposals.length - 2; i++) {
176176
const isValid = validationFn(proposals[i], proposals[i + 1]);
177-
expect(isValid).toBe(true);
177+
expect(isValid, {
178+
message:
179+
!isValid &&
180+
`Failed on sorting ${type} with proposals: ${proposals[i].id} and ${proposals[i + 1].id}`,
181+
}).toBe(true);
178182
}
179183
}
180184

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,11 @@ export default class ProposalDiscussionPage {
183183
// API validation
184184
for (let i = 0; i <= proposals.length - 2; i++) {
185185
const isValid = validationFn(proposals[i], proposals[i + 1]);
186-
expect(isValid).toBe(true);
186+
expect(isValid, {
187+
message:
188+
!isValid &&
189+
`Failed on sorting ${type} with proposals: ${proposals[i].id} and ${proposals[i + 1].id}`,
190+
}).toBe(true);
187191
}
188192
}
189193

tests/govtool-frontend/playwright/lib/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ export type ProposedGovAction = {
210210
attributes: {
211211
proposal_id: string;
212212
prop_name: string;
213+
createdAt: string;
213214
};
214215
};
215216
creator: {

tests/govtool-frontend/playwright/tests/11-proposal-budget/proposalBudget.spec.ts

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ test.describe("Budget proposal list manipulation", () => {
108108
});
109109

110110
test("11B_3. Should sort budget proposals", async () => {
111+
test.slow();
111112
const sortOptions = {
112113
Oldest: (p1: ProposedGovAction, p2: ProposedGovAction) =>
113114
p1.attributes.createdAt <= p2.attributes.createdAt,
@@ -120,21 +121,35 @@ test.describe("Budget proposal list manipulation", () => {
120121
p1.attributes.prop_comments_number <=
121122
p2.attributes.prop_comments_number,
122123
"Name A-Z": (p1: ProposedGovAction, p2: ProposedGovAction) =>
123-
p1.attributes.bd_proposal_detail.data.attributes.proposal_name.localeCompare(
124-
p2.attributes.bd_proposal_detail.data.attributes.proposal_name
125-
) <= 0,
124+
p1.attributes.bd_proposal_detail.data.attributes.proposal_name
125+
.replace(/ /g, "")
126+
.localeCompare(
127+
p2.attributes.bd_proposal_detail.data.attributes.proposal_name.replace(
128+
/ /g,
129+
""
130+
)
131+
) <= 0,
126132
"Name Z-A": (p1: ProposedGovAction, p2: ProposedGovAction) =>
127-
p1.attributes.bd_proposal_detail.data.attributes.proposal_name.localeCompare(
128-
p2.attributes.bd_proposal_detail.data.attributes.proposal_name
129-
) >= 0,
133+
p1.attributes.bd_proposal_detail.data.attributes.proposal_name
134+
.replace(/ /g, "")
135+
.localeCompare(
136+
p2.attributes.bd_proposal_detail.data.attributes.proposal_name.replace(
137+
/ /g,
138+
""
139+
)
140+
) >= 0,
130141
"Proposer A-Z": (p1: ProposedGovAction, p2: ProposedGovAction) =>
131-
p1.attributes.creator.data.attributes.govtool_username.localeCompare(
132-
p2.attributes.creator.data.attributes.govtool_username
133-
) <= 0,
142+
p1.attributes.creator.data.attributes.govtool_username
143+
.replace(/ /g, "")
144+
.localeCompare(
145+
p2.attributes.creator.data.attributes.govtool_username
146+
) <= 0,
134147
"Proposer Z-A": (p1: ProposedGovAction, p2: ProposedGovAction) =>
135-
p1.attributes.creator.data.attributes.govtool_username.localeCompare(
136-
p2.attributes.creator.data.attributes.govtool_username
137-
) >= 0,
148+
p1.attributes.creator.data.attributes.govtool_username
149+
.replace(/ /g, "")
150+
.localeCompare(
151+
p2.attributes.creator.data.attributes.govtool_username
152+
) >= 0,
138153
};
139154

140155
for (const [option, validationFn] of Object.entries(sortOptions)) {

tests/govtool-frontend/playwright/tests/8-proposal-discussion/proposalDiscussion.spec.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,14 @@ test.describe("Filter and sort proposals", () => {
6969
});
7070

7171
test("8B_2. Should sort the list of proposed governance actions.", async () => {
72+
test.slow();
7273
const sortOptions = {
7374
Oldest: (p1: ProposedGovAction, p2: ProposedGovAction) =>
74-
p1.attributes.createdAt <= p2.attributes.createdAt,
75+
p1.attributes.content.attributes.createdAt <=
76+
p2.attributes.content.attributes.createdAt,
7577
Newest: (p1: ProposedGovAction, p2: ProposedGovAction) =>
76-
p1.attributes.createdAt >= p2.attributes.createdAt,
78+
p1.attributes.content.attributes.createdAt >=
79+
p2.attributes.content.attributes.createdAt,
7780
"Most likes": (p1: ProposedGovAction, p2: ProposedGovAction) =>
7881
p1.attributes.prop_likes >= p2.attributes.prop_likes,
7982
"Least likes": (p1: ProposedGovAction, p2: ProposedGovAction) =>
@@ -89,13 +92,17 @@ test.describe("Filter and sort proposals", () => {
8992
p1.attributes.prop_comments_number <=
9093
p2.attributes.prop_comments_number,
9194
"Name A-Z": (p1: ProposedGovAction, p2: ProposedGovAction) =>
92-
p1.attributes.content.attributes.prop_name.localeCompare(
93-
p2.attributes.content.attributes.prop_name
94-
) <= 0,
95+
p1.attributes.content.attributes.prop_name
96+
.replace(/ /g, "")
97+
.localeCompare(
98+
p2.attributes.content.attributes.prop_name.replace(/ /g, "")
99+
) <= 0,
95100
"Name Z-A": (p1: ProposedGovAction, p2: ProposedGovAction) =>
96-
p1.attributes.content.attributes.prop_name.localeCompare(
97-
p2.attributes.content.attributes.prop_name
98-
) >= 0,
101+
p1.attributes.content.attributes.prop_name
102+
.replace(/ /g, "")
103+
.localeCompare(
104+
p2.attributes.content.attributes.prop_name.replace(/ /g, "")
105+
) >= 0,
99106
};
100107

101108
for (const [sortOption, sortFunction] of Object.entries(sortOptions)) {

0 commit comments

Comments
 (0)