mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-27 18:36:08 +00:00
test(ui): cypress test for signUp & login (#7775)
* test(ui): cypress test for signUp & login * fix cypress failure * fix add user api failing * fix add user cypress failure * fix add bot cypress test failure * fix bot failure
This commit is contained in:
parent
e473d2caa4
commit
3b57d726f8
@ -510,13 +510,11 @@ export const addUser = (username, email) => {
|
|||||||
.should('be.visible')
|
.should('be.visible')
|
||||||
.type('Adding user');
|
.type('Adding user');
|
||||||
interceptURL('GET', ' /api/v1/users/generateRandomPwd', 'generatePassword');
|
interceptURL('GET', ' /api/v1/users/generateRandomPwd', 'generatePassword');
|
||||||
cy.get('[data-testid="password-generator"]')
|
cy.get('[data-testid="password-generator"]').should('be.visible').click();
|
||||||
.should('be.visible')
|
|
||||||
.click();
|
|
||||||
verifyResponseStatusCode('@generatePassword', 200);
|
verifyResponseStatusCode('@generatePassword', 200);
|
||||||
|
cy.wait(1000);
|
||||||
interceptURL('POST', ' /api/v1/users', 'add-user');
|
interceptURL('POST', ' /api/v1/users', 'add-user');
|
||||||
cy.get('[data-testid="save-user"]').scrollIntoView().click();
|
cy.get('[data-testid="save-user"]').scrollIntoView().click();
|
||||||
verifyResponseStatusCode('@add-user', 201);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const softDeleteUser = (username) => {
|
export const softDeleteUser = (username) => {
|
||||||
|
@ -67,11 +67,11 @@ describe('Bots Page should work properly', () => {
|
|||||||
cy.get(descriptionBox).type(description);
|
cy.get(descriptionBox).type(description);
|
||||||
//Generate Password
|
//Generate Password
|
||||||
interceptURL('GET', ' /api/v1/users/generateRandomPwd', 'generatePassword');
|
interceptURL('GET', ' /api/v1/users/generateRandomPwd', 'generatePassword');
|
||||||
cy.get('[data-testid="password-generator"]')
|
cy.get('[data-testid="password-generator"]').should('be.visible').click();
|
||||||
.should('be.visible')
|
|
||||||
.click();
|
|
||||||
verifyResponseStatusCode('@generatePassword', 200);
|
verifyResponseStatusCode('@generatePassword', 200);
|
||||||
|
cy.wait(1000);
|
||||||
//Click on save button
|
//Click on save button
|
||||||
|
cy.wait(1000);
|
||||||
interceptURL('POST', '/api/v1/bots', 'createBot');
|
interceptURL('POST', '/api/v1/bots', 'createBot');
|
||||||
cy.get('[data-testid="save-user"]')
|
cy.get('[data-testid="save-user"]')
|
||||||
.scrollIntoView()
|
.scrollIntoView()
|
||||||
|
@ -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();
|
||||||
|
});
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user