Skip to content

Commit 009b59c

Browse files
committed
Update list.test.js
Of specific note, the background-image check passes prior to the previous commit because two renders happen before the test continues. With the new code, only one render happens. This may have been a source of intermittent test failures in the past. Signed-off-by: Taylor Smock <[email protected]>
1 parent 08b89be commit 009b59c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

frontend/src/components/user/tests/list.test.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@ describe('User list card', () => {
3737
expect(getByText('Beginner')).toBeInTheDocument();
3838
expect(getByText('Shyam')).toBeInTheDocument();
3939
expect(screen.getByText('Shyam').closest('a')).toHaveAttribute('href', '/users/Shyam');
40-
expect(screen.getByTitle(/Ram/i)).toHaveStyle(
40+
// The first render does not have background-image. The second render does.
41+
await waitFor(() => expect(screen.getByTitle('Ram')).toHaveStyle(
4142
`background-image: url(https://www.openstreetmap.org/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBNXQ2Q3c9PSIsImV4cCI6bnVsbCwicHVyIjoiYmxvYl9pZCJ9fQ==--fe41f1b2a5d6cf492a7133f15c81f105dec06ff7/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdCem9MWm05eWJXRjBPZ2h3Ym1jNkZISmxjMmw2WlY5MGIxOXNhVzFwZEZzSGFXbHBhUT09IiwiZXhwIjpudWxsLCJwdXIiOiJ2YXJpYXRpb24ifX0=--058ac785867b32287d598a314311e2253bd879a3/unnamed.webp)`,
42-
);
43-
expect(container.querySelectorAll('svg').length).toBe(2);
43+
));
44+
// Two gears (for mapper settings), two trash cans (for user personal information removal)
45+
expect(container.querySelectorAll('svg').length).toBe(4);
4446
});
4547
});
4648

0 commit comments

Comments
 (0)