CYPRESS: fix AUT cypress failure for user,persona and customizeLanding (#17338)

* fix aut cypress failure for user,persona and customizeLanding

* fixes failure
This commit is contained in:
Ashish Gupta 2024-08-08 18:35:31 +05:30 committed by GitHub
parent 71a57a83bb
commit 53ae052a3f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 34 additions and 4 deletions

View File

@ -93,7 +93,7 @@ export const navigateToLandingPage = () => {
export const openAddWidgetModal = () => { export const openAddWidgetModal = () => {
interceptURL( interceptURL(
'GET', 'GET',
`/api/v1/docStore?fqnPrefix=KnowledgePanel`, `/api/v1/docStore?fqnPrefix=KnowledgePanel&limit=25`,
'getWidgetsList' 'getWidgetsList'
); );

View File

@ -196,9 +196,10 @@ class UsersTestClass {
cy.get('[data-testid="displayName"]').clear(); cy.get('[data-testid="displayName"]').clear();
interceptURL('PATCH', '/api/v1/users/*', 'updateName'); interceptURL('PATCH', '/api/v1/users/*', 'updateName');
cy.get('[data-testid="inline-save-btn"]').click(); cy.get('[data-testid="inline-save-btn"]').click();
cy.get('[data-testid="edit-displayName"]').scrollIntoView();
verifyResponseStatusCode('@updateName', 200); verifyResponseStatusCode('@updateName', 200);
cy.get('[data-testid="user-name"]').should('contain', 'Add Display Name');
cy.get('.ant-collapse-expand-icon > .anticon > svg').click(); cy.get('.ant-collapse-expand-icon > .anticon > svg').click();
cy.get('[data-testid="edit-teams-button"]').click(); cy.get('[data-testid="edit-teams-button"]').click();
interceptURL('PATCH', '/api/v1/users/*', 'updateTeam'); interceptURL('PATCH', '/api/v1/users/*', 'updateTeam');

View File

@ -91,6 +91,18 @@ describe('Persona operations', { tags: 'Settings' }, () => {
}); });
it('Persona creation should work properly', () => { it('Persona creation should work properly', () => {
interceptURL(
'GET',
'/api/v1/users?limit=25&isBot=false',
'getInitialUsers'
);
interceptURL(
'GET',
'/api/v1/search/query?q=***%20AND%20isBot:false&from=0&size=25&index=user_search_index',
'getUserSearch'
);
cy.get('[data-testid="add-persona-button"]').scrollIntoView().click(); cy.get('[data-testid="add-persona-button"]').scrollIntoView().click();
cy.get('[data-testid="name"]').clear().type(PERSONA_DETAILS.name); cy.get('[data-testid="name"]').clear().type(PERSONA_DETAILS.name);
validateFormNameFieldInput({ validateFormNameFieldInput({
@ -105,8 +117,12 @@ describe('Persona operations', { tags: 'Settings' }, () => {
cy.get(descriptionBox).type(PERSONA_DETAILS.description); cy.get(descriptionBox).type(PERSONA_DETAILS.description);
cy.get('[data-testid="add-users"]').scrollIntoView().click(); cy.get('[data-testid="add-users"]').scrollIntoView().click();
verifyResponseStatusCode('@getInitialUsers', 200);
cy.get('[data-testid="searchbar"]').type(userSearchText); cy.get('[data-testid="searchbar"]').type(userSearchText);
verifyResponseStatusCode('@getUserSearch', 200);
cy.get(`.ant-popover [title="${userSearchText}"]`).click(); cy.get(`.ant-popover [title="${userSearchText}"]`).click();
cy.get('[data-testid="selectable-list-update-btn"]') cy.get('[data-testid="selectable-list-update-btn"]')
.scrollIntoView() .scrollIntoView()

View File

@ -14,6 +14,7 @@
import { act, render, screen } from '@testing-library/react'; import { act, render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event'; import userEvent from '@testing-library/user-event';
import React from 'react'; import React from 'react';
import { PAGE_SIZE_MEDIUM } from '../../../../constants/constants';
import { mockWidgetsData } from '../../../../mocks/AddWidgetModal.mock'; import { mockWidgetsData } from '../../../../mocks/AddWidgetModal.mock';
import { getAllKnowledgePanels } from '../../../../rest/DocStoreAPI'; import { getAllKnowledgePanels } from '../../../../rest/DocStoreAPI';
import AddWidgetModal from './AddWidgetModal'; import AddWidgetModal from './AddWidgetModal';
@ -75,6 +76,11 @@ describe('AddWidgetModal component', () => {
render(<AddWidgetModal {...mockProps} />); render(<AddWidgetModal {...mockProps} />);
}); });
expect(getAllKnowledgePanels).toHaveBeenCalledWith({
fqnPrefix: 'KnowledgePanel',
limit: PAGE_SIZE_MEDIUM,
});
expect( expect(
screen.getByTestId('ActivityFeed-widget-tab-label') screen.getByTestId('ActivityFeed-widget-tab-label')
).toBeInTheDocument(); ).toBeInTheDocument();

View File

@ -17,7 +17,10 @@ import { AxiosError } from 'axios';
import { isEmpty, toString } from 'lodash'; import { isEmpty, toString } from 'lodash';
import React, { useCallback, useEffect, useMemo, useState } from 'react'; import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { LIGHT_GREEN_COLOR } from '../../../../constants/constants'; import {
LIGHT_GREEN_COLOR,
PAGE_SIZE_MEDIUM,
} from '../../../../constants/constants';
import { ERROR_PLACEHOLDER_TYPE } from '../../../../enums/common.enum'; import { ERROR_PLACEHOLDER_TYPE } from '../../../../enums/common.enum';
import { WidgetWidths } from '../../../../enums/CustomizablePage.enum'; import { WidgetWidths } from '../../../../enums/CustomizablePage.enum';
import { Document } from '../../../../generated/entity/docStore/document'; import { Document } from '../../../../generated/entity/docStore/document';
@ -50,6 +53,7 @@ function AddWidgetModal({
setLoading(true); setLoading(true);
const response = await getAllKnowledgePanels({ const response = await getAllKnowledgePanels({
fqnPrefix: 'KnowledgePanel', fqnPrefix: 'KnowledgePanel',
limit: PAGE_SIZE_MEDIUM,
}); });
setWidgetsList(response.data); setWidgetsList(response.data);

View File

@ -20,7 +20,10 @@ import { getEncodedFqn } from '../utils/StringsUtils';
const BASE_URL = 'docStore'; const BASE_URL = 'docStore';
export const getAllKnowledgePanels = async (params: { fqnPrefix: string }) => { export const getAllKnowledgePanels = async (params: {
fqnPrefix: string;
limit: number;
}) => {
const response = await axiosClient.get<PagingResponse<Document[]>>( const response = await axiosClient.get<PagingResponse<Document[]>>(
`${BASE_URL}`, `${BASE_URL}`,
{ {