Skip to content

Commit 8f6450a

Browse files
committed
fix ui tests [ci]
Signed-off-by: Paweł Perek <[email protected]>
1 parent 431aa7b commit 8f6450a

File tree

2 files changed

+20
-21
lines changed

2 files changed

+20
-21
lines changed

apps/sv/frontend/src/__tests__/governance/proposal-listing.test.tsx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -124,17 +124,17 @@ describe('Inflight Vote Requests', () => {
124124
const voteTakesEffect = screen.getByTestId(`${uniqueId}-row-vote-takes-effect`);
125125
expect(voteTakesEffect.textContent).toBe(data.voteTakesEffect);
126126

127-
const voteStats = screen.getByTestId(`${uniqueId}-row-vote-stats`);
128-
expect(voteStats.textContent).toBe('2 Accepted / 3 Rejected');
127+
const acceptedVoteStats = screen.getByTestId(`${uniqueId}-row-all-votes-stats-accepted`);
128+
expect(acceptedVoteStats.textContent).toBe('2 Accepted');
129+
130+
const rejectedVoteStats = screen.getByTestId(`${uniqueId}-row-all-votes-stats-rejected`);
131+
expect(rejectedVoteStats.textContent).toBe('3 Rejected');
129132

130133
const acceptanceThreshold = screen.getByTestId(`${uniqueId}-row-acceptance-threshold`);
131134
expect(acceptanceThreshold.textContent).toBe('11');
132135

133136
const yourVote = screen.getByTestId(`${uniqueId}-row-your-vote`);
134137
expect(yourVote.textContent).toMatch(/No Vote/);
135-
136-
const viewDetails = screen.getByTestId(`${uniqueId}-row-view-details`);
137-
expect(viewDetails).toBeDefined();
138138
});
139139

140140
test('should render Accepted inflight vote request', () => {
@@ -161,9 +161,9 @@ describe('Inflight Vote Requests', () => {
161161
);
162162

163163
const yourVote = screen.getByTestId(`${uniqueId}-row-your-vote`);
164-
const acceptedIcon = screen.getByTestId(`${uniqueId}-row-your-vote-accepted-icon`);
164+
const acceptedIcon = screen.getByTestId(`${uniqueId}-row-your-vote-stats-accepted-icon`);
165165

166-
expect(acceptedIcon).toBeDefined();
166+
expect(acceptedIcon).toBeInTheDocument();
167167
expect(yourVote.textContent).toMatch(/Accepted/);
168168
});
169169

@@ -191,9 +191,9 @@ describe('Inflight Vote Requests', () => {
191191
);
192192

193193
const yourVote = screen.getByTestId(`${uniqueId}-row-your-vote`);
194-
const rejectedIcon = screen.getByTestId(`${uniqueId}-row-your-vote-rejected-icon`);
194+
const rejectedIcon = screen.getByTestId(`${uniqueId}-row-your-vote-stats-rejected-icon`);
195195

196-
expect(rejectedIcon).toBeDefined();
196+
expect(rejectedIcon).toBeInTheDocument();
197197
expect(yourVote.textContent).toMatch(/Rejected/);
198198
});
199199

@@ -280,17 +280,17 @@ describe('Vote history', () => {
280280
const status = screen.getByTestId(`${uniqueId}-row-status`);
281281
expect(status.textContent).toBe(data.status);
282282

283-
const voteStats = screen.getByTestId(`${uniqueId}-row-vote-stats`);
284-
expect(voteStats.textContent).toBe('9 Accepted / 2 Rejected');
283+
const acceptedVoteStats = screen.getByTestId(`${uniqueId}-row-all-votes-stats-accepted`);
284+
expect(acceptedVoteStats.textContent).toBe('9 Accepted');
285+
286+
const rejectedVoteStats = screen.getByTestId(`${uniqueId}-row-all-votes-stats-rejected`);
287+
expect(rejectedVoteStats.textContent).toBe('2 Rejected');
285288

286289
const acceptanceThreshold = screen.getByTestId(`${uniqueId}-row-acceptance-threshold`);
287290
expect(acceptanceThreshold.textContent).toBe('11');
288291

289292
const yourVote = screen.getByTestId(`${uniqueId}-row-your-vote`);
290293
expect(yourVote.textContent).toMatch(/Accepted/);
291-
292-
const viewDetails = screen.getByTestId(`${uniqueId}-row-view-details`);
293-
expect(viewDetails).toBeDefined();
294294
});
295295

296296
test('should show info message when no vote history is available', async () => {

apps/sv/frontend/src/components/governance/ProposalListingSection.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,12 @@ const VoteRow: React.FC<VoteRowProps> = props => {
181181
</TableCell>
182182
)}
183183
{showVoteStats && (
184-
<TableCell data-testid={`${uniqueId}-row-vote-stats`}>
184+
<TableCell data-testid={`${uniqueId}-row-all-votes`}>
185185
<TableBodyTypography>
186-
{/* {voteStats['accepted']} Accepted / {voteStats['rejected']} Rejected */}
187186
<AllVotes
188187
acceptedVotes={voteStats['accepted']}
189188
rejectedVotes={voteStats['rejected']}
190-
data-testid={`${uniqueId}-row-all-votes`}
189+
data-testid={`${uniqueId}-row-all-votes-stats`}
191190
/>
192191
</TableBodyTypography>
193192
</TableCell>
@@ -199,7 +198,7 @@ const VoteRow: React.FC<VoteRowProps> = props => {
199198
)}
200199

201200
<TableCell data-testid={`${uniqueId}-row-your-vote`}>
202-
<VoteStats vote={yourVote} data-testid={`${uniqueId}-row-your-vote`} />
201+
<VoteStats vote={yourVote} data-testid={`${uniqueId}-row-your-vote-stats`} />
203202
</TableCell>
204203
</TableRow>
205204
);
@@ -233,7 +232,7 @@ interface VoteStatsProps {
233232
const VoteStats: React.FC<VoteStatsProps> = ({ vote, count, 'data-testid': testId }) => {
234233
if (vote === 'accepted') {
235234
return (
236-
<Stack direction="row" gap="4px" alignItems="center">
235+
<Stack direction="row" gap="4px" alignItems="center" data-testid={testId}>
237236
<CheckCircleOutlineIcon
238237
fontSize="small"
239238
color="success"
@@ -246,7 +245,7 @@ const VoteStats: React.FC<VoteStatsProps> = ({ vote, count, 'data-testid': testI
246245

247246
if (vote === 'rejected') {
248247
return (
249-
<Stack direction="row" gap="4px" alignItems="center">
248+
<Stack direction="row" gap="4px" alignItems="center" data-testid={testId}>
250249
<CancelOutlinedIcon
251250
fontSize="small"
252251
color="error"
@@ -257,7 +256,7 @@ const VoteStats: React.FC<VoteStatsProps> = ({ vote, count, 'data-testid': testI
257256
);
258257
}
259258

260-
return <TableBodyTypography>No Vote</TableBodyTypography>;
259+
return <TableBodyTypography data-testid={testId}>No Vote</TableBodyTypography>;
261260
};
262261

263262
const TableBodyTypography: React.FC<React.PropsWithChildren> = ({ children }) => (

0 commit comments

Comments
 (0)