diff --git a/app/client/components/GridView.js b/app/client/components/GridView.js index d028d016..cafc71ef 100644 --- a/app/client/components/GridView.js +++ b/app/client/components/GridView.js @@ -891,6 +891,14 @@ GridView.prototype.insertColumn = async function(colId = null, options = {}) { const newColInfo = await this.viewSection.insertColumn(colId, {colInfo, index}); this.selectColumn(index); if (!skipPopup) { this.currentEditingColumnIndex(index); } + // we want to show creator panel in some cases, but only when "rename panel" is dismissed + const sub = this.currentEditingColumnIndex.subscribe(state=>{ + // if no column is edited we can assume that rename panel is closed + if(state<0){ + options.onPopupClose?.(); + sub.dispose(); + } + }); return newColInfo; }; diff --git a/app/client/components/commandList.ts b/app/client/components/commandList.ts index bf32a778..d943e9ec 100644 --- a/app/client/components/commandList.ts +++ b/app/client/components/commandList.ts @@ -100,6 +100,7 @@ export type CommandName = | 'duplicateRows' | 'sortAsc' | 'sortDesc' + | 'showPopup' | 'addSortAsc' | 'addSortDesc' | 'filterByThisCellValue' @@ -119,7 +120,6 @@ export type CommandName = | 'insertField' ; - export interface CommandDef { name: CommandName; keys: string[]; @@ -283,6 +283,11 @@ export const groups: CommendGroupDef[] = [{ keys: ['Space'], desc: 'Show the record card widget of the selected record', }, + { + name: 'showPopup', + keys:[], + desc: 'showing a behavioral popup' + }, { name: 'createForm', keys: [], @@ -292,7 +297,7 @@ export const groups: CommendGroupDef[] = [{ name: 'insertField', keys: [], desc: 'Insert new column in default location', - }, + } ] }, { group: 'Navigation', diff --git a/app/client/declarations.d.ts b/app/client/declarations.d.ts index 056869f6..7b9c9cdf 100644 --- a/app/client/declarations.d.ts +++ b/app/client/declarations.d.ts @@ -63,6 +63,7 @@ declare module "app/client/components/BaseView" { public isTruncated: ko.Observable; public tableModel: DataTableModel; public selectionSummary?: SelectionSummary; + public currentEditingColumnIndex: ko.Observable; constructor(gristDoc: GristDoc, viewSectionModel: any, options?: {addNewRow?: boolean, isPreview?: boolean}); public setCursorPos(cursorPos: CursorPos): void; @@ -92,6 +93,7 @@ declare module 'app/client/components/GridView' { colInfo?: ColInfo; index?: number; skipPopup?: boolean; + onPopupClose?: () => void; } namespace GridView {} @@ -102,7 +104,10 @@ declare module 'app/client/components/GridView' { public gristDoc: GristDoc; constructor(gristDoc: GristDoc, viewSectionModel: any, isPreview?: boolean); - public insertColumn(colId?: string|null, options?: InsertColOptions): Promise; + public insertColumn( + colId?: string|null, + options?: InsertColOptions, + ): Promise; public showColumn(colRef: number, index?: number): Promise; } export = GridView; diff --git a/app/client/ui/GridViewMenus.ts b/app/client/ui/GridViewMenus.ts index 6753a6e7..04c65f91 100644 --- a/app/client/ui/GridViewMenus.ts +++ b/app/client/ui/GridViewMenus.ts @@ -6,7 +6,7 @@ import {ColumnRec} from "app/client/models/entities/ColumnRec"; import {ViewFieldRec} from 'app/client/models/entities/ViewFieldRec'; import {GristTooltips} from 'app/client/ui/GristTooltips'; import {withInfoTooltip} from 'app/client/ui/tooltips'; -import {testId, theme, vars} from 'app/client/ui2018/cssVars'; +import {isNarrowScreen, testId, theme, vars} from 'app/client/ui2018/cssVars'; import {IconName} from "app/client/ui2018/IconList"; import {icon} from 'app/client/ui2018/icons'; import { @@ -24,7 +24,7 @@ import { SearchableMenuItem, } from 'app/client/ui2018/menus'; import * as UserType from "app/client/widgets/UserType"; -import {isListType, RecalcWhen} from "app/common/gristTypes"; +import {isFullReferencingType, isListType, RecalcWhen} from "app/common/gristTypes"; import {Sort} from 'app/common/SortSpec'; import {dom, DomElementArg, styled} from 'grainjs'; import * as weasel from 'popweasel'; @@ -59,12 +59,18 @@ export function getColumnTypes(gristDoc: GristDoc, tableId: string, pure = false `RefList:${tableId}`, "Attachments"]; return typeNames.map(type => ({type, obj: UserType.typeDefs[type.split(':')[0]]})) - .map((ct): { displayName: string, colType: string, testIdName: string, icon: IconName | undefined } => ({ - displayName: t(ct.obj.label), - colType: ct.type, - testIdName: ct.obj.label.toLowerCase().replace(' ', '-'), - icon: ct.obj.icon - })).map(ct => { + .map((ct): { + displayName: string, + colType: string, + testIdName: string, + icon: IconName | undefined, + openCreatorPanel: boolean } => ({ + displayName: t(ct.obj.label), + colType: ct.type, + testIdName: ct.obj.label.toLowerCase().replace(' ', '-'), + icon: ct.obj.icon, + openCreatorPanel: isFullReferencingType(ct.type) + })).map(ct => { if (!pure) { return ct; } else { return { @@ -94,7 +100,12 @@ function buildAddNewColumMenuSection(gridView: GridView, index?: number): DomEle ...columnTypes.map((colType) => menuItem( async () => { - await gridView.insertColumn(null, {index, colInfo: {type: colType.colType}}); + await gridView.insertColumn(null, {index, colInfo: {type: colType.colType}, onPopupClose: ()=> { + if(!colType.openCreatorPanel || isNarrowScreen()) { return; } + commands.allCommands.fieldTabOpen.run(); + commands.allCommands.rightPanelOpen.run(); + commands.allCommands.showPopup.run({popup: "referenceColumnsConfig"}); + }}); }, menuIcon(colType.icon as IconName), colType.displayName === 'Reference'? diff --git a/app/client/ui/PagePanels.ts b/app/client/ui/PagePanels.ts index 4e388f18..48ef45dd 100644 --- a/app/client/ui/PagePanels.ts +++ b/app/client/ui/PagePanels.ts @@ -109,6 +109,7 @@ export function pagePanels(page: PageContents) { const watcher = new TransitionWatcher(rightPaneDom); watcher.onDispose(() => resolve(undefined)); right.panelOpen.set(true); + }), }, null, true); let contentWrapper: HTMLElement; diff --git a/app/client/ui/RightPanel.ts b/app/client/ui/RightPanel.ts index 0dfab821..4911d14e 100644 --- a/app/client/ui/RightPanel.ts +++ b/app/client/ui/RightPanel.ts @@ -13,7 +13,6 @@ * All methods above return an object which may be disposed to close and dispose that specific * tab from the outside (e.g. when GristDoc is disposed). */ - import * as commands from 'app/client/components/commands'; import {FieldModel} from 'app/client/components/Forms/Field'; import {FormView} from 'app/client/components/Forms/FormView'; @@ -147,7 +146,7 @@ export class RightPanel extends Disposable { viewTabOpen: () => this._openViewTab(), viewTabFocus: () => this._viewTabFocus(), sortFilterTabOpen: () => this._openSortFilter(), - dataSelectionTabOpen: () => this._openDataSelection() + dataSelectionTabOpen: () => this._openDataSelection(), }, this, true)); // When a page widget is changed, subType might not be valid anymore, so reset it. diff --git a/app/client/widgets/FieldBuilder.ts b/app/client/widgets/FieldBuilder.ts index ed6165ea..ec9496ca 100644 --- a/app/client/widgets/FieldBuilder.ts +++ b/app/client/widgets/FieldBuilder.ts @@ -40,6 +40,7 @@ import { bundleChanges, Computed, Disposable, fromKo, import isEqual from 'lodash/isEqual'; import * as ko from 'knockout'; import * as _ from 'underscore'; +import * as commands from "../components/commands"; const testId = makeTestId('test-fbuilder-'); const t = makeT('FieldBuilder'); @@ -110,6 +111,8 @@ export class FieldBuilder extends Disposable { private readonly _showRefConfigPopup: ko.Observable; private readonly _isEditorActive = Observable.create(this, false); + + public constructor(public readonly gristDoc: GristDoc, public readonly field: ViewFieldRec, private _cursor: Cursor, private _options: { isPreview?: boolean } = {}) { super(); @@ -205,6 +208,14 @@ export class FieldBuilder extends Disposable { this.diffImpl = this.autoDispose(DiffBox.create(this.field)); this._showRefConfigPopup = ko.observable(false); + + this.autoDispose(commands.createGroup({ + showPopup: (args: any) => { + if(args.popup==='referenceColumnsConfig'){ + this._showRefConfigPopup(true); + } + } + }, this, true)); } public buildSelectWidgetDom() { @@ -400,14 +411,17 @@ export class FieldBuilder extends Disposable { }); return [ cssLabel(t('DATA FROM TABLE'), - !this._showRefConfigPopup.peek() ? null : this.gristDoc.behavioralPromptsManager.attachTip( - 'referenceColumnsConfig', - { - onDispose: () => this._showRefConfigPopup(false), - popupOptions: { - placement: 'left-start', - }, - } + kd.maybe(this._showRefConfigPopup, () => { + return dom('div', this.gristDoc.behavioralPromptsManager.attachTip( + 'referenceColumnsConfig', + { + onDispose: () => this._showRefConfigPopup(false), + popupOptions: { + placement: 'left-start', + }, + } + )); + }, ), ), cssRow( diff --git a/test/nbrowser/GridViewNewColumnMenu.ts b/test/nbrowser/GridViewNewColumnMenu.ts index d9233f3c..5e836e84 100644 --- a/test/nbrowser/GridViewNewColumnMenu.ts +++ b/test/nbrowser/GridViewNewColumnMenu.ts @@ -5,6 +5,7 @@ import {setupTestSuite} from "./testUtils"; import {UserAPIImpl} from 'app/common/UserAPI'; describe('GridViewNewColumnMenu', function () { + const STANDARD_WAITING_TIME = 1000; this.timeout('2m'); const cleanup = setupTestSuite(); gu.bigScreen(); @@ -75,17 +76,17 @@ describe('GridViewNewColumnMenu', function () { it('should show rename menu after a new column click', async function () { await clickAddColumn(); - await driver.findWait('.test-new-columns-menu-add-new', 100).click(); - await driver.findWait('.test-column-title-popup', 100, 'rename menu is not present'); + await driver.findWait('.test-new-columns-menu-add-new', STANDARD_WAITING_TIME).click(); + await driver.findWait('.test-column-title-popup', STANDARD_WAITING_TIME, 'rename menu is not present'); await closeAddColumnMenu(); }); it('should create a new column', async function () { await clickAddColumn(); - await driver.findWait('.test-new-columns-menu-add-new', 100).click(); + await driver.findWait('.test-new-columns-menu-add-new', STANDARD_WAITING_TIME).click(); await gu.waitForServer(); //discard rename menu - await driver.find('.test-column-title-close').click(); + await driver.findWait('.test-column-title-close', STANDARD_WAITING_TIME).click(); //check if new column is present const columns = await gu.getColumnNames(); assert.include(columns, 'D', 'new column is not present'); @@ -101,30 +102,30 @@ describe('GridViewNewColumnMenu', function () { it('should support inserting before selected column', async function () { await gu.openColumnMenu('A', 'Insert column to the left'); - await driver.findWait(".test-new-columns-menu", 100); + await driver.findWait(".test-new-columns-menu", STANDARD_WAITING_TIME); await gu.sendKeys(Key.ENTER); await gu.waitForServer(); - await driver.findWait('.test-column-title-close', 100).click(); + await driver.findWait('.test-column-title-close', STANDARD_WAITING_TIME).click(); const columns = await gu.getColumnNames(); assert.deepEqual(columns, ['D', 'A', 'B', 'C']); }); it('should support inserting after selected column', async function () { await gu.openColumnMenu('A', 'Insert column to the right'); - await driver.findWait(".test-new-columns-menu", 100); + await driver.findWait(".test-new-columns-menu", STANDARD_WAITING_TIME); await gu.sendKeys(Key.ENTER); await gu.waitForServer(); - await driver.findWait('.test-column-title-close', 100).click(); + await driver.findWait('.test-column-title-close', STANDARD_WAITING_TIME).click(); const columns = await gu.getColumnNames(); assert.deepEqual(columns, ['A', 'D', 'B', 'C']); }); it('should support inserting after the last visible column', async function () { await gu.openColumnMenu('C', 'Insert column to the right'); - await driver.findWait(".test-new-columns-menu", 100); + await driver.findWait(".test-new-columns-menu", STANDARD_WAITING_TIME); await gu.sendKeys(Key.ENTER); await gu.waitForServer(); - await driver.findWait('.test-column-title-close', 100).click(); + await driver.findWait('.test-column-title-close', STANDARD_WAITING_TIME).click(); const columns = await gu.getColumnNames(); assert.deepEqual(columns, ['A', 'B', 'C', 'D']); }); @@ -147,39 +148,10 @@ describe('GridViewNewColumnMenu', function () { describe('create column with type', function () { revertThis(); - it('should show "Add Column With type" option', async function () { - // open add new colum menu - await clickAddColumn(); - // check if "Add Column With type" option is persent - const addWithType = await driver.findWait( - '.test-new-columns-menu-add-with-type', - 100, - 'Add Column With Type is not present'); - assert.equal(await addWithType.getText(), 'Add column with type'); - }); - - it('should display reference column popup when opened for the first time', async function(){ - // open add new colum menu - await clickAddColumn(); - // select "Add Column With type" option - await driver.findWait('.test-new-columns-menu-add-with-type', 100).click(); - // wait for submenu to appear - await driver.findWait('.test-new-columns-menu-add-with-type-submenu', 100); - // check if popup is showed - await driver.findWait('.test-behavioral-prompt', 100, 'Reference column popup is not present'); - // close popup - await gu.dismissBehavioralPrompts(); - // close menu - await closeAddColumnMenu(); - // open it again - await clickAddColumn(); - await driver.findWait('.test-new-columns-menu-add-with-type', 100).click(); - await driver.findWait('.test-new-columns-menu-add-with-type-submenu', 100); - // popup should not be showed - assert.isFalse(await driver.find('.test-behavioral-prompt').isPresent()); - await gu.disableTips(session.email); - await closeAddColumnMenu(); - }); + const columsThatShouldTriggerSideMenu = [ + "Reference", + "Reference List" + ]; const optionsToBeDisplayed = [ "Text", @@ -194,14 +166,56 @@ describe('GridViewNewColumnMenu', function () { "Reference List", "Attachment", ].map((option) => ({type:option, testClass: option.toLowerCase().replace(' ', '-')})); - for (const option of optionsToBeDisplayed) { + + + describe('on desktop', function () { + gu.bigScreen(); + + it('should show "Add Column With type" option', async function () { + // open add new colum menu + await clickAddColumn(); + // check if "Add Column With type" option is persent + const addWithType = await driver.findWait( + '.test-new-columns-menu-add-with-type', + 100, + 'Add Column With Type is not present'); + assert.equal(await addWithType.getText(), 'Add column with type'); + }); + + it('should display reference column popup when opened for the first time', async function(){ + await gu.enableTips(session.email); + // open add new colum menu + await clickAddColumn(); + // select "Add Column With type" option + await driver.findWait('.test-new-columns-menu-add-with-type', STANDARD_WAITING_TIME).click(); + // wait for submenu to appear + await driver.findWait('.test-new-columns-menu-add-with-type-submenu', STANDARD_WAITING_TIME); + // check if popup is showed + await driver.findWait('.test-behavioral-prompt', + STANDARD_WAITING_TIME, + 'Reference column popup is not present'); + // close popup + await gu.dismissBehavioralPrompts(); + // close menu + await closeAddColumnMenu(); + // open it again + await clickAddColumn(); + await driver.findWait('.test-new-columns-menu-add-with-type', STANDARD_WAITING_TIME).click(); + await driver.findWait('.test-new-columns-menu-add-with-type-submenu', STANDARD_WAITING_TIME); + // popup should not be showed + assert.isFalse(await driver.find('.test-behavioral-prompt').isPresent()); + await gu.disableTips(session.email); + await closeAddColumnMenu(); + }); + + for (const option of optionsToBeDisplayed) { it(`should allow to select column type ${option.type}`, async function () { // open add new colum menu await clickAddColumn(); // select "Add Column With type" option - await driver.findWait('.test-new-columns-menu-add-with-type', 100).click(); + await driver.findWait('.test-new-columns-menu-add-with-type', STANDARD_WAITING_TIME).click(); // wait for submenu to appear - await driver.findWait('.test-new-columns-menu-add-with-type-submenu', 100); + await driver.findWait('.test-new-columns-menu-add-with-type-submenu', STANDARD_WAITING_TIME); // check if it is present in the menu const element = await driver.findWait( `.test-new-columns-menu-add-${option.testClass}`.toLowerCase(), @@ -209,18 +223,124 @@ describe('GridViewNewColumnMenu', function () { `${option.type} option is not present`); // click on the option and check if column is added with a proper type await element.click(); - await gu.waitForServer(); - //discard rename menu - await driver.findWait('.test-column-title-close', 100).click(); - //check if new column is present - await gu.selectColumn('D'); - await gu.openColumnPanel(); - const type = await gu.getType(); - assert.equal(type, option.type); + await gu.waitForServer();//discard rename menu + await driver.findWait('.test-column-title-close', STANDARD_WAITING_TIME).click(); + //check if new column is present - await gu.undo(1); - }); - } + await gu.selectColumn('D'); + await gu.openColumnPanel(); + const type = await gu.getType(); + assert.equal(type, option.type); + + await gu.undo(1); + }); + } + + for (const optionsTriggeringMenu of optionsToBeDisplayed.filter((option) => + columsThatShouldTriggerSideMenu.includes(option.type))) { + it(`should open Right Menu on Column section after choosing ${optionsTriggeringMenu.type}`, async function(){ + await gu.enableTips(session.email); + //close right panel just in case. + await gu.toggleSidePanel("right", "close"); + // open add new colum menu + await clickAddColumn(); + // select "Add Column With type" option + await driver.findWait('.test-new-columns-menu-add-with-type', STANDARD_WAITING_TIME).click(); + // wait for submenu to appear + await driver.findWait('.test-new-columns-menu-add-with-type-submenu', STANDARD_WAITING_TIME); + // check if it is present in the menu + const element = await driver.findWait( + `.test-new-columns-menu-add-${optionsTriggeringMenu.testClass}`.toLowerCase(), + STANDARD_WAITING_TIME, + `${optionsTriggeringMenu.type} option is not present`); + // click on the option and check if column is added with a proper type + await element.click(); + //discard rename menu + await driver.findWait('.test-column-title-close', STANDARD_WAITING_TIME).click(); + await gu.waitForServer(); + //check if left menu is opened on column section + assert.isTrue(await driver.findWait('.test-right-tab-field', 1000).isDisplayed()); + + await gu.disableTips(session.email); + await gu.dismissBehavioralPrompts(); + await gu.toggleSidePanel("right", "close"); + await gu.undo(1); + }); + + it(`should show referenceColumnsConfig in right Column section + when ${optionsTriggeringMenu.type} type is chosen`, + async function(){ + //close right panel just in case. + await gu.toggleSidePanel("right", "close"); + await gu.enableTips(session.email); + await driver.executeScript('resetDismissedPopups()'); + // open add new colum menu + await clickAddColumn(); + // select "Add Column With type" option + await driver.findWait('.test-new-columns-menu-add-with-type', STANDARD_WAITING_TIME).click(); + // wait for submenu to appear + await driver.findWait('.test-new-columns-menu-add-with-type-submenu', STANDARD_WAITING_TIME); + // check if it is present in the menu + const element = await driver.findWait( + `.test-new-columns-menu-add-${optionsTriggeringMenu.testClass}`.toLowerCase(), + STANDARD_WAITING_TIME, + `${optionsTriggeringMenu.type} option is not present`); + // click on the option and check if column is added with a proper type + await element.click(); + //discard rename menu + await driver.findWait('.test-column-title-close', STANDARD_WAITING_TIME).click(); + await gu.waitForServer(); + //check if referenceColumnsConfig is present + await gu.waitToPass(async ()=> assert.isTrue( + await driver.findContentWait( + '.test-behavioral-prompt-title', + 'Reference Columns', + STANDARD_WAITING_TIME*2 + ).isDisplayed() + ), 5000); + await gu.dismissBehavioralPrompts(); + await gu.disableTips(session.email); + + await gu.toggleSidePanel("right", "close"); + await gu.undo(1); + }); + } + }); + + describe('on mobile', function () { + gu.narrowScreen(); + for (const optionsTriggeringMenu of optionsToBeDisplayed.filter((option) => + columsThatShouldTriggerSideMenu.includes(option.type))) { + it('should not show Right Menu when user is on the mobile/narrow screen', async function() { + await gu.enableTips(session.email); + //close right panel just in case. + await gu.toggleSidePanel("right", "close"); + // open add new colum menu + await clickAddColumn(); + // select "Add Column With type" option + await driver.findWait('.test-new-columns-menu-add-with-type', STANDARD_WAITING_TIME).click(); + // wait for submenu to appear + await driver.findWait('.test-new-columns-menu-add-with-type-submenu', STANDARD_WAITING_TIME); + // check if it is present in the menu + const element = await driver.findWait( + `.test-new-columns-menu-add-${optionsTriggeringMenu.testClass}`.toLowerCase(), + STANDARD_WAITING_TIME, + `${optionsTriggeringMenu.type} option is not present`); + // click on the option and check if column is added with a proper type + await element.click(); + //discard rename menu + await driver.findWait('.test-column-title-close', STANDARD_WAITING_TIME).click(); + await gu.waitForServer(); + //check if left menu is opened on column section + assert.isFalse(await driver.find('.test-right-tab-field').isPresent()); + + await gu.disableTips(session.email); + await gu.dismissBehavioralPrompts(); + await gu.toggleSidePanel("right", "close"); + await gu.undo(1); + }); + } + }); }); describe('create formula column', function(){ @@ -229,10 +349,10 @@ describe('GridViewNewColumnMenu', function () { // open add new colum menu await clickAddColumn(); // check if "create formula column" option is present - const addWithType = await driver.findWait('.test-new-columns-menu-add-formula', 100, + const addWithType = await driver.findWait('.test-new-columns-menu-add-formula', STANDARD_WAITING_TIME, 'Add formula column is not present'); // check if it has a tooltip button - const tooltip = await addWithType.findWait('.test-info-tooltip', 100, + const tooltip = await addWithType.findWait('.test-info-tooltip', STANDARD_WAITING_TIME, 'Tooltip button is not present'); // check if tooltip is show after hovering await tooltip.mouseMove(); @@ -260,7 +380,7 @@ describe('GridViewNewColumnMenu', function () { // open add new colum menu await clickAddColumn(); // select "create formula column" option - await driver.findWait('.test-new-columns-menu-add-formula', 100).click(); + await driver.findWait('.test-new-columns-menu-add-formula', STANDARD_WAITING_TIME).click(); // there should not be a rename poup assert.isFalse(await driver.find('test-column-title-popup').isPresent()); //check if new column is present @@ -301,7 +421,9 @@ describe('GridViewNewColumnMenu', function () { // Check that the hidden section is present and has the expected columns. const checkSection = async (...columns: string[]) => { await clickAddColumn(); - await driver.findWait(".test-new-columns-menu-hidden-columns-header", 100, 'hidden section is not present'); + await driver.findWait(".test-new-columns-menu-hidden-columns-header", + STANDARD_WAITING_TIME, + 'hidden section is not present'); for (const column of columns) { assert.isTrue( await driver.findContent('.test-new-columns-menu-hidden-column-inlined', column).isPresent(), @@ -361,7 +483,9 @@ describe('GridViewNewColumnMenu', function () { // Now make sure we see all of them in the submenu. await clickAddColumn(); - await driver.findWait(".test-new-columns-menu-hidden-columns-menu", 100, 'hidden section is not present'); + await driver.findWait(".test-new-columns-menu-hidden-columns-menu", + STANDARD_WAITING_TIME, + 'hidden section is not present'); assert.isFalse(await driver.find(".test-new-columns-menu-hidden-columns-header").isPresent()); // We don't see any hidden columns in the main menu. @@ -373,7 +497,9 @@ describe('GridViewNewColumnMenu', function () { // And we should see all the hidden columns. for (const column of columns.slice(1)) { assert.isTrue( - await driver.findContentWait('.test-new-columns-menu-hidden-column-collapsed', column, 100).isDisplayed(), + await driver.findContentWait('.test-new-columns-menu-hidden-column-collapsed', + column, + STANDARD_WAITING_TIME).isDisplayed(), `column ${column} is not present` ); } @@ -393,7 +519,7 @@ describe('GridViewNewColumnMenu', function () { it('submenu should be searchable', async function () { await clickAddColumn(); await driver.find(".test-new-columns-menu-hidden-columns-menu").click(); - await driver.findWait('.test-searchable-menu-input', 100).click(); + await driver.findWait('.test-searchable-menu-input', STANDARD_WAITING_TIME).click(); await gu.sendKeys('New'); await checkResult(['New1', 'New2', 'New3', 'New4']); @@ -412,12 +538,16 @@ describe('GridViewNewColumnMenu', function () { // Show it once again and add B and C. await clickAddColumn(); await driver.find(".test-new-columns-menu-hidden-columns-menu").click(); - await driver.findContentWait('.test-new-columns-menu-hidden-column-collapsed', 'B', 100).click(); + await driver.findContentWait('.test-new-columns-menu-hidden-column-collapsed', + 'B', + STANDARD_WAITING_TIME).click(); await gu.waitForServer(); await clickAddColumn(); // Now this column is inlined. - await driver.findContentWait(".test-new-columns-menu-hidden-column-inlined", 'C', 100).click(); + await driver.findContentWait(".test-new-columns-menu-hidden-column-inlined", + 'C', + STANDARD_WAITING_TIME).click(); await gu.waitForServer(); // Make sure they are added at the end. @@ -430,7 +560,7 @@ describe('GridViewNewColumnMenu', function () { await collapsedHiddenColumns(), cols ); - }, 250); + }, STANDARD_WAITING_TIME); } }); }); @@ -487,7 +617,7 @@ describe('GridViewNewColumnMenu', function () { it('should suggest to add every column from a reference', async function () { await clickAddColumn(); - await driver.findWait('.test-new-columns-menu-lookup-Person', 100).click(); + await driver.findWait('.test-new-columns-menu-lookup-Person', STANDARD_WAITING_TIME).click(); await gu.waitToPass(async () => { const allColumns = await driver.findAll('.test-new-columns-menu-lookup-column', (el) => el.getText()); assert.deepEqual(allColumns, COLUMN_LABELS); @@ -500,8 +630,8 @@ describe('GridViewNewColumnMenu', function () { it(`should insert ${column} with a proper name and type from a Ref column`, async function () { const revert = await gu.begin(); await clickAddColumn(); - await driver.findWait('.test-new-columns-menu-lookup-Person', 100).click(); - await driver.findContentWait(`.test-new-columns-menu-lookup-column`, column, 100).click(); + await driver.findWait('.test-new-columns-menu-lookup-Person', STANDARD_WAITING_TIME).click(); + await driver.findContentWait(`.test-new-columns-menu-lookup-column`, column, STANDARD_WAITING_TIME).click(); await gu.waitForServer(); const columns = await gu.getColumnNames(); @@ -590,9 +720,9 @@ describe('GridViewNewColumnMenu', function () { it('should suggest aggregations for RefList column', async function () { await clickAddColumn(); - await driver.findWait('.test-new-columns-menu-lookup-Employees', 100).click(); + await driver.findWait('.test-new-columns-menu-lookup-Employees', STANDARD_WAITING_TIME).click(); // Wait for the menu to appear. - await driver.findWait('.test-new-columns-menu-lookup-column', 100); + await driver.findWait('.test-new-columns-menu-lookup-column', STANDARD_WAITING_TIME); // First check items (so columns we can add which don't have menu) const items = await driver.findAll('.test-new-columns-menu-lookup-column', (el) => el.getText()); assert.deepEqual(items, [ @@ -629,11 +759,11 @@ describe('GridViewNewColumnMenu', function () { const colId = column.replace(" ", "_"); await clickAddColumn(); - await driver.findWait('.test-new-columns-menu-lookup-Employees', 100).click(); - await driver.findWait(`.test-new-columns-menu-lookup-submenu-${colId}`, 100).mouseMove(); + await driver.findWait('.test-new-columns-menu-lookup-Employees', STANDARD_WAITING_TIME).click(); + await driver.findWait(`.test-new-columns-menu-lookup-submenu-${colId}`, STANDARD_WAITING_TIME).mouseMove(); // Wait for the menu to show up. - await driver.findWait('.test-new-columns-menu-lookup-submenu-function', 100); + await driver.findWait('.test-new-columns-menu-lookup-submenu-function', STANDARD_WAITING_TIME); // Make sure the list of function is accurate. const suggestedFunctions = @@ -655,7 +785,7 @@ describe('GridViewNewColumnMenu', function () { } // Now pick the default function. - await driver.findWait(`.test-new-columns-menu-lookup-submenu-${colId}`, 100).click(); + await driver.findWait(`.test-new-columns-menu-lookup-submenu-${colId}`, STANDARD_WAITING_TIME).click(); await gu.waitForServer(); const columns = await gu.getColumnNames(); @@ -728,7 +858,7 @@ describe('GridViewNewColumnMenu', function () { it('should show reverse lookups in the menu', async function () { await clickAddColumn(); // Wait for any menu to show up. - await driver.findWait('.test-new-columns-menu-revlookup', 100); + await driver.findWait('.test-new-columns-menu-revlookup', STANDARD_WAITING_TIME); // We should see two rev lookups. assert.deepEqual(await driver.findAll('.test-new-columns-menu-revlookup', (el) => el.getText()), [ 'Person [← Item]', @@ -739,7 +869,7 @@ describe('GridViewNewColumnMenu', function () { it('should show same list from Ref and RefList', async function () { await driver.findContent('.test-new-columns-menu-revlookup', 'Person [← Item]').mouseMove(); // Wait for any menu to show up. - await driver.findWait('.test-new-columns-menu-revlookup-column', 100); + await driver.findWait('.test-new-columns-menu-revlookup-column', STANDARD_WAITING_TIME); const columns = await driver.findAll('.test-new-columns-menu-revlookup-column', (el) => el.getText()); const submenus = await driver.findAll('.test-new-columns-menu-revlookup-submenu', (el) => el.getText()); @@ -747,7 +877,7 @@ describe('GridViewNewColumnMenu', function () { // Now open the other submenu and make sure list is the same. await driver.findContent('.test-new-columns-menu-revlookup', 'Person [← Items]').mouseMove(); // Wait for any menu to show up. - await driver.findWait('.test-new-columns-menu-revlookup-column', 100); + await driver.findWait('.test-new-columns-menu-revlookup-column', STANDARD_WAITING_TIME); const columns2 = await driver.findAll('.test-new-columns-menu-revlookup-column', (el) => el.getText()); const submenus2 = await driver.findAll('.test-new-columns-menu-revlookup-submenu', (el) => el.getText()); @@ -791,14 +921,20 @@ describe('GridViewNewColumnMenu', function () { for(const column of ['Age', 'Member', 'Birthday date', 'SeenAt']) { it(`should properly add reverse lookup for ${column}`, async function () { await clickAddColumn(); - await driver.findContentWait('.test-new-columns-menu-revlookup', 'Person [← Item]', 100).mouseMove(); + await driver.findContentWait('.test-new-columns-menu-revlookup', + 'Person [← Item]', + STANDARD_WAITING_TIME + ).mouseMove(); // This is submenu so expand it. - await driver.findContentWait('.test-new-columns-menu-revlookup-submenu', new RegExp("^" + column), 100) - .mouseMove(); + await driver.findContentWait('.test-new-columns-menu-revlookup-submenu', + new RegExp("^" + column), + STANDARD_WAITING_TIME*3 + ).mouseMove(); // Wait for any function to appear. - await driver.findWait('.test-new-columns-menu-revlookup-column-function', 100); + await driver.findWait('.test-new-columns-menu-revlookup-column-function', + STANDARD_WAITING_TIME); // Make sure we see proper list. const functions = await driver.findAll('.test-new-columns-menu-revlookup-column-function', @@ -876,10 +1012,21 @@ describe('GridViewNewColumnMenu', function () { async function addRevLookup(func: string) { await clickAddColumn(); - await driver.findContentWait('.test-new-columns-menu-revlookup', 'Person [← Item]', 100).mouseMove(); - await driver.findContentWait('.test-new-columns-menu-revlookup-submenu', new RegExp("^" + column), 100) - .mouseMove(); - await driver.findContentWait('.test-new-columns-menu-revlookup-column-function', func, 100).click(); + await driver.findContentWait( + '.test-new-columns-menu-revlookup', + 'Person [← Item]', + STANDARD_WAITING_TIME + ).mouseMove(); + await driver.findContentWait( + '.test-new-columns-menu-revlookup-submenu', + new RegExp("^" + column), + STANDARD_WAITING_TIME + ).mouseMove(); + await driver.findContentWait( + '.test-new-columns-menu-revlookup-column-function', + func, + STANDARD_WAITING_TIME + ).click(); await gu.waitForServer(); } }); @@ -890,14 +1037,24 @@ describe('GridViewNewColumnMenu', function () { for(const column of ['Age', 'Member', 'Birthday date', 'SeenAt']) { it(`should properly add reverse lookup for ${column}`, async function () { await clickAddColumn(); - await driver.findContentWait('.test-new-columns-menu-revlookup', 'Person [← Items]', 100).mouseMove(); + await driver.findContentWait( + '.test-new-columns-menu-revlookup', + 'Person [← Items]', + STANDARD_WAITING_TIME + ).mouseMove(); // This is submenu so expand it. - await driver.findContentWait('.test-new-columns-menu-revlookup-submenu', new RegExp("^" + column), 100) - .mouseMove(); + await driver.findContentWait( + '.test-new-columns-menu-revlookup-submenu', + new RegExp("^" + column), + STANDARD_WAITING_TIME + ).mouseMove(); // Wait for any function to appear. - await driver.findWait('.test-new-columns-menu-revlookup-column-function', 100); + await driver.findWait( + '.test-new-columns-menu-revlookup-column-function', + STANDARD_WAITING_TIME + ); // Make sure we see proper list. const functions = await driver.findAll('.test-new-columns-menu-revlookup-column-function', @@ -968,10 +1125,21 @@ describe('GridViewNewColumnMenu', function () { async function addRevLookup(func: string) { await clickAddColumn(); - await driver.findContentWait('.test-new-columns-menu-revlookup', 'Person [← Items]', 100).mouseMove(); - await driver.findContentWait('.test-new-columns-menu-revlookup-submenu', new RegExp("^" + column), 100) - .mouseMove(); - await driver.findContentWait('.test-new-columns-menu-revlookup-column-function', func, 100).click(); + await driver.findContentWait( + '.test-new-columns-menu-revlookup', + 'Person [← Items]', + STANDARD_WAITING_TIME + ).mouseMove(); + await driver.findContentWait( + '.test-new-columns-menu-revlookup-submenu', + new RegExp("^" + column), + STANDARD_WAITING_TIME + ).mouseMove(); + await driver.findContentWait( + '.test-new-columns-menu-revlookup-column-function', + func, + STANDARD_WAITING_TIME + ).click(); await gu.waitForServer(); } }); @@ -987,8 +1155,8 @@ describe('GridViewNewColumnMenu', function () { await gu.openColumnPanel(); await clickAddColumn(); - await driver.findWait('.test-new-columns-menu-shortcuts-timestamp', 100).mouseMove(); - await driver.findWait('.test-new-columns-menu-shortcuts-timestamp-new', 100).click(); + await driver.findWait('.test-new-columns-menu-shortcuts-timestamp', STANDARD_WAITING_TIME).mouseMove(); + await driver.findWait('.test-new-columns-menu-shortcuts-timestamp-new', STANDARD_WAITING_TIME).click(); await gu.waitForServer(); // Make sure we have Created At column at the end. @@ -1014,8 +1182,8 @@ describe('GridViewNewColumnMenu', function () { it('modified at - should create new column with date triggered on change', async function () { await clickAddColumn(); - await driver.findWait('.test-new-columns-menu-shortcuts-timestamp', 100).mouseMove(); - await driver.findWait('.test-new-columns-menu-shortcuts-timestamp-change', 100).click(); + await driver.findWait('.test-new-columns-menu-shortcuts-timestamp', STANDARD_WAITING_TIME).mouseMove(); + await driver.findWait('.test-new-columns-menu-shortcuts-timestamp-change', STANDARD_WAITING_TIME).click(); await gu.waitForServer(); // Make sure we have this column at the end. @@ -1048,8 +1216,8 @@ describe('GridViewNewColumnMenu', function () { await gu.openColumnPanel(); await clickAddColumn(); - await driver.findWait('.test-new-columns-menu-shortcuts-author', 100).mouseMove(); - await driver.findWait('.test-new-columns-menu-shortcuts-author-new', 100).click(); + await driver.findWait('.test-new-columns-menu-shortcuts-author', STANDARD_WAITING_TIME).mouseMove(); + await driver.findWait('.test-new-columns-menu-shortcuts-author-new', STANDARD_WAITING_TIME).click(); await gu.waitForServer(); // Make sure we have this column at the end. @@ -1076,8 +1244,8 @@ describe('GridViewNewColumnMenu', function () { await gu.openColumnPanel(); await clickAddColumn(); - await driver.findWait('.test-new-columns-menu-shortcuts-author', 100).mouseMove(); - await driver.findWait('.test-new-columns-menu-shortcuts-author-change', 100).click(); + await driver.findWait('.test-new-columns-menu-shortcuts-author', STANDARD_WAITING_TIME).mouseMove(); + await driver.findWait('.test-new-columns-menu-shortcuts-author-change', STANDARD_WAITING_TIME).click(); await gu.waitForServer(); // Make sure we have this column at the end. @@ -1105,7 +1273,7 @@ describe('GridViewNewColumnMenu', function () { describe('Detect Duplicates in...', function () { it('should show columns in a searchable sub-menu', async function () { await clickAddColumn(); - await driver.findWait('.test-new-columns-menu-shortcuts-duplicates', 100).mouseMove(); + await driver.findWait('.test-new-columns-menu-shortcuts-duplicates', STANDARD_WAITING_TIME).mouseMove(); await gu.waitToPass(async () => { assert.deepEqual( await driver.findAll('.test-searchable-menu li', (el) => el.getText()), @@ -1119,7 +1287,7 @@ describe('GridViewNewColumnMenu', function () { await driver.findAll('.test-searchable-menu li', (el) => el.getText()), ['A'] ); - }, 250); + }, STANDARD_WAITING_TIME); await gu.sendKeys('BC'); await gu.waitToPass(async () => { @@ -1127,7 +1295,7 @@ describe('GridViewNewColumnMenu', function () { await driver.findAll('.test-searchable-menu li', (el) => el.getText()), [] ); - }, 250); + }, STANDARD_WAITING_TIME); await gu.clearInput(); await gu.waitToPass(async () => { @@ -1135,12 +1303,12 @@ describe('GridViewNewColumnMenu', function () { await driver.findAll('.test-searchable-menu li', (el) => el.getText()), ['A', 'B', 'C'] ); - }, 250); + }, STANDARD_WAITING_TIME); }); it('should create new column that checks for duplicates in the specified column', async function () { await clickAddColumn(); - await driver.findWait('.test-new-columns-menu-shortcuts-duplicates', 100).mouseMove(); + await driver.findWait('.test-new-columns-menu-shortcuts-duplicates', STANDARD_WAITING_TIME).mouseMove(); await driver.findContentWait('.test-searchable-menu li', 'A', 500).click(); await gu.waitForServer(); await gu.sendKeys(Key.ENTER); @@ -1159,7 +1327,7 @@ describe('GridViewNewColumnMenu', function () { for (const [label, type] of [['Choice', 'Choice List'], ['Ref', 'Reference List']]) { await gu.addColumn(label, type); await clickAddColumn(); - await driver.findWait('.test-new-columns-menu-shortcuts-duplicates', 100).mouseMove(); + await driver.findWait('.test-new-columns-menu-shortcuts-duplicates', STANDARD_WAITING_TIME).mouseMove(); await driver.findContentWait('.test-searchable-menu li', label, 500).click(); await gu.waitForServer(); await gu.sendKeys(Key.ENTER); @@ -1181,7 +1349,7 @@ describe('GridViewNewColumnMenu', function () { await gu.sendKeys('A', Key.ENTER); await gu.waitForServer(); await clickAddColumn(); - await driver.findWait('.test-new-columns-menu-shortcuts-uuid', 100).click(); + await driver.findWait('.test-new-columns-menu-shortcuts-uuid', STANDARD_WAITING_TIME).click(); await gu.waitForServer(); const cells1 = await gu.getVisibleGridCells({col: 'UUID', rowNums: [1, 2]}); assert.match(cells1[0], /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/); @@ -1224,7 +1392,7 @@ describe('GridViewNewColumnMenu', function () { // Now on the main tab, make sure we don't see those references in lookup menu. await mainTab.open(); await clickAddColumn(); - await driver.findWait('.test-new-columns-menu-lookups-none', 100); + await driver.findWait('.test-new-columns-menu-lookups-none', STANDARD_WAITING_TIME); // Now test RefList columns. await transformTab.open(); @@ -1248,14 +1416,14 @@ describe('GridViewNewColumnMenu', function () { // Now on the main make sure we still don't see those references in lookup menu. await mainTab.open(); await clickAddColumn(); - await driver.findWait('.test-new-columns-menu-lookups-none', 100); + await driver.findWait('.test-new-columns-menu-lookups-none', STANDARD_WAITING_TIME); // Now test reverse lookups. await gu.openPage('Person'); await clickAddColumn(); // Wait for any menu to show up. - await driver.findWait('.test-new-columns-menu-lookup', 100); + await driver.findWait('.test-new-columns-menu-lookup', STANDARD_WAITING_TIME); // Now make sure we don't have helper columns assert.isEmpty(await driver.findAll('.test-new-columns-menu-revlookup', e => e.getText())); @@ -1274,9 +1442,9 @@ describe('GridViewNewColumnMenu', function () { async function clickAddColumn() { const isMenuPresent = await driver.find(".test-new-columns-menu").isPresent(); if (!isMenuPresent) { - await driver.findWait(".mod-add-column", 100).click(); + await driver.findWait(".mod-add-column", STANDARD_WAITING_TIME).click(); } - await driver.findWait(".test-new-columns-menu", 100); + await driver.findWait(".test-new-columns-menu", STANDARD_WAITING_TIME); } async function isMenuPresent() { @@ -1293,7 +1461,7 @@ describe('GridViewNewColumnMenu', function () { } async function isDisplayed(selector: string, message: string) { - assert.isTrue(await driver.findWait(selector, 100, message).isDisplayed(), message); + assert.isTrue(await driver.findWait(selector, STANDARD_WAITING_TIME, message).isDisplayed(), message); } async function hasShortcuts() { @@ -1342,9 +1510,9 @@ describe('GridViewNewColumnMenu', function () { async function addRefListLookup(refListId: string, colId: string, func: string) { await clickAddColumn(); - await driver.findWait(`.test-new-columns-menu-lookup-${refListId}`, 100).click(); - await driver.findWait(`.test-new-columns-menu-lookup-submenu-${colId}`, 100).mouseMove(); - await driver.findWait(`.test-new-columns-menu-lookup-submenu-function-${func}`, 100).click(); + await driver.findWait(`.test-new-columns-menu-lookup-${refListId}`, STANDARD_WAITING_TIME).click(); + await driver.findWait(`.test-new-columns-menu-lookup-submenu-${colId}`, STANDARD_WAITING_TIME).mouseMove(); + await driver.findWait(`.test-new-columns-menu-lookup-submenu-function-${func}`, STANDARD_WAITING_TIME).click(); await gu.waitForServer(); }