Browse Source

test(cypress): table rename verification

Signed-off-by: Raju Udava <sivadstala@gmail.com>
pull/797/head
Raju Udava 3 years ago
parent
commit
5f66ec5d0b
  1. 6
      packages/nc-gui/helpers/treeViewDataSerializer.js
  2. 75
      scripts/cypress/integration/common/1a_table_operations.js
  3. 40
      scripts/cypress/support/commands.js

6
packages/nc-gui/helpers/treeViewDataSerializer.js

@ -147,8 +147,7 @@ function migrationsParser(data = [], dbKey, env, dbAlias, dbConnection) {
tn: table.tn,
_tn: table._tn,
dbConnection
},
creator_tooltip: `SQL Table name : '${table.tn}'`
}
};
tables.children.push(json);
}
@ -356,8 +355,7 @@ function tableParser(data = [], dbKey, env, dbAlias, dbConnection) {
tn: table.tn,
_tn: table._tn,
dbConnection
},
creator_tooltip: `SQL Table name : '${table.tn}'`
}
};
tables.children.push(json);
}

75
scripts/cypress/integration/common/1a_table_operations.js

@ -21,35 +21,13 @@ export const genTest = (type, xcdb) => {
// create a new random table
it('Create Table', () => {
cy.get('.add-btn').click();
cy.get('.nc-create-table-card .nc-table-name input[type="text"]')
.first().click().clear().type(name)
if (!xcdb) {
cy.get('.nc-create-table-card .nc-table-name-alias input[type="text"]')
.first().should('have.value', name.toLowerCase())
}
//cy.wait(5000)
cy.get('.nc-create-table-card .nc-create-table-submit').first().click()
cy.get(`.project-tab:contains(${name})`).should('exist')
cy.url().should('contain', `name=${name}`)
//cy.wait(5000)
cy.createTable(name)
})
// delete newly created table
it('Delete Table', () => {
cy.get('.nc-project-tree').find('.v-list-item__title:contains(Tables)', {timeout: 10000})
.first().click()
cy.get('.nc-project-tree').contains(name, {timeout: 6000}).first().click({force: true});
cy.get(`.project-tab:contains(${name}):visible`).should('exist')
cy.get('.nc-table-delete-btn:visible').click()
cy.get('button:contains(Submit)').click()
cy.get(`.project-tab:contains(${name}):visible`).first().should('not.exist')
cy.deleteTable(name)
})
const getAuditCell = (row, col) => {
@ -72,15 +50,50 @@ export const genTest = (type, xcdb) => {
getAuditCell(1,0).contains('TABLE').should('exist')
getAuditCell(1,1).contains('CREATED').should('exist')
getAuditCell(1,3).contains('user@nocodb.com').should('exist')
})
})
}
})
it('Table Rename operation', () => {
cy.renameTable('City', 'CityX')
// genTest('rest', false)
// genTest('graphql', false)
// genTest('rest', true)
// genTest('graphql', true)
// verify
// 1. Table name in project tree has changed
cy.get('.nc-project-tree')
.contains('CityX')
.should('exist')
// 2. Table tab name has changed
cy.get(`.project-tab:contains('CityX'):visible`)
.should('exist')
// 3. contents of the table are valid
mainPage.getCell(`City`, 1)
.contains('A Corua (La Corua)')
.should('exist')
cy.closeTableTab('CityX')
// 4. verify linked contents in other table
// 4a. Address table, has many field
cy.openTableTab('Address')
cy.wait(2000).then(() => {
mainPage.getCell('City <= Address', 1).scrollIntoView()
mainPage.getCell('City <= Address', 1).find('.name').contains('Lethbridge').should('exist')
})
cy.closeTableTab('Address')
// 4b. Country table, belongs to field
cy.openTableTab('Country')
cy.wait(2000).then(() => {
mainPage.getCell('Country => City', 1).find('.name').contains('Kabul').should('exist')
})
cy.closeTableTab('Country')
// revert re-name operation to not impact rest of test suite
cy.renameTable('CityX', 'City')
})
})
}
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd

40
scripts/cypress/support/commands.js

@ -208,6 +208,46 @@ Cypress.Commands.add('deleteTable', (name) => {
cy.get(`.project-tab:contains(${name}):visible`).first().should('not.exist')
})
Cypress.Commands.add('renameTable', (oldName, newName) => {
// expand project tree
cy.get('.nc-project-tree')
.find('.v-list-item__title:contains(Tables)', { timeout: 10000 })
.first()
.click()
// right click on project table name
cy.get('.nc-project-tree')
.contains(oldName, { timeout: 6000 })
.first()
.rightclick()
// choose rename option from menu
cy.getActiveMenu()
.find('[role="menuitem"]')
.contains('Table Rename')
.click({ force: true })
// feed new name
cy.getActiveContentModal()
.find('input')
.clear()
.type(newName)
// submit
cy.getActiveContentModal()
.find('button')
.contains('Submit')
.click()
// close expanded project tree
cy.get('.nc-project-tree')
.find('.v-list-item__title:contains(Tables)', { timeout: 10000 })
.first()
.click()
cy.wait(2000)
})
Cypress.Commands.add('createColumn', (table, columnName) => {
cy.get('.nc-project-tree').find('.v-list-item__title:contains(Tables)', {timeout: 10000})
.first().click()

Loading…
Cancel
Save