| addRow()}
disabled={maxRows != null && rows.length >= maxRows}
data-testid="line-items-add"
>
- {cfg.addLabel || t('fields.grid.addLine', { defaultValue: 'Add line' })}
+ {addLabel}
)}
diff --git a/ui/packages/plugin-form/src/LineItemsPanel.childObjectDecline.test.tsx b/ui/packages/plugin-form/src/LineItemsPanel.childObjectDecline.test.tsx
index 24e1a548c15..bd34c53c7a5 100644
--- a/ui/packages/plugin-form/src/LineItemsPanel.childObjectDecline.test.tsx
+++ b/ui/packages/plugin-form/src/LineItemsPanel.childObjectDecline.test.tsx
@@ -247,8 +247,9 @@ describe('record:line_items — an unresolvable panel offers no editable grid (o
// assertion so a failure names which affordance came back.
expect(view.container.querySelector('[data-testid="line-items"]')).toBeNull();
expect(view.container.querySelector('[data-testid="line-items-add"]')).toBeNull();
- // No cell to type in — the ghost row is what made the save path reachable in
- // ONE keystroke, without the Add button being touched at all.
+ // No cell to type in — the always-present entry row the grid drew then
+ // (objectstack#35507 removed it) made the save path reachable in ONE
+ // keystroke, without the Add button being touched at all.
expect(view.container.querySelector('input[aria-label="Qty"]')).toBeNull();
// ⛔ And NOT a spinner that never ends: hiding a permanent authoring error
@@ -276,7 +277,7 @@ describe('record:line_items — an unresolvable panel offers no editable grid (o
expect(view.container.querySelector('[data-testid="line-items-no-child-object"]')).toBeNull();
expect(view.container.querySelector('[data-testid="line-items"]')).not.toBeNull();
- expect(view.container.querySelector('input[aria-label="Qty"]')).not.toBeNull();
+ expect(view.container.querySelector('[data-testid="line-items-add"]')).not.toBeNull();
});
it('refuses to save when the child object is dropped from a panel with dirty rows', async () => {
@@ -295,6 +296,10 @@ describe('record:line_items — an unresolvable panel offers no editable grid (o
);
await settle();
+ // A line to dirty (the grid draws no trailing entry row, objectstack#35507).
+ await act(async () => {
+ fireEvent.click(view.container.querySelector('[data-testid="line-items-add"]') as HTMLButtonElement);
+ });
const cell = view.container.querySelector('input[aria-label="Qty"]') as HTMLInputElement;
expect(cell).not.toBeNull();
await act(async () => {
diff --git a/ui/packages/plugin-form/src/LineItemsPanel.fieldWriteGate-10163.test.tsx b/ui/packages/plugin-form/src/LineItemsPanel.fieldWriteGate-10163.test.tsx
index f72052318ab..facc8f52ec6 100644
--- a/ui/packages/plugin-form/src/LineItemsPanel.fieldWriteGate-10163.test.tsx
+++ b/ui/packages/plugin-form/src/LineItemsPanel.fieldWriteGate-10163.test.tsx
@@ -116,12 +116,11 @@ function mount(perms: any | null, schema: any = SCHEMA) {
);
}
-/** Every rendered cell of one column — the two loaded rows plus the entry row. */
+/** Every rendered cell of one column — the two loaded rows (no entry row follows them, objectstack#35507). */
async function cells(label: string): Promise {
return waitFor(() => {
const els = screen.getAllByLabelText(label) as HTMLInputElement[];
- // Two loaded rows and the grid's always-present entry row.
- if (els.length < ROWS.length + 1) throw new Error(`${label} cells not rendered yet`);
+ if (els.length < ROWS.length) throw new Error(`${label} cells not rendered yet`);
return els;
});
}
diff --git a/ui/packages/plugin-form/src/LineItemsPanel.heldForAnotherParent-10740.test.tsx b/ui/packages/plugin-form/src/LineItemsPanel.heldForAnotherParent-10740.test.tsx
index 41dda5b81c8..25093fabeaf 100644
--- a/ui/packages/plugin-form/src/LineItemsPanel.heldForAnotherParent-10740.test.tsx
+++ b/ui/packages/plugin-form/src/LineItemsPanel.heldForAnotherParent-10740.test.tsx
@@ -147,11 +147,22 @@ const answerLines = (read: LinesRead, ...lines: Array<{ id: string; label: strin
settle(() => read.resolve({ data: lines }));
const fail = (read: Deferred, message: string) => settle(() => read.reject(new Error(message)));
-/** The grid's line inputs; the grid always trails one blank entry row. */
+/** The grid's line inputs (it draws no trailing entry row, objectstack#35507). */
const lineInputs = () =>
Array.from(document.body.querySelectorAll('input[aria-label="Line"]')) as HTMLInputElement[];
-/** The lines the grid draws (its trailing blank row is not a line). */
+/** The lines the grid draws (a blank one is not counted). */
const shownLines = () => lineInputs().map((input) => input.value).filter((value) => value !== '');
+/** Press the grid's Add once it is drawn, and wait for the new line. */
+const addLine = async () => {
+ const add = await waitFor(() => {
+ const el = document.body.querySelector('[data-testid="line-items-add"]') as HTMLButtonElement | null;
+ if (!el) throw new Error('grid not drawn yet');
+ return el;
+ });
+ const before = lineInputs().length;
+ await settle(() => { fireEvent.click(add); });
+ await waitFor(() => expect(lineInputs().length).toBeGreaterThan(before));
+};
const saveButton = () =>
Array.from(document.body.querySelectorAll('button')).find((b) => /^(Save|Saving…)$/.test(b.textContent ?? '')) as
| HTMLButtonElement
@@ -247,9 +258,9 @@ describe('LineItemsPanel refuses the lines it holds for another parent (objectui
const view = mount(dataSource, linesBlock());
await fail(await nth(lineReads, 1), 'p1 load failed');
await waitFor(() => expect(bannerShows('p1 load failed')).toBe(true));
- // The first failure leaves the empty grid on screen (its entry row is
- // there), as before this card. A line typed into it is p1's.
- await waitFor(() => expect(lineInputs().length).toBeGreaterThan(0));
+ // The first failure leaves the empty grid on screen, as before this card.
+ // A line added and typed into it is p1's.
+ await addLine();
await editFirstLine('new p1 line');
await waitFor(() => expect(shownLines()).toEqual(['new p1 line']));
expect(saveButton()?.disabled).toBe(false);
@@ -274,9 +285,9 @@ describe('LineItemsPanel refuses the lines it holds for another parent (objectui
);
// No adapter: the load declines before any fetch and the panel offers its
- // empty grid (its entry row) for p1. A line typed there is p1's.
+ // empty grid for p1. A line added there is p1's.
const view = render(tree(linesBlock(), null));
- await waitFor(() => expect(lineInputs().length).toBeGreaterThan(0));
+ await addLine();
await editFirstLine('typed under p1');
await waitFor(() => expect(shownLines()).toEqual(['typed under p1']));
expect(dataSource.find).not.toHaveBeenCalled();
@@ -392,8 +403,9 @@ describe('what the rule leaves alone (objectui#10740 controls)', () => {
await waitFor(() => expect(bannerShows('p1 load failed')).toBe(true));
expect(placeholder()).toBeNull();
- // The grid is on screen: its entry row is drawn, no line is.
- await waitFor(() => expect(lineInputs().length).toBeGreaterThan(0));
+ // The grid is on screen (its Add button), and no line is.
+ await waitFor(() => expect(document.body.querySelector('[data-testid="line-items-add"]')).not.toBeNull());
+ expect(lineInputs()).toHaveLength(0);
expect(shownLines()).toEqual([]);
expect(saveButton()?.disabled, 'a clean panel offered Save').toBe(true);
});
diff --git a/ui/packages/plugin-form/src/LineItemsPanel.tsx b/ui/packages/plugin-form/src/LineItemsPanel.tsx
index a26b5445f23..cd0e3330d84 100644
--- a/ui/packages/plugin-form/src/LineItemsPanel.tsx
+++ b/ui/packages/plugin-form/src/LineItemsPanel.tsx
@@ -26,7 +26,7 @@ import {
CardTitle,
cn,
} from '@object-ui/components';
-import { LineItemsField, lookupAutofillByField, useBooleanValueLabel, type GridColumn } from '@object-ui/fields';
+import { LineItemsField, lookupAutofillByField, columnHelpByField, useBooleanValueLabel, type GridColumn } from '@object-ui/fields';
import type { GridFieldMetadata } from '@object-ui/types';
import { createSafeTranslation, useLocalization } from '@object-ui/i18n';
import { useSchemaContext, useRecordContext, useFilterScope, useResolvedFilter, useDataInvalidation, usePrintPage, NonGridRowCeilingNote } from '@object-ui/react';
@@ -765,6 +765,12 @@ export const LineItemsPanel: React.FC<{ schema: LineItemsPanelSchema }> = ({ sch
() => lookupAutofillByField(childSchema?.fields as Record | undefined),
[childSchema],
);
+ // Each child field's help, on its column header (objectstack#35804), read
+ // from the same served definition the record form reads.
+ const lineColumnHelp = useMemo(
+ () => columnHelpByField(childSchema?.fields as Record | undefined),
+ [childSchema],
+ );
const gridField = useMemo(
() =>
@@ -912,6 +918,7 @@ export const LineItemsPanel: React.FC<{ schema: LineItemsPanelSchema }> = ({ sch
// targets in the row. Empty until that schema arrives.
lookupAutofill={lineLookupAutofill}
columnCurrencies={lineColumnCurrencies}
+ columnHelp={lineColumnHelp}
readonly={schema.readonly}
// No input while the save is in flight (objectui#10631): `save`
// reloads the rows once the batch lands, so a line edited in the
diff --git a/ui/packages/plugin-form/src/MasterDetailForm.detailEntryIdentity.test.tsx b/ui/packages/plugin-form/src/MasterDetailForm.detailEntryIdentity.test.tsx
index 8c9250ae5ae..f0177bc033d 100644
--- a/ui/packages/plugin-form/src/MasterDetailForm.detailEntryIdentity.test.tsx
+++ b/ui/packages/plugin-form/src/MasterDetailForm.detailEntryIdentity.test.tsx
@@ -97,6 +97,8 @@ function formSchema(details: any[]) {
/** Type an amount into the (single) resolved collection's grid. */
async function enterLineTotal(value: string) {
+ // The grid draws no trailing entry row (objectstack#35507): Add the line first.
+ fireEvent.click(await waitFor(() => screen.getByTestId('line-items-add')));
const cell = await waitFor(() => screen.getAllByLabelText('Line Total')[0] as HTMLInputElement);
fireEvent.change(cell, { target: { value } });
return cell;
diff --git a/ui/packages/plugin-form/src/MasterDetailForm.editBaselineAdvance.test.tsx b/ui/packages/plugin-form/src/MasterDetailForm.editBaselineAdvance.test.tsx
index 6edafab30dc..a274a492b60 100644
--- a/ui/packages/plugin-form/src/MasterDetailForm.editBaselineAdvance.test.tsx
+++ b/ui/packages/plugin-form/src/MasterDetailForm.editBaselineAdvance.test.tsx
@@ -105,7 +105,13 @@ function renderForm(opts: {
}
const saveButton = () => screen.getByTestId('md-form-submit') as HTMLButtonElement;
-const qtyInputs = () => screen.getAllByLabelText('Qty') as HTMLInputElement[];
+const qtyInputs = () => screen.queryAllByLabelText('Qty') as HTMLInputElement[];
+/** Press the grid's Add: the grid draws no trailing entry row (objectstack#35507). */
+const addLine = async () => {
+ await act(async () => {
+ fireEvent.click(screen.getByTestId('line-items-add'));
+ });
+};
/** The parent form has its values and the stored lines have landed. */
async function ready(container: HTMLElement, mode: 'create' | 'edit', storedLines: number) {
@@ -114,8 +120,9 @@ async function ready(container: HTMLElement, mode: 'create' | 'edit', storedLine
if (!ref) throw new Error('parent form not ready');
if (mode === 'edit' && ref.value !== 'PO-1') throw new Error('parent record not loaded');
});
- // Every stored line plus the grid's trailing ghost row.
- await waitFor(() => expect(qtyInputs()).toHaveLength(storedLines + 1));
+ // The grid is drawn, with every stored line (and no entry row below them).
+ await waitFor(() => expect(screen.getByTestId('line-items-add')).toBeTruthy());
+ await waitFor(() => expect(qtyInputs()).toHaveLength(storedLines));
await waitFor(() => expect(saveButton().disabled).toBe(false));
}
@@ -144,7 +151,8 @@ describe('a mounted master-detail edit form: the next save diffs against what th
const { container, onSuccess } = renderForm({ batchTransaction: batch });
await ready(container, 'edit', 0);
- await change(qtyInputs()[0], '5'); // type into the ghost row
+ await addLine();
+ await change(qtyInputs()[0], '5');
await save(() => batch.mock.calls.length);
expect(onSuccess).toHaveBeenCalledTimes(1);
expect(childOps(batch, 0)).toEqual([
@@ -154,7 +162,7 @@ describe('a mounted master-detail edit form: the next save diffs against what th
// Nothing changed: no child operation at all — not a second create.
await save(() => batch.mock.calls.length);
expect(childOps(batch, 1)).toEqual([]);
- expect(qtyInputs()).toHaveLength(2); // the one line, and the ghost row
+ expect(qtyInputs()).toHaveLength(1); // the one line
// The created row carries the server's id now: editing it is an update.
await change(qtyInputs()[0], '6');
@@ -196,6 +204,7 @@ describe('a mounted master-detail edit form: the next save diffs against what th
const { container, onSuccess } = renderForm({ batchTransaction: batch });
await ready(container, 'edit', 0);
+ await addLine();
await change(qtyInputs()[0], '5');
await act(async () => {
fireEvent.click(saveButton());
@@ -252,7 +261,8 @@ describe('a FAILED save advances neither baseline: the retry carries every opera
await change(container.querySelector('input[name="ref"]') as HTMLElement, 'PO-2');
await change(qtyInputs()[0], '2');
- await change(qtyInputs()[1], '7'); // the ghost row
+ await addLine();
+ await change(qtyInputs()[1], '7');
await save(() => batch.mock.calls.length);
expect(onError).toHaveBeenCalledTimes(1);
expect(onSuccess).not.toHaveBeenCalled();
@@ -294,6 +304,7 @@ describe('a FAILED save advances neither baseline: the retry carries every opera
await change(container.querySelector('input[name="ref"]') as HTMLElement, 'PO-2');
await change(qtyInputs()[0], '2');
+ await addLine();
await change(qtyInputs()[1], '7');
await save(() => create.mock.calls.length);
expect(onError).toHaveBeenCalledTimes(1);
@@ -316,6 +327,7 @@ describe('create mode is unchanged (control)', () => {
const batch = echoBatch();
const { container, onSuccess } = renderForm({ mode: 'create', batchTransaction: batch });
await ready(container, 'create', 0);
+ await addLine();
await change(container.querySelector('input[name="ref"]') as HTMLElement, 'PO-9');
await change(qtyInputs()[0], '5');
@@ -326,9 +338,8 @@ describe('create mode is unchanged (control)', () => {
{ object: 'po_line', action: 'create', data: { qty: 5, po: { $ref: 0 } } },
]);
- // Lines back to the lone ghost row, header cleared.
- await waitFor(() => expect(qtyInputs()).toHaveLength(1));
- expect(qtyInputs()[0].value).toBe('');
+ // Lines back to none, header cleared.
+ await waitFor(() => expect(qtyInputs()).toHaveLength(0));
await waitFor(() =>
expect((container.querySelector('input[name="ref"]') as HTMLInputElement).value).toBe(''),
);
diff --git a/ui/packages/plugin-form/src/MasterDetailForm.elementDataSource.test.tsx b/ui/packages/plugin-form/src/MasterDetailForm.elementDataSource.test.tsx
index 1f1c1125ea4..ed0e6d6871e 100644
--- a/ui/packages/plugin-form/src/MasterDetailForm.elementDataSource.test.tsx
+++ b/ui/packages/plugin-form/src/MasterDetailForm.elementDataSource.test.tsx
@@ -289,6 +289,8 @@ describe('object-master-detail-form — dataSource: { object } (objectstack#7121
return el;
});
fireEvent.change(number, { target: { value: 'INV-9' } });
+ // A line (the grid draws no trailing entry row, objectstack#35507).
+ fireEvent.click(await waitFor(() => screen.getByTestId('line-items-add')));
const qty = await waitFor(() => screen.getAllByLabelText('Qty')[0] as HTMLInputElement);
fireEvent.change(qty, { target: { value: '5' } });
fireEvent.click(screen.getByRole('button', { name: /^create$/i }));
diff --git a/ui/packages/plugin-form/src/MasterDetailForm.headerKeystrokePendingWork-28471.test.tsx b/ui/packages/plugin-form/src/MasterDetailForm.headerKeystrokePendingWork-28471.test.tsx
index 633cd31c9fa..b70c58f2293 100644
--- a/ui/packages/plugin-form/src/MasterDetailForm.headerKeystrokePendingWork-28471.test.tsx
+++ b/ui/packages/plugin-form/src/MasterDetailForm.headerKeystrokePendingWork-28471.test.tsx
@@ -26,7 +26,7 @@
* pending work is a page re-render scheduled just before the keystroke.
*/
import { describe, it, expect, vi, afterEach } from 'vitest';
-import { render, screen, waitFor, act } from '@testing-library/react';
+import { render, screen, waitFor, act, fireEvent } from '@testing-library/react';
import React from 'react';
import { flushSync } from 'react-dom';
import { registerAllFields } from '@object-ui/fields';
@@ -120,6 +120,8 @@ describe('MasterDetailForm — a header keystroke is never dropped (objectstack#
return el;
});
const qty = () => screen.getAllByLabelText('Qty')[0] as HTMLInputElement;
+ // A line (the grid draws no trailing entry row, objectstack#35507).
+ fireEvent.click(await waitFor(() => screen.getByTestId('line-items-add')));
await waitFor(() => expect(qty().disabled).toBe(false));
// The element right under the React root container: above the form host,
diff --git a/ui/packages/plugin-form/src/MasterDetailForm.inlineColumnsSortAmount-11144.test.tsx b/ui/packages/plugin-form/src/MasterDetailForm.inlineColumnsSortAmount-11144.test.tsx
index 1ad90534017..e709a1808dc 100644
--- a/ui/packages/plugin-form/src/MasterDetailForm.inlineColumnsSortAmount-11144.test.tsx
+++ b/ui/packages/plugin-form/src/MasterDetailForm.inlineColumnsSortAmount-11144.test.tsx
@@ -99,7 +99,7 @@ function dataSource(child: ReturnType) {
};
}
-/** Type into the given row's cell (the trailing ghost row materializes a new line). */
+/** Type into the given row's cell. */
function typeCell(label: string, row: number, value: string) {
const cell = screen.getAllByLabelText(label)[row] as HTMLInputElement;
fireEvent.change(cell, { target: { value } });
@@ -129,14 +129,16 @@ async function enterReorderAndSave(detail: Record, child = line
expect(el).not.toBeNull();
return el!;
});
+ // The grid draws no trailing entry row (objectstack#35507): each line is Added.
+ const add = await waitFor(() => screen.getByTestId('line-items-add'));
+ fireEvent.click(add);
await waitFor(() => expect(screen.getAllByLabelText('Description')).toHaveLength(1));
-
typeCell('Description', 0, 'A');
- await waitFor(() => expect(screen.getAllByLabelText('Description')).toHaveLength(2));
typeCell('Qty', 0, '2');
typeCell('Unit Price', 0, '5');
+ fireEvent.click(add);
+ await waitFor(() => expect(screen.getAllByLabelText('Description')).toHaveLength(2));
typeCell('Description', 1, 'B');
- await waitFor(() => expect(screen.getAllByLabelText('Description')).toHaveLength(3));
typeCell('Qty', 1, '1');
typeCell('Unit Price', 1, '3');
diff --git a/ui/packages/plugin-form/src/MasterDetailForm.lateHeaderRecord-13062.test.tsx b/ui/packages/plugin-form/src/MasterDetailForm.lateHeaderRecord-13062.test.tsx
index 328edd05e1f..d3999d8e4d0 100644
--- a/ui/packages/plugin-form/src/MasterDetailForm.lateHeaderRecord-13062.test.tsx
+++ b/ui/packages/plugin-form/src/MasterDetailForm.lateHeaderRecord-13062.test.tsx
@@ -146,6 +146,8 @@ describe('MasterDetailForm — a late header record still drives parent-scoped l
/>,
);
const status = await statusInput(container, '');
+ // A line (the grid draws no trailing entry row, objectstack#35507).
+ fireEvent.click(await waitFor(() => screen.getByTestId('line-items-add')));
await waitFor(() => expect(qty().disabled).toBe(false));
// A create form reads no record.
expect(ds.findOne).not.toHaveBeenCalled();
diff --git a/ui/packages/plugin-form/src/MasterDetailForm.lineGrant-12082.test.tsx b/ui/packages/plugin-form/src/MasterDetailForm.lineGrant-12082.test.tsx
index f22a844e741..2d4ca174731 100644
--- a/ui/packages/plugin-form/src/MasterDetailForm.lineGrant-12082.test.tsx
+++ b/ui/packages/plugin-form/src/MasterDetailForm.lineGrant-12082.test.tsx
@@ -108,11 +108,12 @@ async function lineLoaded() {
await waitFor(() => expect(screen.getByDisplayValue('3')).toBeTruthy());
}
-/** A create form: wait for the grid, then type into the entry row so it becomes a line. */
+/** A create form: wait for the grid, press Add and type into the new line (the grid draws no trailing entry row, objectstack#35507). */
async function addLineViaEntryRow(value: string) {
+ fireEvent.click(await waitFor(() => screen.getByTestId('line-items-add')));
const cells = await waitFor(() => {
const els = screen.getAllByLabelText('Qty') as HTMLInputElement[];
- if (els.length === 0) throw new Error('grid not drawn yet');
+ if (els.length === 0) throw new Error('line not drawn yet');
return els;
});
fireEvent.change(cells[cells.length - 1], { target: { value } });
diff --git a/ui/packages/plugin-form/src/MasterDetailForm.saveInFlight.test.tsx b/ui/packages/plugin-form/src/MasterDetailForm.saveInFlight.test.tsx
index 71b28737791..8483004003e 100644
--- a/ui/packages/plugin-form/src/MasterDetailForm.saveInFlight.test.tsx
+++ b/ui/packages/plugin-form/src/MasterDetailForm.saveInFlight.test.tsx
@@ -138,7 +138,7 @@ function renderForm(opts: {
}
const saveButton = () => screen.getByTestId('md-form-submit') as HTMLButtonElement;
-const qtyInputs = () => screen.getAllByLabelText('Qty') as HTMLInputElement[];
+const qtyInputs = () => screen.queryAllByLabelText('Qty') as HTMLInputElement[];
const refInput = (container: HTMLElement) => container.querySelector('input[name="ref"]') as HTMLInputElement;
/** The parent form has its values and the stored lines have landed. */
@@ -148,8 +148,9 @@ async function ready(container: HTMLElement, mode: 'create' | 'edit', storedLine
if (!ref) throw new Error('parent form not ready');
if (mode === 'edit' && ref.value !== 'PO-1') throw new Error('parent record not loaded');
});
- // Every stored line plus the grid's trailing ghost row.
- await waitFor(() => expect(qtyInputs()).toHaveLength(storedLines + 1));
+ // The grid is drawn, with every stored line (and no entry row below them).
+ await waitFor(() => expect(screen.getByTestId('line-items-add')).toBeTruthy());
+ await waitFor(() => expect(qtyInputs()).toHaveLength(storedLines));
await waitFor(() => expect(saveButton().disabled).toBe(false));
}
@@ -165,6 +166,9 @@ const click = async (el: HTMLElement) => {
});
};
+/** Press the grid's Add: the grid draws no trailing entry row (objectstack#35507). */
+const addLine = () => click(screen.getByTestId('line-items-add'));
+
/** Let real time run past the 1.5 s the old guard re-armed Save after. */
const pastTheOldGuard = () =>
act(async () => {
@@ -188,7 +192,7 @@ async function save(calls: () => number) {
/** The child operations of the batch sent on save number `n` (0-based). */
const childOps = (batch: any, n: number): Op[] => (batch.mock.calls[n][0] as Op[]).slice(1);
-/** No line of the grid takes input: every cell is disabled, and there is no ghost row, add or remove. */
+/** No line of the grid takes input: every cell is disabled, and there is no add or remove. */
function expectGridInert(lines: number) {
expect(qtyInputs()).toHaveLength(lines);
for (const input of qtyInputs()) expect(input.disabled).toBe(true);
@@ -202,6 +206,7 @@ describe('the Save guard holds until the batch settles, not for 1.5 s', () => {
const { container, onSuccess } = renderForm({ batchTransaction: batch });
await ready(container, 'edit', 0);
+ await addLine();
await change(qtyInputs()[0], '5');
await click(saveButton());
await waitFor(() => expect(batch).toHaveBeenCalledTimes(1));
@@ -230,6 +235,7 @@ describe('the Save guard holds until the batch settles, not for 1.5 s', () => {
const { container, onSuccess, onError } = renderForm({ batchTransaction: batch });
await ready(container, 'edit', 0);
+ await addLine();
await change(qtyInputs()[0], '5');
await click(saveButton());
await waitFor(() => expect(batch).toHaveBeenCalledTimes(1));
@@ -244,7 +250,7 @@ describe('the Save guard holds until the batch settles, not for 1.5 s', () => {
expect(onSuccess).not.toHaveBeenCalled();
expect(await screen.findByText('The server refused the batch')).toBeTruthy();
// The grid takes input again after a failure, too.
- expect(qtyInputs()).toHaveLength(2);
+ expect(qtyInputs()).toHaveLength(1);
expect(qtyInputs()[0].disabled).toBe(false);
await save(() => batch.mock.calls.length);
@@ -261,6 +267,7 @@ describe('the Save guard holds until the batch settles, not for 1.5 s', () => {
});
await ready(container, 'create', 0);
+ await addLine();
await change(qtyInputs()[0], '5'); // the required header field stays empty
await click(saveButton());
expect(saveButton().disabled).toBe(true);
@@ -279,6 +286,7 @@ describe('the Save guard holds until the batch settles, not for 1.5 s', () => {
await ready(container, 'create', 0);
await change(refInput(container), 'PO-9');
+ await addLine();
await change(qtyInputs()[0], '5');
await click(saveButton());
await waitFor(() => expect(batch).toHaveBeenCalledTimes(1));
@@ -296,7 +304,7 @@ describe('the Save guard holds until the batch settles, not for 1.5 s', () => {
await waitFor(() => expect(onSuccess).toHaveBeenCalledTimes(1));
await waitFor(() => expect(saveButton().disabled).toBe(false));
// Cleared for the next entry, and still exactly one create.
- await waitFor(() => expect(qtyInputs()).toHaveLength(1));
+ await waitFor(() => expect(qtyInputs()).toHaveLength(0));
await waitFor(() => expect(refInput(container).value).toBe(''));
expect(batch).toHaveBeenCalledTimes(1);
});
@@ -306,6 +314,7 @@ describe('the Save guard holds until the batch settles, not for 1.5 s', () => {
const { container, onSuccess, onError } = renderForm({ batchTransaction: batch });
await ready(container, 'edit', 0);
+ await addLine();
await change(qtyInputs()[0], '5');
// The header form is the first |