Skip to content

Commit a1a0506

Browse files
committed
review
1 parent c333938 commit a1a0506

2 files changed

Lines changed: 30 additions & 1 deletion

File tree

packages/core-ui/js/gui_components/data-generator-page.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,9 @@ class DataGeneratorPage {
662662
return parsed;
663663
}
664664

665-
this.schemaRows = parsed.rows.length > 0 ? parsed.rows : [this.createBlankSchemaRow()];
665+
// Keep empty text schemas as zero rows while in text mode so validation can
666+
// report "Add at least one schema row." instead of introducing a synthetic blank row.
667+
this.schemaRows = parsed.rows;
666668
return { rows: this.schemaRows, errors: [] };
667669
}
668670

packages/core-ui/src/tests/generator/data-generator-page.test.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,4 +846,31 @@ describe('DataGeneratorPage', () => {
846846
text: 'csv:async:2',
847847
});
848848
});
849+
850+
test('empty text mode schema keeps zero rows and shows add-row validation', async () => {
851+
const page = new DataGeneratorPage({
852+
parentElement: document.getElementById('app'),
853+
documentObj: document,
854+
alertFn,
855+
faker: { word: { noun: () => 'x' } },
856+
RandExp: function RandExp() {},
857+
TabulatorCtor: FakeTabulator,
858+
GridExtensionClass: FakeGridExtension,
859+
ExporterClass: FakeExporter,
860+
DownloadClass: FakeDownload,
861+
TestDataGeneratorClass: FakeTestDataGenerator,
862+
});
863+
page.init();
864+
865+
const toggle = document.getElementById('schemaModeToggleButton');
866+
toggle.click();
867+
868+
const textArea = document.getElementById('generatorSchemaText');
869+
textArea.value = '';
870+
871+
await page.generateDataFile();
872+
873+
expect(alertFn).toHaveBeenCalledWith('Add at least one schema row.');
874+
expect(page.schemaRows).toEqual([]);
875+
});
849876
});

0 commit comments

Comments
 (0)