Browse Source

chore(cypress): clipboard verification correction

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/3655/head
Pranav C 2 years ago
parent
commit
06f9c09207
  1. 15
      scripts/cypress/integration/common/4g_table_view_expanded_form.js
  2. 27
      scripts/cypress/support/commands.js

15
scripts/cypress/integration/common/4g_table_view_expanded_form.js

@ -63,14 +63,15 @@ export const genTest = (apiType, dbType) => {
}
cy.url().should('include', 'rowId=1');
// spy on clipboard to verify copied text
cy.window().then((win) => {
cy.spy(win.navigator.clipboard, 'writeText').as('copy');
})
// copy url
cy.get('.nc-copy-row-url').click();
cy.window().then((win) => {
win.navigator.clipboard.readText().then((text) => {
expect(text).to.contains('?rowId=1');
});
});
cy.get('@copy').should('be.calledWithMatch', `?rowId=1`);
cy.get('.nc-expand-form-close-btn').click();
@ -79,20 +80,16 @@ export const genTest = (apiType, dbType) => {
it(`Visit a ${viewType} row url and verify expanded form`, () => {
cy.url()
.then((url) => {
cy.restoreLocalStorage();
cy.visit('/' + url.split('/').slice(3).join('/').split('?')[0] + '?rowId=2');
cy.get('.nc-expanded-form-header').should('exist');
cy.saveLocalStorage();
});
});
it(`Visit an invalid ${viewType} row url and verify expanded form`, () => {
cy.url()
.then((url) => {
cy.restoreLocalStorage();
cy.visit('/' + url.split('/').slice(3).join('/').split('?')[0] + '?rowId=99999999');
cy.get('.nc-expanded-form-header').should('not.exist');
cy.saveLocalStorage();
});
});

27
scripts/cypress/support/commands.js

@ -141,7 +141,7 @@ Cypress.Commands.add('refreshTableTab', () => {
.first()
.rightclick({ force: true });
cy.getActiveMenu(".nc-dropdown-tree-view-context-menu")
cy.getActiveMenu('.nc-dropdown-tree-view-context-menu')
.find('[role="menuitem"]')
.contains('Tables Refresh')
.should('exist')
@ -242,13 +242,16 @@ Cypress.Commands.add('saveLocalStorage', (name) => {
cy.printLocalStorage();
});
Cypress.Commands.add('restoreLocalStorage', (name) => {
Object.keys(LOCAL_STORAGE_MEMORY).forEach((key) => {
localStorage.setItem(key, LOCAL_STORAGE_MEMORY[key]);
});
const restoreLocalStorage = () => {
Object.keys(LOCAL_STORAGE_MEMORY).forEach((key) => {
localStorage.setItem(key, LOCAL_STORAGE_MEMORY[key]);
});
cy.printLocalStorage();
});
cy.printLocalStorage();
};
Cypress.Commands.add('restoreLocalStorage', restoreLocalStorage);
Cypress.on('window:before:load', restoreLocalStorage);
Cypress.Commands.add('deleteLocalStorage', () => {
Object.keys(LOCAL_STORAGE_MEMORY).forEach((key) => {
@ -322,7 +325,7 @@ Cypress.Commands.add('createTable', (name) => {
Cypress.Commands.add('deleteTable', (name, dbType) => {
cy.get(`.nc-project-tree-tbl-${name}`).should('exist').rightclick();
cy.getActiveMenu(".nc-dropdown-tree-view-context-menu").find('[role="menuitem"]').contains('Delete').click();
cy.getActiveMenu('.nc-dropdown-tree-view-context-menu').find('[role="menuitem"]').contains('Delete').click();
cy.getActiveModal().find('button').contains('Yes').click();
cy.toastWait(`Deleted table successfully`);
@ -337,16 +340,16 @@ Cypress.Commands.add('renameTable', (oldName, newName) => {
.rightclick();
// choose rename option from menu
cy.getActiveMenu(".nc-dropdown-tree-view-context-menu")
cy.getActiveMenu('.nc-dropdown-tree-view-context-menu')
.find('[role="menuitem"]')
.contains('Rename')
.click({ force: true });
// feed new name
cy.getActiveModal(".nc-modal-table-rename").find('input').clear().type(newName);
cy.getActiveModal('.nc-modal-table-rename').find('input').clear().type(newName);
// submit
cy.getActiveModal(".nc-modal-table-rename").find('button').contains('Submit').click();
cy.getActiveModal('.nc-modal-table-rename').find('button').contains('Submit').click();
cy.toastWait('Table renamed successfully');
@ -475,7 +478,7 @@ Cypress.Commands.add('signOut', () => {
cy.visit(`/`);
cy.get('.nc-project-page-title', { timeout: 30000 }).contains('My Projects').should('be.visible');
cy.get('.nc-menu-accounts', { timeout: 30000 }).should('exist').click();
cy.getActiveMenu(".nc-dropdown-user-accounts-menu").find('.ant-dropdown-menu-item').eq(1).click();
cy.getActiveMenu('.nc-dropdown-user-accounts-menu').find('.ant-dropdown-menu-item').eq(1).click();
cy.wait(5000);
cy.get('button:contains("SIGN")').should('exist');

Loading…
Cancel
Save