From 3285a99138515dc1eecd09d35d1c32c7ff7334ed Mon Sep 17 00:00:00 2001 From: Pranav C Date: Mon, 23 Aug 2021 20:10:14 +0530 Subject: [PATCH] test(cypress): correction and add table create test Signed-off-by: Pranav C --- cypress/integration/firsttime_run_spec.js | 69 ++++++++++++++++------- cypress/support/commands.js | 3 + 2 files changed, 52 insertions(+), 20 deletions(-) diff --git a/cypress/integration/firsttime_run_spec.js b/cypress/integration/firsttime_run_spec.js index e704488559..068bce0b4b 100644 --- a/cypress/integration/firsttime_run_spec.js +++ b/cypress/integration/firsttime_run_spec.js @@ -1,38 +1,67 @@ describe('My First Test', () => { - it('Sign Up / Sign In', (done) => { - cy.visit('http://localhost:8080/dashboard') - cy.get('body').then($body => { + before(() => { + cy.visit('http://localhost:3000') + cy.waitForSpinners(); + }) - if ($body.find('.welcome-msg').length > 0) { - cy.wait(12000); + it('Sign Up / Sign In', () => { + // console.log('=====',cy.$$(cy.get('body')).find('.welcome-page').length) + cy.get('body').then(($body) => { + if ($body.find('.welcome-page').length > 0) { + + // if (cy.get('body').find('.welcome-page').should('exist')) { + cy.wait(8000); cy.get('body').trigger('mousemove'); - cy.wait(1000); cy.contains('Let\'s Begin').click(); - cy.wait(1000); cy.get('input[type="text"]').type('pranavc@gmail.com'); cy.get('input[type="password"]').type('Password123.'); - cy.contains('Sign Up').click() + cy.get('button:contains("SIGN UP")').click() + // cy.url().shou } else { cy.get('input[type="text"]').type('pranavc@gmail.com'); cy.get('input[type="password"]').type('Password123.'); - cy.contains('Sign In').click() + cy.get('button:contains("SIGN IN")').click() } - done() }); }); - it('Create Project', async () => { - cy.wait(1000) - cy.contains('New Project').trigger('onmouseover').trigger('mouseenter'); - cy.wait(1500) - cy.get('.create-external-db-project').click() - cy.wait(5500) - cy.get('.database-field input').click().clear().type('sakila') - cy.contains('Test Database Connection').click() - + it('Create Project', () => { cy.wait(1500); - cy.contains('Ok & Save Project').click() + cy.get('body').then($el => { + if ($el.find('.project-row').length) { + cy.get('.project-row').first().click(); + } else { + cy.contains('New Project').trigger('onmouseover').trigger('mouseenter'); + cy.get('.create-external-db-project').click() + + cy.wait(1500); + cy.url().should('contain', '#/project') + cy.get('.database-field input').click().clear().type('sakila') + cy.contains('Test Database Connection').click() + + cy.wait(1500); + cy.contains('Ok & Save Project').click() + + } + cy.wait(5000); + cy.url().should('contain', '#/nc/') + }) + + + }); + + + it('Create Table', () => { + cy.get('.add-btn').click(); + const name= 'Test' + Date.now(); + cy.get('.nc-create-table-card .nc-table-name input[type="text"]').first().click().clear().type(name) + cy.get('.nc-create-table-card .nc-table-name-alias input[type="text"]').first().should('have.value', name.toLowerCase()) + cy.wait(3000) + 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}&`) }); + }) diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 119ab03f7c..0b075721e7 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -23,3 +23,6 @@ // // -- This will overwrite an existing command -- // Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) +Cypress.Commands.add('waitForSpinners', () => { + cy.get('#nuxt-loading', { timeout: 10_000 }).should('have.length', 0) +})