mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-18 03:30:39 +09:00
test(ui): wait for workspace selector in new issue dialog test
This commit is contained in:
parent
5d021583be
commit
3cee1f12da
1 changed files with 17 additions and 5 deletions
|
|
@ -222,6 +222,18 @@ async function flush() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function waitForValue<T>(getValue: () => T | null | undefined, attempts = 10): Promise<T> {
|
||||||
|
for (let attempt = 0; attempt < attempts; attempt += 1) {
|
||||||
|
const value = getValue();
|
||||||
|
if (value != null) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
await flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Error("Timed out waiting for value");
|
||||||
|
}
|
||||||
|
|
||||||
function renderDialog(container: HTMLDivElement) {
|
function renderDialog(container: HTMLDivElement) {
|
||||||
const queryClient = new QueryClient({
|
const queryClient = new QueryClient({
|
||||||
defaultOptions: {
|
defaultOptions: {
|
||||||
|
|
@ -421,13 +433,13 @@ describe("NewIssueDialog", () => {
|
||||||
|
|
||||||
expect(container.textContent).not.toContain("will no longer use the parent issue workspace");
|
expect(container.textContent).not.toContain("will no longer use the parent issue workspace");
|
||||||
|
|
||||||
const selects = Array.from(container.querySelectorAll("select"));
|
const modeSelect = await waitForValue(
|
||||||
const modeSelect = selects[0] as HTMLSelectElement | undefined;
|
() => container.querySelector("select") as HTMLSelectElement | null,
|
||||||
expect(modeSelect).not.toBeUndefined();
|
);
|
||||||
|
|
||||||
await act(async () => {
|
await act(async () => {
|
||||||
modeSelect!.value = "shared_workspace";
|
modeSelect.value = "shared_workspace";
|
||||||
modeSelect!.dispatchEvent(new Event("change", { bubbles: true }));
|
modeSelect.dispatchEvent(new Event("change", { bubbles: true }));
|
||||||
});
|
});
|
||||||
await flush();
|
await flush();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue