From 955fdf4ae770714d3b7d2bcf5ec3bd774b544369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaros=C5=82aw=20Sadzi=C5=84ski?= Date: Mon, 14 Nov 2022 12:30:50 +0100 Subject: [PATCH] (core) Fixing multicolumn bug on a card view Summary: Fixing bug on a card view. Type selector was always showing 'mixed type' value. Test Plan: Updated Reviewers: georgegevoian Reviewed By: georgegevoian Differential Revision: https://phab.getgrist.com/D3704 --- app/client/ui/RightPanel.ts | 6 +++++- test/nbrowser/MultiColumn.ts | 12 ++++++++++++ test/nbrowser/gristUtils.ts | 23 +++++++++++++++++++++-- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/app/client/ui/RightPanel.ts b/app/client/ui/RightPanel.ts index 40f60351..e3baa4a3 100644 --- a/app/client/ui/RightPanel.ts +++ b/app/client/ui/RightPanel.ts @@ -193,7 +193,11 @@ export class RightPanel extends Disposable { const selectedColumns = owner.autoDispose(ko.computed(() => { const vsi = this._gristDoc.viewModel.activeSection?.().viewInstance(); - return vsi && vsi.selectedColumns ? vsi.selectedColumns() : null; + if (vsi && vsi.selectedColumns) { + return vsi.selectedColumns(); + } + const field = fieldBuilder()?.field; + return field ? [field] : []; })); const isMultiSelect = owner.autoDispose(ko.pureComputed(() => { diff --git a/test/nbrowser/MultiColumn.ts b/test/nbrowser/MultiColumn.ts index 022fe6da..10470679 100644 --- a/test/nbrowser/MultiColumn.ts +++ b/test/nbrowser/MultiColumn.ts @@ -61,6 +61,18 @@ describe('MultiColumn', function() { } }); + it('should not work on card view', async () => { + await gu.changeWidget('Card'); + await gu.openColumnPanel(); + assert.notEqual(await gu.getType(), "Mixed types"); + await gu.openColumnPanel(); + // Should be able to change type. + await gu.getDetailCell('Test1', 1); + await gu.enterCell("aa"); + await gu.setType("Integer", {apply: true}); + assert.equal(await gu.getType(), "Integer"); + }); + it('should undo color change', async () => { // This is test for a bug, colors were not saved when "click outside" was done by clicking // one of the cells. diff --git a/test/nbrowser/gristUtils.ts b/test/nbrowser/gristUtils.ts index d010defa..cced2ce6 100644 --- a/test/nbrowser/gristUtils.ts +++ b/test/nbrowser/gristUtils.ts @@ -1103,6 +1103,13 @@ export async function selectWidget( await waitForServer(); } +export async function changeWidget(type: string) { + await openWidgetPanel(); + await driver.findContent('.test-right-panel button', /Change Widget/).click(); + await selectWidget(type); + await waitForServer(); +} + /** * Toggle elem if not selected. Expects elem to be clickable and to have a class ending with * -selected when selected. @@ -1329,6 +1336,14 @@ export async function openWidgetPanel() { await driver.find('.test-right-tab-pagewidget').click(); } +/** + * Opens a Creator Panel on Widget/Table settings tab. + */ + export async function openColumnPanel() { + await toggleSidePanel('right', 'open'); + await driver.find('.test-right-tab-field').click(); +} + /** * Moves a column from a hidden to visible section. * Needs a visible Creator panel. @@ -1521,13 +1536,17 @@ export async function deleteColumn(col: IColHeader|string) { /** * Sets the type of the currently selected field to value. */ -export async function setType(type: RegExp|string, options: {skipWait?: boolean} = {}) { +export async function setType(type: RegExp|string, options: {skipWait?: boolean, apply?: boolean} = {}) { await toggleSidePanel('right', 'open'); await driver.find('.test-right-tab-field').click(); await driver.find('.test-fbuilder-type-select').click(); type = typeof type === 'string' ? exactMatch(type) : type; await driver.findContentWait('.test-select-menu .test-select-row', type, 500).click(); - if (!options.skipWait) { await waitForServer(); } + if (!options.skipWait || options.apply) { await waitForServer(); } + if (options.apply) { + await driver.findWait('.test-type-transform-apply', 1000).click(); + await waitForServer(); + } } /**