Files
wehub-resource-sync adf0d17497
publish / version_or_publish (push) Has been cancelled
storybook-build / changes (push) Has been cancelled
storybook-build / :storybook-build (push) Has been cancelled
Sync Gradio Skills to Hugging Face / sync-skills (push) Has been cancelled
functional / changes (push) Has been cancelled
functional / build-frontend (push) Has been cancelled
functional / functional-test-SSR=false (push) Has been cancelled
functional / functional-reload (push) Has been cancelled
js / changes (push) Has been cancelled
js / js-test (push) Has been cancelled
docs-build / changes (push) Has been cancelled
docs-build / docs-build (push) Has been cancelled
docs-build / website-build (push) Has been cancelled
functional / functional-test-SSR=true (push) Has been cancelled
hygiene / hygiene-test (push) Has been cancelled
python / changes (push) Has been cancelled
python / build (push) Has been cancelled
python / test-ubuntu-latest-flaky (push) Has been cancelled
python / test-ubuntu-latest-not-flaky (push) Has been cancelled
python / test-windows-latest-flaky (push) Has been cancelled
python / test-windows-latest-not-flaky (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:17:32 +08:00

87 lines
2.2 KiB
TypeScript

import { test, describe, assert, afterEach } from "vitest";
import { cleanup, render } from "@self/tootils/render";
import event from "@testing-library/user-event";
import MultimodalTextbox from "./Index.svelte";
import type { ILoadingStatus as LoadingStatus } from "@gradio/statustracker";
const loading_status: LoadingStatus = {
eta: 0,
queue_position: 1,
queue_size: 1,
status: "complete" as LoadingStatus["status"],
scroll_to_output: false,
visible: true,
fn_index: 0,
show_progress: "full"
};
describe("MultimodalTextbox", () => {
afterEach(() => cleanup());
test("renders provided value", async () => {
const { getByDisplayValue } = await render(MultimodalTextbox, {
show_label: true,
max_lines: 1,
loading_status,
lines: 1,
value: { text: "hello world", files: [] },
label: "Textbox",
interactive: false,
root: "",
sources: []
});
const item: HTMLInputElement = getByDisplayValue(
"hello world"
) as HTMLInputElement;
assert.equal(item.value, "hello world");
});
test.skip("changing the text should update the value", async () => {
const { getByDisplayValue, listen } = await render(MultimodalTextbox, {
show_label: true,
max_lines: 10,
loading_status,
lines: 1,
value: { text: "hi ", files: [] },
label: "MultimodalTextbox",
interactive: true,
root: "",
sources: []
});
const item: HTMLInputElement = getByDisplayValue("hi") as HTMLInputElement;
const mock = listen("change");
item.focus();
await event.keyboard("some text");
assert.equal(item.value, "hi some text");
assert.equal(mock.callCount, 9);
assert.equal(mock.calls[8][0].detail.data.text, "hi some text");
assert.equal(mock.calls[8][0].detail.data.files.length, 0);
});
test.skip("submitting should clear mic_audio", async () => {
const { getByTestId, listen } = await render(MultimodalTextbox, {
show_label: true,
max_lines: 10,
loading_status,
lines: 1,
value: { text: "", files: [] },
label: "MultimodalTextbox",
interactive: true,
root: "",
sources: ["microphone"],
submit_btn: true
});
const mock = listen("submit");
const submitButton = getByTestId("submit-button");
await event.click(submitButton);
assert.equal(mock.callCount, 1);
});
});