Skip to content

Commit

Permalink
fix: remove short timeout & use userEvent.paste (#1737)
Browse files Browse the repository at this point in the history
* fix: remove short timeout & no delay in typing

* Update Agent.test.tsx

* Update Agent.test.tsx

* Update Agent.test.tsx
  • Loading branch information
ivyjeong13 authored Feb 13, 2025
1 parent 6f70049 commit f7c2486
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions ui/admin/app/components/agent/__tests__/Agent.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,19 @@ describe(Agent, () => {
const modifiedValue = faker.word.words({ count: { min: 2, max: 5 } });

if (!as) {
await userEvent.type(screen.getByDisplayValue(searchFor), modifiedValue);
await userEvent.click(screen.getByDisplayValue(searchFor));
await userEvent.paste(modifiedValue);
} else if (as === "placeholder") {
await userEvent.type(
screen.getByPlaceholderText(searchFor),
modifiedValue
);
await userEvent.click(screen.getByPlaceholderText(searchFor));
await userEvent.paste(modifiedValue);
} else if (as === "textbox") {
const heading = screen.getByRole("heading", { name: searchFor });
const textbox = within(heading.parentElement!).queryAllByRole("textbox")[
index ?? 0
];

await userEvent.type(textbox, modifiedValue, { delay: null });
await userEvent.click(textbox);
await userEvent.paste(modifiedValue);
}

await waitFor(
Expand All @@ -126,6 +126,7 @@ describe(Agent, () => {
),
{ timeout: 1000 }
);
expect(putSpy).toHaveBeenCalledTimes(1);
});

it("Updating icon triggers save", async () => {
Expand Down Expand Up @@ -154,7 +155,7 @@ describe(Agent, () => {
const iconSrc = iconSelections[0].getAttribute("src");
await userEvent.click(iconSelections[0]);

await waitFor(() => expect(putSpy).toHaveBeenCalled(), { timeout: 20 });
await waitFor(() => expect(putSpy).toHaveBeenCalled());

expect(putSpy).toHaveBeenCalledWith(
expect.objectContaining({
Expand Down Expand Up @@ -203,7 +204,7 @@ describe(Agent, () => {
).getAllByRole("button")[1];
await userEvent.click(imageDeleteButton);

await waitFor(() => expect(putSpy).toHaveBeenCalled(), { timeout: 20 });
await waitFor(() => expect(putSpy).toHaveBeenCalled());

expect(putSpy).toHaveBeenCalledWith(
expect.objectContaining({
Expand Down

0 comments on commit f7c2486

Please sign in to comment.