feat(web): disable submit while saving + Save & create another + Cmd/Ctrl+Enter (#46)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-07 23:15:21 +02:00
parent ed0c13907c
commit 3900bc362c
7 changed files with 122 additions and 25 deletions
+15 -1
View File
@@ -1,5 +1,5 @@
import { expect, test, vi } from "vitest";
import { screen, waitFor } from "@testing-library/react";
import { fireEvent, screen, waitFor } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { renderApp } from "../test/render";
import { ObjectForm } from "./object-form";
@@ -25,6 +25,20 @@ test("create mode: shows visibility (draft/internal only) and submits assembled
expect(values.fields.inscription).toBe("To the gods");
});
test("Cmd/Ctrl+Enter submits the form", async () => {
const onSubmit = vi.fn();
renderApp(<ObjectForm mode="create" onSubmit={onSubmit} onCancel={() => {}} />);
await userEvent.type(await screen.findByLabelText(/object number/i), "A-9");
await userEvent.type(screen.getByLabelText(/^name/i), "Amphora");
await userEvent.type(screen.getByLabelText(/inscription/i), "To the gods");
const numberInput = screen.getByLabelText(/object number/i);
fireEvent.keyDown(numberInput, { key: "Enter", metaKey: true });
await waitFor(() => expect(onSubmit).toHaveBeenCalledOnce());
});
test("required core + required flexible field block submit", async () => {
const onSubmit = vi.fn();
renderApp(<ObjectForm mode="create" onSubmit={onSubmit} onCancel={() => {}} />);