Fix UI :- Cypress issue for User and Bot creation (#7785)

* Fix cypress issue for User and Bot creation

* changes as per comments

* cypress for user and bot

* added cypress for bot
This commit is contained in:
Ashish Gupta 2022-09-29 18:02:27 +05:30 committed by GitHub
parent 75953df386
commit 8bb7219826
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 2 deletions

View File

@ -509,7 +509,14 @@ export const addUser = (username, email) => {
.should('exist') .should('exist')
.should('be.visible') .should('be.visible')
.type('Adding user'); .type('Adding user');
interceptURL('GET', ' /api/v1/users/generateRandomPwd', 'generatePassword');
cy.get('[data-testid="password-generator"]')
.should('be.visible')
.click();
verifyResponseStatusCode('@generatePassword', 200);
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) => {

View File

@ -65,8 +65,14 @@ describe('Bots Page should work properly', () => {
cy.get('[data-testid="displayName"]').should('exist').type(botName); cy.get('[data-testid="displayName"]').should('exist').type(botName);
//Enter description //Enter description
cy.get(descriptionBox).type(description); cy.get(descriptionBox).type(description);
interceptURL('POST', '/api/v1/bots', 'createBot'); //Generate Password
interceptURL('GET', ' /api/v1/users/generateRandomPwd', 'generatePassword');
cy.get('[data-testid="password-generator"]')
.should('be.visible')
.click();
verifyResponseStatusCode('@generatePassword', 200);
//Click on save button //Click on save button
interceptURL('POST', '/api/v1/bots', 'createBot');
cy.get('[data-testid="save-user"]') cy.get('[data-testid="save-user"]')
.scrollIntoView() .scrollIntoView()
.should('be.visible') .should('be.visible')

View File

@ -11,7 +11,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { addUser, deleteSoftDeletedUser, login, restoreUser, softDeleteUser, uuid } from '../../common/common'; import { addUser, deleteSoftDeletedUser, interceptURL, login, restoreUser, softDeleteUser, uuid, verifyResponseStatusCode } from '../../common/common';
import { LOGIN } from '../../constants/constants'; import { LOGIN } from '../../constants/constants';
const userName = `Usercttest${uuid()}`; const userName = `Usercttest${uuid()}`;
@ -29,6 +29,7 @@ describe('Users flow should work properly', () => {
.should('exist') .should('exist')
.should('be.visible') .should('be.visible')
.click(); .click();
interceptURL('GET', '/api/v1/users?fields=profile,teams,roles&&isBot=false&limit=15', 'getUsers');
cy.get('.ant-menu-title-content') cy.get('.ant-menu-title-content')
.contains('Users') .contains('Users')
.should('exist') .should('exist')
@ -41,6 +42,7 @@ describe('Users flow should work properly', () => {
cy.get('.ant-btn').contains('Add User').click(); cy.get('.ant-btn').contains('Add User').click();
addUser(userName, userEmail); addUser(userName, userEmail);
verifyResponseStatusCode('@getUsers', 200);
//Validate if user is added in the User tab //Validate if user is added in the User tab
@ -74,6 +76,7 @@ describe('Admin flow should work properly', () => {
.should('exist') .should('exist')
.should('be.visible') .should('be.visible')
.click(); .click();
interceptURL('GET', '/api/v1/users?fields=profile,teams,roles&&isAdmin=true&isBot=false&limit=15', 'getAdmins');
cy.get('.ant-menu-title-content') cy.get('.ant-menu-title-content')
.contains('Admins') .contains('Admins')
.should('exist') .should('exist')
@ -93,6 +96,7 @@ describe('Admin flow should work properly', () => {
.click(); .click();
addUser(adminName, adminEmail); addUser(adminName, adminEmail);
verifyResponseStatusCode('@getAdmins', 200);
//Validate if user is added in the User tab //Validate if user is added in the User tab

View File

@ -842,6 +842,7 @@ const CreateUser = ({
<div className="flex-center w-16"> <div className="flex-center w-16">
<div <div
className="w-8 h-7 flex-center cursor-pointer" className="w-8 h-7 flex-center cursor-pointer"
data-testid="password-generator"
onClick={generateRandomPassword}> onClick={generateRandomPassword}>
{isPasswordGenerating ? ( {isPasswordGenerating ? (
<Loader size="small" type="default" /> <Loader size="small" type="default" />