Skip to content

Commit f7c2486

Browse files
authored
fix: remove short timeout & use userEvent.paste (#1737)
* fix: remove short timeout & no delay in typing * Update Agent.test.tsx * Update Agent.test.tsx * Update Agent.test.tsx
1 parent 6f70049 commit f7c2486

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

ui/admin/app/components/agent/__tests__/Agent.test.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,19 +102,19 @@ describe(Agent, () => {
102102
const modifiedValue = faker.word.words({ count: { min: 2, max: 5 } });
103103

104104
if (!as) {
105-
await userEvent.type(screen.getByDisplayValue(searchFor), modifiedValue);
105+
await userEvent.click(screen.getByDisplayValue(searchFor));
106+
await userEvent.paste(modifiedValue);
106107
} else if (as === "placeholder") {
107-
await userEvent.type(
108-
screen.getByPlaceholderText(searchFor),
109-
modifiedValue
110-
);
108+
await userEvent.click(screen.getByPlaceholderText(searchFor));
109+
await userEvent.paste(modifiedValue);
111110
} else if (as === "textbox") {
112111
const heading = screen.getByRole("heading", { name: searchFor });
113112
const textbox = within(heading.parentElement!).queryAllByRole("textbox")[
114113
index ?? 0
115114
];
116115

117-
await userEvent.type(textbox, modifiedValue, { delay: null });
116+
await userEvent.click(textbox);
117+
await userEvent.paste(modifiedValue);
118118
}
119119

120120
await waitFor(
@@ -126,6 +126,7 @@ describe(Agent, () => {
126126
),
127127
{ timeout: 1000 }
128128
);
129+
expect(putSpy).toHaveBeenCalledTimes(1);
129130
});
130131

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

157-
await waitFor(() => expect(putSpy).toHaveBeenCalled(), { timeout: 20 });
158+
await waitFor(() => expect(putSpy).toHaveBeenCalled());
158159

159160
expect(putSpy).toHaveBeenCalledWith(
160161
expect.objectContaining({
@@ -203,7 +204,7 @@ describe(Agent, () => {
203204
).getAllByRole("button")[1];
204205
await userEvent.click(imageDeleteButton);
205206

206-
await waitFor(() => expect(putSpy).toHaveBeenCalled(), { timeout: 20 });
207+
await waitFor(() => expect(putSpy).toHaveBeenCalled());
207208

208209
expect(putSpy).toHaveBeenCalledWith(
209210
expect.objectContaining({

0 commit comments

Comments
 (0)