TEST : fix DataInsightSetting cypress and glossary rename playwright issue (#17313)

* fix DataInsightSetting cypress and glossary rename playwright issue

* fix sonar
This commit is contained in:
Ashish Gupta 2024-08-07 14:16:02 +05:30 committed by GitHub
parent d3baf4fcf2
commit 6ab3d932f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 60 additions and 20 deletions

View File

@ -11,9 +11,13 @@
* limitations under the License. * limitations under the License.
*/ */
import {
customFormatDateTime,
getCurrentMillis,
getEpochMillisForFutureDays,
} from '../../../src/utils/date-time/DateTimeUtils';
import { interceptURL, verifyResponseStatusCode } from '../../common/common'; import { interceptURL, verifyResponseStatusCode } from '../../common/common';
import { checkDataInsightSuccessStatus } from '../../common/DataInsightUtils'; import { checkDataInsightSuccessStatus } from '../../common/DataInsightUtils';
import { BASE_URL } from '../../constants/constants';
import { GlobalSettingOptions } from '../../constants/settings.constant'; import { GlobalSettingOptions } from '../../constants/settings.constant';
describe( describe(
@ -89,6 +93,23 @@ describe(
).click(); ).click();
cy.get('[data-testid="install-application"]').click(); cy.get('[data-testid="install-application"]').click();
cy.get('[data-testid="save-button"]').click(); cy.get('[data-testid="save-button"]').click();
cy.get('#root\\/backfillConfiguration\\/enabled').click();
const startDate = customFormatDateTime(getCurrentMillis(), 'yyyy-MM-dd');
const endDate = customFormatDateTime(
getEpochMillisForFutureDays(5),
'yyyy-MM-dd'
);
cy.get('#root\\/backfillConfiguration\\/startDate')
.click()
.type(`${startDate}`);
cy.get('#root\\/backfillConfiguration\\/endDate')
.click()
.type(`${endDate}`);
cy.get('[data-testid="submit-btn"]').click();
cy.get('[data-testid="cron-type"]').click(); cy.get('[data-testid="cron-type"]').click();
cy.get('.rc-virtual-list [title="Day"]').click(); cy.get('.rc-virtual-list [title="Day"]').click();
cy.get('[data-testid="cron-type"]').should('contain', 'Day'); cy.get('[data-testid="cron-type"]').should('contain', 'Day');
@ -106,11 +127,6 @@ describe(
'/api/v1/apps/name/DataInsightsApplication?fields=*', '/api/v1/apps/name/DataInsightsApplication?fields=*',
'getDataInsightDetails' 'getDataInsightDetails'
); );
interceptURL(
'POST',
'/api/v1/apps/deploy/DataInsightsApplication',
'deploy'
);
interceptURL( interceptURL(
'POST', 'POST',
'/api/v1/apps/trigger/DataInsightsApplication', '/api/v1/apps/trigger/DataInsightsApplication',
@ -120,20 +136,18 @@ describe(
'[data-testid="data-insights-application-card"] [data-testid="config-btn"]' '[data-testid="data-insights-application-card"] [data-testid="config-btn"]'
).click(); ).click();
verifyResponseStatusCode('@getDataInsightDetails', 200); verifyResponseStatusCode('@getDataInsightDetails', 200);
cy.get('[data-testid="deploy-button"]').click();
verifyResponseStatusCode('@deploy', 200);
cy.reload();
verifyResponseStatusCode('@getDataInsightDetails', 200);
// Adding a manual wait to allow some time between deploying the pipeline and triggering it
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(2000);
cy.get('[data-testid="run-now-button"]').click(); cy.get('[data-testid="run-now-button"]').click();
verifyResponseStatusCode('@triggerPipeline', 200); verifyResponseStatusCode('@triggerPipeline', 200);
cy.reload(); cy.reload();
checkDataInsightSuccessStatus(); checkDataInsightSuccessStatus();
cy.get('[data-testid="logs"]').click(); cy.get('[data-testid="logs"]').click();
cy.url().should('eq', `${BASE_URL}/apps/DataInsightsApplication/logs`);
cy.get('[data-testid="stats-component"]').contains('Success');
cy.get('[data-testid="app-entity-stats-history-table"]').should(
'be.visible'
);
}); });
} }
); );

View File

