diff --git a/openmetadata-ui/src/main/resources/ui/cypress/common/common.js b/openmetadata-ui/src/main/resources/ui/cypress/common/common.js index 6c128eb93a4..96304cffadc 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/common/common.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/common/common.js @@ -510,13 +510,11 @@ export const addUser = (username, email) => { .should('be.visible') .type('Adding user'); interceptURL('GET', ' /api/v1/users/generateRandomPwd', 'generatePassword'); - cy.get('[data-testid="password-generator"]') - .should('be.visible') - .click(); + cy.get('[data-testid="password-generator"]').should('be.visible').click(); verifyResponseStatusCode('@generatePassword', 200); + cy.wait(1000); interceptURL('POST', ' /api/v1/users', 'add-user'); cy.get('[data-testid="save-user"]').scrollIntoView().click(); - verifyResponseStatusCode('@add-user', 201); }; export const softDeleteUser = (username) => { diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Bots.spec.js b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Bots.spec.js index c3a4579b08e..9a93f75b093 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Bots.spec.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Bots.spec.js @@ -67,11 +67,11 @@ describe('Bots Page should work properly', () => { cy.get(descriptionBox).type(description); //Generate Password interceptURL('GET', ' /api/v1/users/generateRandomPwd', 'generatePassword'); - cy.get('[data-testid="password-generator"]') - .should('be.visible') - .click(); - verifyResponseStatusCode('@generatePassword', 200); + cy.get('[data-testid="password-generator"]').should('be.visible').click(); + verifyResponseStatusCode('@generatePassword', 200); + cy.wait(1000); //Click on save button + cy.wait(1000); interceptURL('POST', '/api/v1/bots', 'createBot'); cy.get('[data-testid="save-user"]') .scrollIntoView() diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Login.spec.js b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Login.spec.js new file mode 100644 index 00000000000..45fcd1e5d62 --- /dev/null +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Login.spec.js @@ -0,0 +1,117 @@ +/* + * Copyright 2021 Collate + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { interceptURL, login, verifyResponseStatusCode } from '../../common/common'; + +const CREDENTIALS = { + firstName: 'Test', + lastName: 'User', + email: 'user@openmetadata.org', + password: 'User@OMD123', +}; +const invalidEmail = 'userTest@openmetadata.org'; +const invalidPassword = 'testUsers@123'; + +const ERROR_MESSAGE = { + invalidEmail: 'user instance for userTest not found', + invalidPassword: 'You have entered an invalid username or password.', +}; + +describe('Login flow should work properly', () => { + it('Signup and Login with signed up credentials', () => { + interceptURL('GET', 'api/v1/config/auth', 'getLoginPage'); + cy.visit('/'); + verifyResponseStatusCode('@getLoginPage', 200); + //Click on create account button + cy.get('[data-testid="signup"]') + .scrollIntoView() + .should('be.visible') + .click(); + //Enter first name + cy.get('[id="firstName"]').should('be.visible').type(CREDENTIALS.firstName); + cy.get('[id="firstName"]').should('have.value', CREDENTIALS.firstName); + //Enter last name + cy.get('[id="lastName"]').should('be.visible').type(CREDENTIALS.lastName); + cy.get('[id="lastName"]').should('have.value', CREDENTIALS.lastName); + //Enter email + cy.get('[id="email"]').should('be.visible').type(CREDENTIALS.email); + cy.get('[id="email"]').should('have.value', CREDENTIALS.email); + //Enter password + cy.get('[id="password"]').should('be.visible').type(CREDENTIALS.password); + cy.get('[id="password"]') + .should('have.attr', 'type') + .should('eq', 'password'); + + //Confirm password + cy.get('[id="confirmPassword"]') + .should('be.visible') + .type(CREDENTIALS.password); + //Click on create account button + cy.get('.ant-btn').contains('Create Account').should('be.visible').click(); + cy.url() + .should('eq', 'http://localhost:8585/signin') + .and('contain', 'signin'); + + //Login with the created user + + login(CREDENTIALS.email, CREDENTIALS.password); + cy.goToHomePage(); + cy.url().should('eq', 'http://localhost:8585/my-data'); + + //Verify user profile + cy.get('[data-testid="avatar"]').should('be.visible').click(); + + cy.get('[data-testid="user-name"]') + .should('be.visible') + .invoke('text') + .should('contain', `${CREDENTIALS.firstName}${CREDENTIALS.lastName}`); + interceptURL('GET', 'api/v1/users/name/*', 'getUserPage'); + cy.get('[data-testid="user-name"]').should('be.visible').click({force: true}); + verifyResponseStatusCode('@getUserPage', 200); + cy.get('[data-testid="left-panel"]').should( + 'contain', + `${CREDENTIALS.firstName}${CREDENTIALS.lastName}` + ); + }); + + it('Signin using invalid credentials', () => { + //Login with invalid email + login(invalidEmail, CREDENTIALS.password); + cy.get('[data-testid="login-error-container"]') + .should('be.visible') + .invoke('text') + .should('eq', ERROR_MESSAGE.invalidEmail); + + //Login with invalid password + login(CREDENTIALS.email, invalidPassword); + cy.get('[data-testid="login-error-container"]') + .should('be.visible') + .invoke('text') + .should('eq', ERROR_MESSAGE.invalidPassword); + }); + + it('Forgot password and login with new password', () => { + interceptURL('GET', 'api/v1/config/auth', 'getLoginPage'); + cy.visit('/'); + verifyResponseStatusCode('@getLoginPage', 200); + //Click on Forgot button + cy.get('[data-testid="forgot-password"]').should('be.visible').click(); + cy.url() + .should('eq', 'http://localhost:8585/forgot-password') + .and('contain', 'forgot-password'); + //Enter email + cy.get('[id="email"]').should('be.visible').clear().type(CREDENTIALS.email); + //Click on submit + cy.get('.ant-btn').contains('Submit').click(); + }); +});