From 46148aa1256dded6dad2d9ac16d7690c7d18a2ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaros=C5=82aw=20Sadzi=C5=84ski?= Date: Wed, 9 Nov 2022 20:45:55 +0100 Subject: [PATCH] (core) Fix for layout editor when fields are removed Summary: Fix for layout editor when fields are removed using the creator panel. Layout editor wasn't updated properly when "layoutSpecs" were changed. Test Plan: Updated Reviewers: georgegevoian Reviewed By: georgegevoian Differential Revision: https://phab.getgrist.com/D3700 --- app/client/components/RecordLayout.js | 2 +- test/nbrowser/gristUtils.ts | 70 ++++++++++++++------------- 2 files changed, 38 insertions(+), 34 deletions(-) diff --git a/app/client/components/RecordLayout.js b/app/client/components/RecordLayout.js index ce86e5c7..1193ad28 100644 --- a/app/client/components/RecordLayout.js +++ b/app/client/components/RecordLayout.js @@ -326,7 +326,7 @@ RecordLayout.prototype.buildLayoutDom = function(row, optCreateEditor) { ) ); - const sub = this.layoutSpec.subscribe((spec) => { layout.buildLayout(spec); }); + const sub = this.layoutSpec.subscribe((spec) => { layout.buildLayout(spec, createEditor); }); if (createEditor) { this.layoutEditor(RecordLayoutEditor.create(this, layout)); diff --git a/test/nbrowser/gristUtils.ts b/test/nbrowser/gristUtils.ts index d9f4ac65..d6f7963a 100644 --- a/test/nbrowser/gristUtils.ts +++ b/test/nbrowser/gristUtils.ts @@ -1041,43 +1041,46 @@ export async function openAddWidgetToPage() { // must be already opened when calling this function. export async function selectWidget( typeRe: RegExp|string, - tableRe: RegExp|string, + tableRe: RegExp|string = '', options: PageWidgetPickerOptions = {}) { - const tableEl = driver.findContent('.test-wselect-table', tableRe); - - // unselect all selected columns - for (const col of (await driver.findAll('.test-wselect-column[class*=-selected]'))) { - await col.click(); - } - - // let's select table - await tableEl.click(); - - const pivotEl = tableEl.find('.test-wselect-pivot'); - if (await pivotEl.isPresent()) { - await toggleSelectable(pivotEl, Boolean(options.summarize)); - } - - if (options.summarize) { - for (const columnEl of await driver.findAll('.test-wselect-column')) { - const label = await columnEl.getText(); - // TODO: Matching cols with regexp calls for trouble and adds no value. I think function should be - // rewritten using string matching only. - const goal = Boolean(options.summarize.find(r => label.match(r))); - await toggleSelectable(columnEl, goal); - } - } - - if (options.selectBy) { - // select link - await driver.find('.test-wselect-selectby').doClick(); - await driver.findContent('.test-wselect-selectby option', options.selectBy).doClick(); - } - // select right type await driver.findContent('.test-wselect-type', typeRe).doClick(); + if (tableRe) { + const tableEl = driver.findContent('.test-wselect-table', tableRe); + + // unselect all selected columns + for (const col of (await driver.findAll('.test-wselect-column[class*=-selected]'))) { + await col.click(); + } + + // let's select table + await tableEl.click(); + + const pivotEl = tableEl.find('.test-wselect-pivot'); + if (await pivotEl.isPresent()) { + await toggleSelectable(pivotEl, Boolean(options.summarize)); + } + + if (options.summarize) { + for (const columnEl of await driver.findAll('.test-wselect-column')) { + const label = await columnEl.getText(); + // TODO: Matching cols with regexp calls for trouble and adds no value. I think function should be + // rewritten using string matching only. + const goal = Boolean(options.summarize.find(r => label.match(r))); + await toggleSelectable(columnEl, goal); + } + } + + if (options.selectBy) { + // select link + await driver.find('.test-wselect-selectby').doClick(); + await driver.findContent('.test-wselect-selectby option', options.selectBy).doClick(); + } + } + + if (options.dontAdd) { return; } @@ -1985,7 +1988,8 @@ export class Session { return doc; } - public async tempNewDoc(cleanup: Cleanup, docName: string, {load} = {load: true}) { + public async tempNewDoc(cleanup: Cleanup, docName: string = '', {load} = {load: true}) { + docName ||= `Test${Date.now()}`; const docId = await createNewDoc(this.settings.name, this.settings.orgDomain, this.settings.workspace, docName, {email: this.settings.email}); if (load) {