@ -385,6 +385,8 @@ test.describe('Glossary tests', () => {
}); });
test('Rename Glossary Term and verify assets', async ({ browser }) => { test('Rename Glossary Term and verify assets', async ({ browser }) => {
test.slow();
const { page, afterAction, apiContext } = await performAdminLogin(browser); const { page, afterAction, apiContext } = await performAdminLogin(browser);
const table = new TableClass(); const table = new TableClass();
const topic = new TopicClass(); const topic = new TopicClass();

View File

@ -11,6 +11,7 @@
* limitations under the License. * limitations under the License.
*/ */
import Icon from '@ant-design/icons/lib/components/Icon';
import { import {
Badge, Badge,
Button, Button,
@ -22,11 +23,11 @@ import {
Table, Table,
Typography, Typography,
} from 'antd'; } from 'antd';
import { isEmpty, isNil } from 'lodash'; import { capitalize, isEmpty, isNil } from 'lodash';
import React, { useCallback, useMemo } from 'react'; import React, { useCallback, useMemo } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { LazyLog } from 'react-lazylog'; import { LazyLog } from 'react-lazylog';
import { ReactComponent as IconSuccessBadge } from '../../../../assets/svg/success-badge.svg'; import { ICON_DIMENSION, STATUS_ICON } from '../../../../constants/constants';
import { getEntityStatsData } from '../../../../utils/ApplicationUtils'; import { getEntityStatsData } from '../../../../utils/ApplicationUtils';
import { formatDateTimeWithTimezone } from '../../../../utils/date-time/DateTimeUtils'; import { formatDateTimeWithTimezone } from '../../../../utils/date-time/DateTimeUtils';
import { formatJsonString } from '../../../../utils/StringsUtils'; import { formatJsonString } from '../../../../utils/StringsUtils';
@ -42,7 +43,7 @@ import {
const AppLogsViewer = ({ data }: AppLogsViewerProps) => { const AppLogsViewer = ({ data }: AppLogsViewerProps) => {
const { t } = useTranslation(); const { t } = useTranslation();
const { successContext, failureContext, timestamp } = data; const { successContext, failureContext, timestamp, status } = data;
const handleJumpToEnd = () => { const handleJumpToEnd = () => {
const logsBody = document.getElementsByClassName( const logsBody = document.getElementsByClassName(
@ -101,8 +102,11 @@ const AppLogsViewer = ({ data }: AppLogsViewerProps) => {
)}:`}</span> )}:`}</span>
<Space align="center" className="m-l-xs" size={8}> <Space align="center" className="m-l-xs" size={8}>
<IconSuccessBadge height={14} width={14} /> <Icon
<span>{t('label.success')}</span> component={STATUS_ICON[status as keyof typeof STATUS_ICON]}
style={ICON_DIMENSION}
/>
<span>{capitalize(status)}</span>
</Space> </Space>
</div> </div>
<Divider type="vertical" /> <Divider type="vertical" />

View File

@ -13,6 +13,7 @@
import { render, screen } from '@testing-library/react'; import { 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 { ReactComponent as IconSuccessBadge } from '../../../../assets/svg/success-badge.svg';
import { import {
ScheduleTimeline, ScheduleTimeline,
Status, Status,
@ -55,6 +56,16 @@ jest.mock('../../../common/Badge/Badge.component', () =>
}) })
); );
jest.mock('../../../../constants/constants', () => ({
ICON_DIMENSION: {
with: 14,
height: 14,
},
STATUS_ICON: {
success: IconSuccessBadge,
},
}));
const mockProps1 = { const mockProps1 = {
data: { data: {
appId: '6e4d3dcf-238d-4874-b4e4-dd863ede6544', appId: '6e4d3dcf-238d-4874-b4e4-dd863ede6544',
@ -175,7 +186,7 @@ describe('AppLogsViewer component', () => {
render(<AppLogsViewer {...mockProps1} />); render(<AppLogsViewer {...mockProps1} />);
expect(screen.getByText('label.status:')).toBeInTheDocument(); expect(screen.getByText('label.status:')).toBeInTheDocument();
expect(screen.getByText('label.success')).toBeInTheDocument(); expect(screen.getByText('Success')).toBeInTheDocument();
expect(screen.getByText('label.index-states:')).toBeInTheDocument(); expect(screen.getByText('label.index-states:')).toBeInTheDocument();
expect(screen.getAllByText('Badge')).toHaveLength(3); expect(screen.getAllByText('Badge')).toHaveLength(3);
expect(screen.getByText('label.last-updated:')).toBeInTheDocument(); expect(screen.getByText('label.last-updated:')).toBeInTheDocument();

View File

@ -15,6 +15,9 @@ import { t } from 'i18next';
import { isUndefined } from 'lodash'; import { isUndefined } from 'lodash';
import Qs from 'qs'; import Qs from 'qs';
import { CSSProperties } from 'react'; import { CSSProperties } from 'react';
import { ReactComponent as IconCompleteBadge } from '../assets/svg/complete.svg';
import { ReactComponent as IconFailedBadge } from '../assets/svg/fail-badge.svg';
import { ReactComponent as IconSuccessBadge } from '../assets/svg/success-badge.svg';
import { COOKIE_VERSION } from '../components/Modals/WhatsNewModal/whatsNewData'; import { COOKIE_VERSION } from '../components/Modals/WhatsNewModal/whatsNewData';
import { EntityTabs, EntityType } from '../enums/entity.enum'; import { EntityTabs, EntityType } from '../enums/entity.enum';
import { getPartialNameFromFQN } from '../utils/CommonUtils'; import { getPartialNameFromFQN } from '../utils/CommonUtils';
@ -579,3 +582,9 @@ export const COMMON_ICON_STYLES: CSSProperties = {
export const APPLICATION_JSON_CONTENT_TYPE_HEADER = { export const APPLICATION_JSON_CONTENT_TYPE_HEADER = {
headers: { 'Content-type': 'application/json' }, headers: { 'Content-type': 'application/json' },
}; };
export const STATUS_ICON = {
success: IconSuccessBadge,
failed: IconFailedBadge,
completed: IconCompleteBadge,
};