Skip to content

Commit

Permalink
✅ Update tests that were failing
Browse files Browse the repository at this point in the history
  • Loading branch information
mariush2 committed Dec 11, 2024
1 parent 28d1312 commit 4ed0493
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 59 deletions.
13 changes: 8 additions & 5 deletions src/molecules/InfoElement/CopyText.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { waitForElementToBeRemoved } from '@testing-library/dom';

import CopyText from 'src/molecules/InfoElement/CopyText';
import {
render,
Expand All @@ -9,7 +7,12 @@ import {
} from 'src/tests/browsertest-utils';

test('Renders label on hover', async () => {
render(<CopyText textToCopy="Test">testing text</CopyText>);
render(
<div>
<CopyText textToCopy="Test">testing text</CopyText>
<p>other</p>
</div>
);
const user = userEvent.setup();

const wrapper = screen.getByText('testing text');
Expand All @@ -20,8 +23,8 @@ test('Renders label on hover', async () => {
const copyText = screen.getByText(/copy/i);
expect(copyText).toBeInTheDocument();

await user.unhover(wrapper);
await waitForElementToBeRemoved(() => copyText);
await user.hover(screen.getByText('other'));

expect(screen.queryByText(/copy/i)).not.toBeInTheDocument();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,66 +56,56 @@ test(
{ timeout: 6000 }
);

describe('Not able to delete user impersonation with activeUsers', () => {
beforeAll(() => {
worker.resetHandlers(
http.get('*/api/v1/Token/AmplifyPortal/*', async () => {
test('Not able to delete user impersonation with activeUsers', async () => {
worker.resetHandlers(
http.get('*/api/v1/Token/AmplifyPortal/*', async () => {
await delay('real');
return HttpResponse.text(faker.string.nanoid());
}),
http.get('*/api/v1/ImpersonateUser/CanImpersonate', async () => {
await delay('real');
return HttpResponse.text('true');
}),
http.get('*/api/v1/ImpersonateUser/ActiveUser', async () => {
await delay('real');
return HttpResponse.json(undefined, { status: 204 });
}),
http.get(
'*/api/v1/ImpersonateUser/GetImpersonateUserForApp/:appName',
async () => {
await delay('real');
return HttpResponse.text(faker.string.nanoid());
}),
http.get('*/api/v1/ImpersonateUser/CanImpersonate', async () => {
await delay('real');
return HttpResponse.text('true');
}),
http.get('*/api/v1/ImpersonateUser/ActiveUser', async () => {
await delay('real');
return HttpResponse.json(undefined, { status: 204 });
}),
http.get(
'*/api/v1/ImpersonateUser/GetImpersonateUserForApp/:appName',
async () => {
await delay('real');
const copy = structuredClone(fakeImpersonateUsers);
copy[0].activeUsers.push(faker.internet.username());
return HttpResponse.json(copy);
const copy = structuredClone(fakeImpersonateUsers);
for (const item of copy) {
item.activeUsers = [faker.internet.username()];
}
)
);
});

afterAll(() => {
worker.resetHandlers();
});
return HttpResponse.json(copy);
}
)
);

test(
'Not able to delete user impersonation with activeUsers',
async () => {
renderWithProviders(<Account />);
const user = userEvent.setup();
const button = screen.getByRole('button');
renderWithProviders(<Account />);
const user = userEvent.setup();
const button = screen.getByRole('button');

await user.click(button);
await user.click(button);

const impersonateButton = await screen.findByRole('button', {
name: /impersonate/i,
});
const impersonateButton = await screen.findByRole('button', {
name: /impersonate/i,
});

await user.click(impersonateButton);
await user.click(impersonateButton);

const menuItems = await screen.findAllByTestId('impersonation-user');
expect(menuItems.length).toBeGreaterThan(0);
const menuItems = await screen.findAllByTestId('impersonation-user');
expect(menuItems.length).toBeGreaterThan(0);

// Click edit on the first one
await user.click(within(menuItems[0]).getByRole('button'));
// Click edit on the first one
await user.click(within(menuItems[0]).getByRole('button'));

await waitFor(
() =>
expect(
screen.getByRole('button', { name: /delete user/i })
).toBeDisabled(),
{ timeout: 3000 }
);
},
{ concurrent: false }
await waitFor(
() =>
expect(
screen.getByRole('button', { name: /delete user/i })
).toBeDisabled(),

Check failure on line 108 in src/organisms/TopBar/Account/ImpersonateMenu/DeleteUser/DeleteUser.test.tsx

View workflow job for this annotation

GitHub Actions / Browser tests / test (webkit)

src/organisms/TopBar/Account/ImpersonateMenu/DeleteUser/DeleteUser.test.tsx > Not able to delete user impersonation with activeUsers

Error: expect(element).toBeDisabled() Received element is not disabled: <button class="sc-dwGkES ljcPUV sc-kXaPYj fMLruc" /> Ignored nodes: comments, script, style <html lang="en" > <head> <meta charset="UTF-8" /> <link href="/__vitest__/favicon.svg" rel="icon" type="image/svg+xml" /> <meta content="width=device-width, initial-scale=1.0" name="viewport" /> <title> Vitest Browser Tester </title> <link crossorigin="" href="/__vitest_browser__/utils-Owv5OOOf.js" rel="modulepreload" /> </head> <body> <div> <div class="sc-fIymDE a-Dfzn" > <button class="sc-fantwC hrOvdP" > <div class="sc-gQkENW hPSxqy" > <span> MM </span> </div> </button> </div> <div class="Menu__StyledPopover-sc-1vlnqcj-1 fxCHlc" data-floating-ui-focusable="" popover="manual" style="width: 400px; position: absolute; top: 40px; left: 8px;" tabindex="-1" > <div class="Paper__StyledPaper-sc-6ncnv9-0 iHUHkq Menu__MenuPaper-sc-1vlnqcj-0 hAiDrr" > <div class="MenuList__List-sc-104rzof-0 eilaKU" role="menu" > <header class="sc-glpSfM fcBUbp" index="0" > <h6 class="Typography__StyledTypography-sc-179guof-0 kCSDDt" > Impersonate </h6> <p class="Typography__StyledTypography-sc-179guof-0 bWBVuK" > Select a user to impersonate </p> <div class="InputWrapper__Container-sc-v6o9z1-0 sc-kpAHqd kJTWXQ" role="search" > <div class="Input__Container-sc-1ykv024-0 YAklD Search__SearchInput-sc-v8l23u-0 gubJdd" > <div class="Input__Adornments-sc-1ykv024-2 Input__LeftAdornments-sc-1ykv024-3 fedFMR gUzpzx" > <svg aria-hidden="true" class="Icon__StyledSvg-sc-6evbi1-0 iATzmE" fill="currentColor" height="18px" viewBox="0 0 18 18" width="18px" xmlns="http://www.w3.org/2000/svg" > <path class="Icon__StyledPath-sc-6evbi1-1" clip-rule="evenodd" d="M11.224 10.691h.592l3.743 3.75-1.118 1.118-3.75-3.743v-.592l-.202-.21a4.853 4.853 0 0 1-3.173 1.177 4.875 4.875 0 1 1 4.875-4.875 4.853 4.853 0 0 1-1.177 3.173l.21.202ZM3.94 7.316a3.37 3.37 0 0 0 3.375 3.375 3.37 3.37 0 0 0 3.375-3.375 3.37 3.37 0 0 0-3.375-3.375 3.37 3.37 0 0 0-3.375 3.375Z" data-testid="eds-icon-path" fill-rule="evenodd" /> </svg> </div> <input autocomplete="off" class="Input__StyledInput-sc-1ykv024-1 cfrECc" placeholder="Search users" style="resize: none;" type="text" value="" /> <div class="Input__Adornments-sc-1ykv024-2 Input__RightAdornments-sc-1ykv024-4 fedFMR jjTNHJ" /> </div> </div> </header> <section class="sc-kHhQGl dIumTf" index="1" > <div class="sc-PBvYm jyJZTt" data-testid="impersonation-user"

Check failure on line 108 in src/organisms/TopBar/Account/ImpersonateMenu/DeleteUser/DeleteUser.test.tsx

View workflow job for this annotation

GitHub Actions / Browser tests / test (webkit)

src/organisms/TopBar/Account/ImpersonateMenu/DeleteUser/DeleteUser.test.tsx > Not able to delete user impersonation with activeUsers

Error: expect(element).toBeDisabled() Received element is not disabled: <button class="sc-dwGkES ljcPUV sc-kXaPYj fMLruc" /> Ignored nodes: comments, script, style <html lang="en" > <head> <meta charset="UTF-8" /> <link href="/__vitest__/favicon.svg" rel="icon" type="image/svg+xml" /> <meta content="width=device-width, initial-scale=1.0" name="viewport" /> <title> Vitest Browser Tester </title> <link crossorigin="" href="/__vitest_browser__/utils-Owv5OOOf.js" rel="modulepreload" /> </head> <body> <div> <div class="sc-fIymDE a-Dfzn" > <button class="sc-fantwC hrOvdP" > <div class="sc-gQkENW hPSxqy" > <span> MM </span> </div> </button> </div> <div class="Menu__StyledPopover-sc-1vlnqcj-1 fxCHlc" data-floating-ui-focusable="" popover="manual" style="width: 400px; position: absolute; top: 40px; left: 8px;" tabindex="-1" > <div class="Paper__StyledPaper-sc-6ncnv9-0 iHUHkq Menu__MenuPaper-sc-1vlnqcj-0 hAiDrr" > <div class="MenuList__List-sc-104rzof-0 eilaKU" role="menu" > <header class="sc-glpSfM fcBUbp" index="0" > <h6 class="Typography__StyledTypography-sc-179guof-0 kCSDDt" > Impersonate </h6> <p class="Typography__StyledTypography-sc-179guof-0 bWBVuK" > Select a user to impersonate </p> <div class="InputWrapper__Container-sc-v6o9z1-0 sc-kpAHqd kJTWXQ" role="search" > <div class="Input__Container-sc-1ykv024-0 YAklD Search__SearchInput-sc-v8l23u-0 gubJdd" > <div class="Input__Adornments-sc-1ykv024-2 Input__LeftAdornments-sc-1ykv024-3 fedFMR gUzpzx" > <svg aria-hidden="true" class="Icon__StyledSvg-sc-6evbi1-0 iATzmE" fill="currentColor" height="18px" viewBox="0 0 18 18" width="18px" xmlns="http://www.w3.org/2000/svg" > <path class="Icon__StyledPath-sc-6evbi1-1" clip-rule="evenodd" d="M11.224 10.691h.592l3.743 3.75-1.118 1.118-3.75-3.743v-.592l-.202-.21a4.853 4.853 0 0 1-3.173 1.177 4.875 4.875 0 1 1 4.875-4.875 4.853 4.853 0 0 1-1.177 3.173l.21.202ZM3.94 7.316a3.37 3.37 0 0 0 3.375 3.375 3.37 3.37 0 0 0 3.375-3.375 3.37 3.37 0 0 0-3.375-3.375 3.37 3.37 0 0 0-3.375 3.375Z" data-testid="eds-icon-path" fill-rule="evenodd" /> </svg> </div> <input autocomplete="off" class="Input__StyledInput-sc-1ykv024-1 cfrECc" placeholder="Search users" style="resize: none;" type="text" value="" /> <div class="Input__Adornments-sc-1ykv024-2 Input__RightAdornments-sc-1ykv024-4 fedFMR jjTNHJ" /> </div> </div> </header> <section class="sc-kHhQGl dIumTf" index="1" > <div class="sc-PBvYm jyJZTt" data-testid="impersonation-user"
{ timeout: 3000 }
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ const MOCK_SLACK_FILE_ERROR = 'slack file error';
describe('Show expected error message when requests fail', () => {
beforeEach(() => {
worker.resetHandlers(
http.get('*/api/v1/ReleaseNotes*', async () => {
await delay('real');
return HttpResponse.json([]);
}),
http.get('*/api/v1/Token/AmplifyPortal/*', async () => {
await delay('real');
return HttpResponse.text(faker.string.nanoid());
Expand Down Expand Up @@ -186,15 +190,15 @@ describe('Show expected error message when requests fail', () => {

await user.click(sendButton);

expect(await screen.findAllByText(/sending/i)).toHaveLength(1);
expect(await screen.findAllByText(/sending/i)).toHaveLength(2);

Check failure on line 193 in src/organisms/TopBar/Resources/Feedback/tests/ReportABug.test.tsx

View workflow job for this annotation

GitHub Actions / Browser tests / test (webkit)

src/organisms/TopBar/Resources/Feedback/tests/ReportABug.test.tsx > Show expected error message when requests fail > Show expected error message when requests fail

AssertionError: expected [ <p …(1)></p> ] to have a length of 2 but got 1 - Expected + Received - 2 + 1 ❯ src/organisms/TopBar/Resources/Feedback/tests/ReportABug.test.tsx:193:51

Check failure on line 193 in src/organisms/TopBar/Resources/Feedback/tests/ReportABug.test.tsx

View workflow job for this annotation

GitHub Actions / Browser tests / test (webkit)

src/organisms/TopBar/Resources/Feedback/tests/ReportABug.test.tsx > Show expected error message when requests fail > Show expected error message when requests fail

AssertionError: expected [ <p …(1)></p> ] to have a length of 2 but got 1 - Expected + Received - 2 + 1 ❯ src/organisms/TopBar/Resources/Feedback/tests/ReportABug.test.tsx:193:51

Check failure on line 193 in src/organisms/TopBar/Resources/Feedback/tests/ReportABug.test.tsx

View workflow job for this annotation

GitHub Actions / Code coverage / coverage

src/organisms/TopBar/Resources/Feedback/tests/ReportABug.test.tsx > Show expected error message when requests fail > Show expected error message when requests fail

AssertionError: expected [ <p …(1)></p> ] to have a length of 2 but got 1 - Expected + Received - 2 + 1 ❯ src/organisms/TopBar/Resources/Feedback/tests/ReportABug.test.tsx:193:51

Check failure on line 193 in src/organisms/TopBar/Resources/Feedback/tests/ReportABug.test.tsx

View workflow job for this annotation

GitHub Actions / Code coverage / coverage

src/organisms/TopBar/Resources/Feedback/tests/ReportABug.test.tsx > Show expected error message when requests fail > Show expected error message when requests fail

AssertionError: expected [ <p …(1)></p> ] to have a length of 2 but got 1 - Expected + Received - 2 + 1 ❯ src/organisms/TopBar/Resources/Feedback/tests/ReportABug.test.tsx:193:51

expect(
await screen.findByText(`Posting ${image.name}`, undefined, {
timeout: 5000,
})
).toBeInTheDocument();

expect(await screen.findAllByText(/not found/i)).toHaveLength(2);
expect(await screen.findAllByText(/not found/i)).toHaveLength(3);

await user.click(screen.getByRole('button', { name: /retry/i }));
});
Expand Down

0 comments on commit 4ed0493

Please sign in to comment.