Skip to content

Commit 636fcd6

Browse files
Copilothotlong
andcommitted
test: address code review - improve switch field assertions, add pageSizeOptions boundary test
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 43c7d73 commit 636fcd6

2 files changed

Lines changed: 28 additions & 3 deletions

File tree

apps/console/src/__tests__/ViewConfigPanel.test.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2674,6 +2674,25 @@ describe('ViewConfigPanel', () => {
26742674
}));
26752675
});
26762676

2677+
it('filters invalid pageSizeOptions values (non-positive, NaN)', () => {
2678+
const onViewUpdate = vi.fn();
2679+
render(
2680+
<ViewConfigPanel
2681+
open={true}
2682+
onClose={vi.fn()}
2683+
activeView={mockActiveView}
2684+
objectDef={mockObjectDef}
2685+
onViewUpdate={onViewUpdate}
2686+
/>
2687+
);
2688+
2689+
const input = screen.getByTestId('input-pagination-pageSizeOptions');
2690+
fireEvent.change(input, { target: { value: 'abc, 50, -10, 0' } });
2691+
expect(onViewUpdate).toHaveBeenCalledWith('pagination', expect.objectContaining({
2692+
pageSizeOptions: [50],
2693+
}));
2694+
});
2695+
26772696
// ── Boundary: densityMode enum selection ──
26782697

26792698
it('changes densityMode to all enum values', () => {

apps/console/src/__tests__/view-config-schema.test.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -738,20 +738,26 @@ describe('spec alignment', () => {
738738
return section.fields.find(f => f.key === fieldKey)!;
739739
}
740740

741-
it('collapseAllByDefault defaults to false (explicitTrue)', () => {
741+
it('collapseAllByDefault is an explicitTrue switch field', () => {
742742
// explicitTrue fields only show checked when value === true
743743
const field = findField('appearance', 'collapseAllByDefault');
744744
expect(field.render).toBeDefined();
745+
expect(field.type).toBe('custom');
746+
expect(field.key).toBe('collapseAllByDefault');
745747
});
746748

747-
it('showDescription defaults to true (defaultOn)', () => {
749+
it('showDescription is a defaultOn switch field', () => {
748750
const field = findField('appearance', 'showDescription');
749751
expect(field.render).toBeDefined();
752+
expect(field.type).toBe('custom');
753+
expect(field.key).toBe('showDescription');
750754
});
751755

752-
it('inlineEdit defaults to true (defaultOn)', () => {
756+
it('inlineEdit is a defaultOn switch field', () => {
753757
const field = findField('userActions', 'inlineEdit');
754758
expect(field.render).toBeDefined();
759+
expect(field.type).toBe('custom');
760+
expect(field.key).toBe('inlineEdit');
755761
});
756762
});
757763

0 commit comments

Comments
 (0)