Skip to content

Commit

Permalink
Update list.test.js
Browse files Browse the repository at this point in the history
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 <tsmock@meta.com>
  • Loading branch information
tsmock committed May 7, 2024
1 parent 9f84d20 commit f71048f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions frontend/src/components/user/tests/list.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ describe('User list card', () => {
expect(getByText('Beginner')).toBeInTheDocument();
expect(getByText('Shyam')).toBeInTheDocument();
expect(screen.getByText('Shyam').closest('a')).toHaveAttribute('href', '/users/Shyam');
expect(screen.getByTitle(/Ram/i)).toHaveStyle(
// The first render does not have background-image. The second render does.
await waitFor(() => expect(screen.getByTitle('Ram')).toHaveStyle(
`background-image: url(https://www.openstreetmap.org/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBNXQ2Q3c9PSIsImV4cCI6bnVsbCwicHVyIjoiYmxvYl9pZCJ9fQ==--fe41f1b2a5d6cf492a7133f15c81f105dec06ff7/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdCem9MWm05eWJXRjBPZ2h3Ym1jNkZISmxjMmw2WlY5MGIxOXNhVzFwZEZzSGFXbHBhUT09IiwiZXhwIjpudWxsLCJwdXIiOiJ2YXJpYXRpb24ifX0=--058ac785867b32287d598a314311e2253bd879a3/unnamed.webp)`,
);
expect(container.querySelectorAll('svg').length).toBe(2);
));
// Two gears (for mapper settings), two trash cans (for user personal information removal)
expect(container.querySelectorAll('svg').length).toBe(4);
});
});

Expand Down

0 comments on commit f71048f

Please sign in to comment.