mirror of
https://github.com/simonw/datasette.git
synced 2026-07-09 17:14:35 +02:00
Fix bulk insert Playwright expectations
Keep copied spreadsheet templates aligned with the single-row insert columns while still previewing auto primary keys in bulk insert rows. Treat invalid JSON during live bulk-insert validation as unfinished input so Firefox does not expose browser-specific parse errors while typing.
This commit is contained in:
parent
b1d990ceba
commit
8f32a8f134
2 changed files with 12 additions and 5 deletions
|
|
@ -5611,7 +5611,7 @@ async function loadBulkInsertTextFile(state, file) {
|
|||
}
|
||||
|
||||
function bulkInsertTemplateText(state) {
|
||||
return (state.bulkInsertColumns || []).join("\t");
|
||||
return (state.bulkInsertTemplateColumns || []).join("\t");
|
||||
}
|
||||
|
||||
async function copyTextToClipboard(text) {
|
||||
|
|
@ -5893,8 +5893,7 @@ function bulkInsertLiveValidationShouldWait(message) {
|
|||
return (
|
||||
message === "Paste rows before previewing." ||
|
||||
message === "No data rows found to preview." ||
|
||||
(message.indexOf("Invalid JSON:") === 0 &&
|
||||
message.indexOf("Unexpected end") !== -1)
|
||||
message.indexOf("Invalid JSON:") === 0
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -6607,7 +6606,10 @@ function renderRowInsertFields(state, data) {
|
|||
state.bulkInsertColumns = bulkColumns.map(function (column) {
|
||||
return column.name;
|
||||
});
|
||||
state.copyTemplateButton.disabled = !state.bulkInsertColumns.length;
|
||||
state.bulkInsertTemplateColumns = columns.map(function (column) {
|
||||
return column.name;
|
||||
});
|
||||
state.copyTemplateButton.disabled = !state.bulkInsertTemplateColumns.length;
|
||||
setBulkInsertCopyButtonReady(state);
|
||||
syncBulkInsertConflictUi(state);
|
||||
clearTimeout(state.copyTemplateResetTimer);
|
||||
|
|
@ -6784,6 +6786,7 @@ function ensureRowEditDialog(manager) {
|
|||
bulkInsertHasPrimaryKeyColumns: false,
|
||||
bulkInsertLiveValidationError: null,
|
||||
bulkInsertColumns: [],
|
||||
bulkInsertTemplateColumns: [],
|
||||
bulkInsertColumnDetails: [],
|
||||
bulkInsertPreviewRows: null,
|
||||
bulkInsertPreviewReady: false,
|
||||
|
|
|
|||
|
|
@ -1109,10 +1109,14 @@ def test_insert_row_flow_uses_custom_column_field(page, datasette_server):
|
|||
"Previewing 1 row."
|
||||
)
|
||||
preview_text = dialog.locator(".row-edit-bulk-preview-table").inner_text()
|
||||
assert "id" in preview_text
|
||||
assert "title" in preview_text
|
||||
assert "metadata" in preview_text
|
||||
assert "id" not in preview_text
|
||||
assert "From CSV" in preview_text
|
||||
assert (
|
||||
dialog.locator(".row-edit-bulk-preview-auto").first.text_content()
|
||||
== "auto"
|
||||
)
|
||||
assert "null" not in preview_text
|
||||
assert "undefined" not in preview_text
|
||||
preview_cell_style = dialog.locator(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue