From f71048fee4ddd0e8538e7d712052038b74c8dccc Mon Sep 17 00:00:00 2001 From: Taylor Smock Date: Thu, 2 May 2024 11:14:26 -0600 Subject: [PATCH] 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 --- frontend/src/components/user/tests/list.test.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/user/tests/list.test.js b/frontend/src/components/user/tests/list.test.js index c764b005d1..447289fbe3 100644 --- a/frontend/src/components/user/tests/list.test.js +++ b/frontend/src/components/user/tests/list.test.js @@ -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); }); });