Skip to content

Commit 25ca7f3

Browse files
authored
Merge pull request #3748 from IntersectMBO/test
v2.0.25
2 parents 40f2739 + 5a73ac6 commit 25ca7f3

File tree

10 files changed

+133
-48
lines changed

10 files changed

+133
-48
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ changes.
1616

1717
### Fixed
1818

19+
- Fix blank page on dRep details when link or identity references contain objects: { @value: ... } not strings [Issue 3733](https://github.com/IntersectMBO/govtool/issues/3733)
1920
- Fix missing off chain references in DRep details [Issue 3490](https://github.com/IntersectMBO/govtool/issues/3490)
2021
- Fix blank screen and type error on linkReferences when navigating to edit dRep page that has no links [Issue 3714](https://github.com/IntersectMBO/govtool/issues/3714)
2122
- Fix adding two link input fields when editing the dRep form when no links are present initially [Issue 3709](https://github.com/IntersectMBO/govtool/issues/3709)

govtool/backend/sql/list-dreps.sql

Lines changed: 71 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ HasNonDeregisterVotingAnchor AS (
9595
EXISTS (
9696
SELECT 1
9797
FROM drep_registration dr_sub
98-
WHERE
98+
WHERE
9999
dr_sub.drep_hash_id = dr.drep_hash_id
100100
AND dr_sub.voting_anchor_id IS NULL
101101
AND COALESCE(dr_sub.deposit, 0) >= 0
@@ -129,12 +129,24 @@ DRepData AS (
129129
off_chain_vote_drep_data.image_hash,
130130
COALESCE(
131131
(
132-
SELECT jsonb_agg(ref)
132+
SELECT jsonb_agg(
133+
jsonb_build_object(
134+
'uri', COALESCE(
135+
CASE WHEN jsonb_typeof(ref->'uri') = 'string' THEN ref->>'uri' END,
136+
ref->'uri'->>'@value'
137+
),
138+
'@type', ref->>'@type',
139+
'label', COALESCE(
140+
CASE WHEN jsonb_typeof(ref->'label') = 'string' THEN ref->>'label' END,
141+
ref->'label'->>'@value'
142+
)
143+
)
144+
)
133145
FROM jsonb_array_elements(
134-
CASE
135-
WHEN (ocvd.json::jsonb)->'body'->'references' IS NOT NULL
136-
THEN (ocvd.json::jsonb)->'body'->'references'
137-
ELSE '[]'::jsonb
146+
CASE
147+
WHEN (ocvd.json::jsonb)->'body'->'references' IS NOT NULL
148+
THEN (ocvd.json::jsonb)->'body'->'references'
149+
ELSE '[]'::jsonb
138150
END
139151
) AS ref
140152
WHERE ref->>'@type' = 'Identity'
@@ -143,12 +155,24 @@ DRepData AS (
143155
) AS identity_references,
144156
COALESCE(
145157
(
146-
SELECT jsonb_agg(ref)
158+
SELECT jsonb_agg(
159+
jsonb_build_object(
160+
'uri', COALESCE(
161+
CASE WHEN jsonb_typeof(ref->'uri') = 'string' THEN ref->>'uri' END,
162+
ref->'uri'->>'@value'
163+
),
164+
'@type', ref->>'@type',
165+
'label', COALESCE(
166+
CASE WHEN jsonb_typeof(ref->'label') = 'string' THEN ref->>'label' END,
167+
ref->'label'->>'@value'
168+
)
169+
)
170+
)
147171
FROM jsonb_array_elements(
148-
CASE
149-
WHEN (ocvd.json::jsonb)->'body'->'references' IS NOT NULL
150-
THEN (ocvd.json::jsonb)->'body'->'references'
151-
ELSE '[]'::jsonb
172+
CASE
173+
WHEN (ocvd.json::jsonb)->'body'->'references' IS NOT NULL
174+
THEN (ocvd.json::jsonb)->'body'->'references'
175+
ELSE '[]'::jsonb
152176
END
153177
) AS ref
154178
WHERE ref->>'@type' = 'Link'
@@ -185,7 +209,7 @@ DRepData AS (
185209
LEFT JOIN FetchError fetch_error ON fetch_error.voting_anchor_id = leva.voting_anchor_id
186210
LEFT JOIN HasNonDeregisterVotingAnchor hndva ON hndva.drep_hash_id = dh.id
187211
LEFT JOIN off_chain_vote_data ocvd ON ocvd.voting_anchor_id = leva.voting_anchor_id
188-
LEFT JOIN off_chain_vote_drep_data ON off_chain_vote_drep_data.off_chain_vote_data_id = ocvd.id
212+
LEFT JOIN off_chain_vote_drep_data ON off_chain_vote_drep_data.off_chain_vote_data_id = ocvd.id
189213
LEFT JOIN voting_procedure ON voting_procedure.drep_voter = dh.id
190214
LEFT JOIN tx voting_procedure_transaction ON voting_procedure_transaction.id = voting_procedure.tx_id
191215
LEFT JOIN block voting_procedure_block ON voting_procedure_block.id = voting_procedure_transaction.block_id
@@ -242,23 +266,47 @@ DRepData AS (
242266
off_chain_vote_drep_data.image_url,
243267
off_chain_vote_drep_data.image_hash,
244268
(
245-
SELECT jsonb_agg(ref)
269+
SELECT jsonb_agg(
270+
jsonb_build_object(
271+
'uri', COALESCE(
272+
CASE WHEN jsonb_typeof(ref->'uri') = 'string' THEN ref->>'uri' END,
273+
ref->'uri'->>'@value'
274+
),
275+
'@type', ref->>'@type',
276+
'label', COALESCE(
277+
CASE WHEN jsonb_typeof(ref->'label') = 'string' THEN ref->>'label' END,
278+
ref->'label'->>'@value'
279+
)
280+
)
281+
)
246282
FROM jsonb_array_elements(
247-
CASE
248-
WHEN (ocvd.json::jsonb)->'body'->'references' IS NOT NULL
249-
THEN (ocvd.json::jsonb)->'body'->'references'
250-
ELSE '[]'::jsonb
283+
CASE
284+
WHEN (ocvd.json::jsonb)->'body'->'references' IS NOT NULL
285+
THEN (ocvd.json::jsonb)->'body'->'references'
286+
ELSE '[]'::jsonb
251287
END
252288
) AS ref
253289
WHERE ref->>'@type' = 'Identity'
254290
),
255291
(
256-
SELECT jsonb_agg(ref)
292+
SELECT jsonb_agg(
293+
jsonb_build_object(
294+
'uri', COALESCE(
295+
CASE WHEN jsonb_typeof(ref->'uri') = 'string' THEN ref->>'uri' END,
296+
ref->'uri'->>'@value'
297+
),
298+
'@type', ref->>'@type',
299+
'label', COALESCE(
300+
CASE WHEN jsonb_typeof(ref->'label') = 'string' THEN ref->>'label' END,
301+
ref->'label'->>'@value'
302+
)
303+
)
304+
)
257305
FROM jsonb_array_elements(
258-
CASE
259-
WHEN (ocvd.json::jsonb)->'body'->'references' IS NOT NULL
260-
THEN (ocvd.json::jsonb)->'body'->'references'
261-
ELSE '[]'::jsonb
306+
CASE
307+
WHEN (ocvd.json::jsonb)->'body'->'references' IS NOT NULL
308+
THEN (ocvd.json::jsonb)->'body'->'references'
309+
ELSE '[]'::jsonb
262310
END
263311
) AS ref
264312
WHERE ref->>'@type' = 'Link'
@@ -275,4 +323,4 @@ WHERE
275323
objectives ILIKE ? OR
276324
motivations ILIKE ? OR
277325
qualifications ILIKE ?
278-
)
326+
)

tests/govtool-frontend/playwright/lib/forms/dRepForm.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ export default class DRepForm {
166166
await this.identityReferenceFirstDescriptionInput.fill(
167167
dRepInfo.identityReferenceLinks[0].description
168168
);
169+
170+
await this.form.keyboard.press("Tab");
169171
}
170172

171173
async validateForm(dRepInfo: IDRepInfo) {

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/4-proposal-visibility/proposalVisibility.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ test("4H. Should verify none of the displayed governance actions have expired",
203203
async () => {
204204
const proposalCards = await govActionsPage.getAllProposals();
205205
for (const proposalCard of proposalCards) {
206+
await expect(proposalCard).toBeVisible();
206207
const expiryDateEl = proposalCard.getByTestId("expiry-date");
207208
const expiryDateTxt = await expiryDateEl.innerText();
208209
const expiryDate = extractExpiryDateFromText(expiryDateTxt);

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

Lines changed: 18 additions & 9 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)) {
@@ -149,7 +156,9 @@ test("8C. Should search the list of proposed governance actions.", async ({
149156
const proposalTitle = await proposalCard
150157
.locator('[data-testid^="proposal-"][data-testid$="-title"]')
151158
.innerText();
152-
expect(proposalTitle.trim()).toContain(proposalName.trim());
159+
expect(proposalTitle.toLowerCase().trim()).toContain(
160+
proposalName.toLowerCase().trim()
161+
);
153162
}
154163
},
155164
{

0 commit comments

Comments
 (0)