@ -27,11 +27,14 @@ export class TreeViewPage extends BasePage {
. locator ( '[data-testid="nc-sidebar-add-base-entity"]' ) ;
. locator ( '[data-testid="nc-sidebar-add-base-entity"]' ) ;
}
}
private getProjectContextMenu ( { baseTitle } : { baseTitle : string } ) {
private async openProjectContextMenu ( { baseTitle } : { baseTitle : string } ) {
return this . dashboard
await this . dashboard . get ( ) . getByTestId ( ` nc-sidebar-base-title- ${ baseTitle } ` ) . hover ( ) ;
await this . dashboard
. get ( )
. get ( )
. getByTestId ( ` nc-sidebar-base-title- ${ baseTitle } ` )
. getByTestId ( ` nc-sidebar-base-title- ${ baseTitle } ` )
. locator ( '[data-testid="nc-sidebar-context-menu"]' ) ;
. locator ( '[data-testid="nc-sidebar-context-menu"]' )
. click ( ) ;
}
}
async isVisible() {
async isVisible() {
@ -61,7 +64,9 @@ export class TreeViewPage extends BasePage {
}
}
async focusTable ( { title } : { title : string } ) {
async focusTable ( { title } : { title : string } ) {
await this . get ( ) . locator ( ` .nc-base-tree-tbl- ${ title } ` ) . focus ( ) ;
await this . get ( )
. locator ( ` .nc-base-tree-tbl- ${ title . replace ( / /g , '' ) } ` )
. focus ( ) ;
}
}
async openBase ( { title } : { title : string } ) {
async openBase ( { title } : { title : string } ) {
@ -78,6 +83,16 @@ export class TreeViewPage extends BasePage {
return this . get ( ) . locator ( '.nc-tree-item' ) . nth ( index ) ;
return this . get ( ) . locator ( '.nc-tree-item' ) . nth ( index ) ;
}
}
async waitForTableOptions ( { title } : { title : string } ) {
const tableTitle = title . replace ( / /g , '' ) ;
await this . get ( ) . locator ( ` .nc-base-tree-tbl- ${ tableTitle } ` ) . waitFor ( { state : 'visible' } ) ;
await this . get ( ) . locator ( ` .nc-base-tree-tbl- ${ tableTitle } ` ) . scrollIntoViewIfNeeded ( ) ;
await this . get ( ) . locator ( ` .nc-base-tree-tbl- ${ tableTitle } ` ) . getByTestId ( ` nc-tbl-title- ${ title } ` ) . hover ( ) ;
}
// assumption: first view rendered is always GRID
// assumption: first view rendered is always GRID
//
//
async openTable ( {
async openTable ( {
@ -164,10 +179,11 @@ export class TreeViewPage extends BasePage {
}
}
async deleteTable ( { title } : { title : string } ) {
async deleteTable ( { title } : { title : string } ) {
await this . get ( ) . locator ( ` .nc-base-tree-tbl- ${ title } ` ) . waitFor ( { state : 'visible' } ) ;
const tableTitle = title . replace ( / /g , '' ) ;
await this . get ( ) . locator ( ` .nc-base-tree-tbl- ${ title } ` ) . scrollIntoViewIfNeeded ( ) ;
await this . waitForTableOptions ( { title } ) ;
await this . get ( ) . locator ( ` .nc-base-tree-tbl- ${ title } ` ) . locator ( '.nc-tbl-context-menu' ) . click ( ) ;
await this . get ( ) . locator ( ` .nc-base-tree-tbl- ${ tableTitle } ` ) . locator ( '.nc-tbl-context-menu' ) . click ( ) ;
await this . rootPage . locator ( '.ant-dropdown' ) . locator ( '.nc-menu-item:has-text("Delete")' ) . click ( ) ;
await this . rootPage . locator ( '.ant-dropdown' ) . locator ( '.nc-menu-item:has-text("Delete")' ) . click ( ) ;
await this . waitForResponse ( {
await this . waitForResponse ( {
@ -186,9 +202,11 @@ export class TreeViewPage extends BasePage {
}
}
async renameTable ( { title , newTitle } : { title : string ; newTitle : string } ) {
async renameTable ( { title , newTitle } : { title : string ; newTitle : string } ) {
await this . get ( ) . locator ( ` .nc-base-tree-tbl- ${ title } ` ) . waitFor ( { state : 'visible' } ) ;
const tableTitle = title . replace ( / /g , '' ) ;
await this . get ( ) . locator ( ` .nc-base-tree-tbl- ${ title } ` ) . scrollIntoViewIfNeeded ( ) ;
await this . get ( ) . locator ( ` .nc-base-tree-tbl- ${ title } ` ) . locator ( '.nc-tbl-context-menu' ) . click ( ) ;
await this . waitForTableOptions ( { title } ) ;
await this . get ( ) . locator ( ` .nc-base-tree-tbl- ${ tableTitle } ` ) . locator ( '.nc-tbl-context-menu' ) . click ( ) ;
await this . rootPage . locator ( '.ant-dropdown' ) . locator ( '.nc-menu-item:has-text("Rename")' ) . click ( ) ;
await this . rootPage . locator ( '.ant-dropdown' ) . locator ( '.nc-menu-item:has-text("Rename")' ) . click ( ) ;
await this . dashboard . get ( ) . locator ( '[placeholder="Enter table name"]' ) . fill ( newTitle ) ;
await this . dashboard . get ( ) . locator ( '[placeholder="Enter table name"]' ) . fill ( newTitle ) ;
@ -204,8 +222,7 @@ export class TreeViewPage extends BasePage {
}
}
async baseSettings ( { title } : { title? : string } ) {
async baseSettings ( { title } : { title? : string } ) {
await this . getProjectContextMenu ( { baseTitle : title } ) . hover ( ) ;
await this . openProjectContextMenu ( { baseTitle : title } ) ;
await this . getProjectContextMenu ( { baseTitle : title } ) . click ( ) ;
const settingsMenu = this . dashboard . get ( ) . locator ( '.ant-dropdown-menu.nc-scrollbar-md' ) ;
const settingsMenu = this . dashboard . get ( ) . locator ( '.ant-dropdown-menu.nc-scrollbar-md' ) ;
await settingsMenu . locator ( ` .nc-sidebar-base-base-settings ` ) . click ( ) ;
await settingsMenu . locator ( ` .nc-sidebar-base-base-settings ` ) . click ( ) ;
}
}
@ -213,8 +230,7 @@ export class TreeViewPage extends BasePage {
async quickImport ( { title , baseTitle , context } : { title : string ; baseTitle : string ; context : NcContext } ) {
async quickImport ( { title , baseTitle , context } : { title : string ; baseTitle : string ; context : NcContext } ) {
baseTitle = this . scopedProjectTitle ( { title : baseTitle , context } ) ;
baseTitle = this . scopedProjectTitle ( { title : baseTitle , context } ) ;
await this . getProjectContextMenu ( { baseTitle } ) . hover ( ) ;
await this . openProjectContextMenu ( { baseTitle } ) ;
await this . getProjectContextMenu ( { baseTitle } ) . click ( ) ;
const importMenu = this . dashboard . get ( ) . locator ( '.ant-dropdown-menu' ) ;
const importMenu = this . dashboard . get ( ) . locator ( '.ant-dropdown-menu' ) ;
await importMenu . locator ( ` .nc-sub-menu:has-text("Import Data") ` ) . click ( ) ;
await importMenu . locator ( ` .nc-sub-menu:has-text("Import Data") ` ) . click ( ) ;
await this . rootPage . locator ( ` .ant-dropdown-menu-item:has-text(" ${ title } ") ` ) . waitFor ( ) ;
await this . rootPage . locator ( ` .ant-dropdown-menu-item:has-text(" ${ title } ") ` ) . waitFor ( ) ;
@ -222,18 +238,24 @@ export class TreeViewPage extends BasePage {
}
}
async changeTableIcon ( { title , icon , iconDisplay } : { title : string ; icon : string ; iconDisplay? : string } ) {
async changeTableIcon ( { title , icon , iconDisplay } : { title : string ; icon : string ; iconDisplay? : string } ) {
await this . get ( ) . locator ( ` .nc-base-tree-tbl- ${ title } .nc-table-icon ` ) . click ( ) ;
const tableTitle = title . replace ( / /g , '' ) ;
await this . get ( ) . locator ( ` .nc-base-tree-tbl- ${ tableTitle } .nc-table-icon ` ) . click ( ) ;
await this . rootPage . locator ( '.emoji-mart-search > input' ) . fill ( icon ) ;
await this . rootPage . locator ( '.emoji-mart-search > input' ) . fill ( icon ) ;
const emojiList = this . rootPage . locator ( '[id="emoji-mart-list"]' ) ;
const emojiList = this . rootPage . locator ( '[id="emoji-mart-list"]' ) ;
await emojiList . locator ( 'button' ) . first ( ) . click ( ) ;
await emojiList . locator ( 'button' ) . first ( ) . click ( ) ;
await expect (
await expect (
this . get ( ) . locator ( ` .nc-base-tree-tbl- ${ title } ` ) . locator ( ` .nc-table-icon:has-text(" ${ iconDisplay } ") ` )
this . get ( ) . locator ( ` .nc-base-tree-tbl- ${ tableT itle } ` ) . locator ( ` .nc-table-icon:has-text(" ${ iconDisplay } ") ` )
) . toHaveCount ( 1 ) ;
) . toHaveCount ( 1 ) ;
}
}
async duplicateTable ( title : string , includeData = true , includeViews = true ) {
async duplicateTable ( title : string , includeData = true , includeViews = true ) {
await this . get ( ) . locator ( ` .nc-base-tree-tbl- ${ title } ` ) . locator ( '.nc-icon.ant-dropdown-trigger' ) . click ( ) ;
const tableTitle = title . replace ( / /g , '' ) ;
await this . waitForTableOptions ( { title } ) ;
await this . get ( ) . locator ( ` .nc-base-tree-tbl- ${ tableTitle } ` ) . locator ( '.nc-icon.ant-dropdown-trigger' ) . click ( ) ;
await this . dashboard . get ( ) . locator ( 'div.nc-base-menu-item:has-text("Duplicate")' ) . click ( ) ;
await this . dashboard . get ( ) . locator ( 'div.nc-base-menu-item:has-text("Duplicate")' ) . click ( ) ;
// Find the checkbox element with the label "Include data"
// Find the checkbox element with the label "Include data"
@ -261,9 +283,11 @@ export class TreeViewPage extends BasePage {
async verifyTabIcon ( { title , icon , iconDisplay } : { title : string ; icon : string ; iconDisplay? : string } ) {
async verifyTabIcon ( { title , icon , iconDisplay } : { title : string ; icon : string ; iconDisplay? : string } ) {
await new Promise ( resolve = > setTimeout ( resolve , 1000 ) ) ;
await new Promise ( resolve = > setTimeout ( resolve , 1000 ) ) ;
await this . rootPage . locator ( ` .nc-base-tree-tbl- ${ title } ` ) . waitFor ( { state : 'visible' } ) ;
const tableTitle = title . replace ( / /g , '' ) ;
await this . rootPage . locator ( ` .nc-base-tree-tbl- ${ tableTitle } ` ) . waitFor ( { state : 'visible' } ) ;
await expect (
await expect (
this . get ( ) . locator ( ` .nc-base-tree-tbl- ${ title } ` ) . locator ( ` .nc-table-icon:has-text(" ${ iconDisplay } ") ` )
this . get ( ) . locator ( ` .nc-base-tree-tbl- ${ tableT itle } ` ) . locator ( ` .nc-table-icon:has-text(" ${ iconDisplay } ") ` )
) . toHaveCount ( 1 ) ;
) . toHaveCount ( 1 ) ;
}
}
@ -322,8 +346,7 @@ export class TreeViewPage extends BasePage {
param . title = this . scopedProjectTitle ( { title : param.title , context : param.context } ) ;
param . title = this . scopedProjectTitle ( { title : param.title , context : param.context } ) ;
param . newTitle = this . scopedProjectTitle ( { title : param.newTitle , context : param.context } ) ;
param . newTitle = this . scopedProjectTitle ( { title : param.newTitle , context : param.context } ) ;
await this . getProjectContextMenu ( { baseTitle : param.title } ) . hover ( ) ;
await this . openProjectContextMenu ( { baseTitle : param.title } ) ;
await this . getProjectContextMenu ( { baseTitle : param.title } ) . click ( ) ;
const contextMenu = this . dashboard . get ( ) . locator ( '.ant-dropdown-menu.nc-scrollbar-md:visible' ) . last ( ) ;
const contextMenu = this . dashboard . get ( ) . locator ( '.ant-dropdown-menu.nc-scrollbar-md:visible' ) . last ( ) ;
await contextMenu . waitFor ( ) ;
await contextMenu . waitFor ( ) ;
await contextMenu . locator ( ` .ant-dropdown-menu-item:has-text("Rename") ` ) . click ( ) ;
await contextMenu . locator ( ` .ant-dropdown-menu-item:has-text("Rename") ` ) . click ( ) ;
@ -337,8 +360,7 @@ export class TreeViewPage extends BasePage {
async deleteProject ( param : { title : string ; context : NcContext } ) {
async deleteProject ( param : { title : string ; context : NcContext } ) {
param . title = this . scopedProjectTitle ( { title : param.title , context : param.context } ) ;
param . title = this . scopedProjectTitle ( { title : param.title , context : param.context } ) ;
await this . getProjectContextMenu ( { baseTitle : param.title } ) . hover ( ) ;
await this . openProjectContextMenu ( { baseTitle : param.title } ) ;
await this . getProjectContextMenu ( { baseTitle : param.title } ) . click ( ) ;
const contextMenu = this . dashboard . get ( ) . locator ( '.ant-dropdown-menu.nc-scrollbar-md:visible' ) . last ( ) ;
const contextMenu = this . dashboard . get ( ) . locator ( '.ant-dropdown-menu.nc-scrollbar-md:visible' ) . last ( ) ;
await contextMenu . waitFor ( ) ;
await contextMenu . waitFor ( ) ;
await contextMenu . locator ( ` .ant-dropdown-menu-item:has-text("Delete") ` ) . click ( ) ;
await contextMenu . locator ( ` .ant-dropdown-menu-item:has-text("Delete") ` ) . click ( ) ;
@ -349,8 +371,7 @@ export class TreeViewPage extends BasePage {
async duplicateProject ( param : { title : string ; context : NcContext } ) {
async duplicateProject ( param : { title : string ; context : NcContext } ) {
param . title = this . scopedProjectTitle ( { title : param.title , context : param.context } ) ;
param . title = this . scopedProjectTitle ( { title : param.title , context : param.context } ) ;
await this . getProjectContextMenu ( { baseTitle : param.title } ) . hover ( ) ;
await this . openProjectContextMenu ( { baseTitle : param.title } ) ;
await this . getProjectContextMenu ( { baseTitle : param.title } ) . click ( ) ;
const contextMenu = this . dashboard . get ( ) . locator ( '.ant-dropdown-menu.nc-scrollbar-md:visible' ) ;
const contextMenu = this . dashboard . get ( ) . locator ( '.ant-dropdown-menu.nc-scrollbar-md:visible' ) ;
await contextMenu . waitFor ( ) ;
await contextMenu . waitFor ( ) ;
await contextMenu . locator ( ` .ant-dropdown-menu-item:has-text("Duplicate") ` ) . click ( ) ;
await contextMenu . locator ( ` .ant-dropdown-menu-item:has-text("Duplicate") ` ) . click ( ) ;