Fix: cypress tests invalid token issue (#15581)

This commit is contained in:
Sachin Chaurasiya 2024-03-15 17:34:31 +05:30 committed by GitHub
parent cadca31b1c
commit b86a8438c3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 111 additions and 95 deletions

View File

@ -13,6 +13,7 @@
import { interceptURL, verifyResponseStatusCode } from '../../common/common';
import { searchServiceFromSettingPage } from '../../common/serviceUtils';
import { getToken } from '../../common/Utils/LocalStorage';
import { GlobalSettingOptions } from '../../constants/settings.constant';
const schemaNames = ['sales', 'admin', 'anonymous', 'dip', 'gsmadmin_internal'];
@ -25,7 +26,8 @@ describe('Schema search', { tags: 'DataAssets' }, () => {
});
it('Prerequisite', () => {
const token = localStorage.getItem('oidcIdToken');
cy.getAllLocalStorage().then((data) => {
const token = getToken(data);
cy.request({
method: 'POST',
url: `/api/v1/services/databaseServices`,
@ -77,6 +79,7 @@ describe('Schema search', { tags: 'DataAssets' }, () => {
});
});
});
});
it('Search schema in database page', () => {
// Click on settings page
@ -131,8 +134,8 @@ describe('Schema search', { tags: 'DataAssets' }, () => {
});
it('Cleanup', () => {
const token = localStorage.getItem('oidcIdToken');
cy.getAllLocalStorage().then((data) => {
const token = getToken(data);
cy.request({
method: 'DELETE',
url: `/api/v1/services/databaseServices/${serviceId}?hardDelete=true&recursive=true`,
@ -141,4 +144,5 @@ describe('Schema search', { tags: 'DataAssets' }, () => {
expect(response.status).to.eq(200);
});
});
});
});

View File

@ -85,7 +85,8 @@ describe('Customize Landing Page Flow', { tags: 'Settings' }, () => {
after(() => {
cy.login();
const token = localStorage.getItem('oidcIdToken');
cy.getAllLocalStorage().then((data) => {
const token = getToken(data);
// Delete created user
cy.request({
@ -101,6 +102,7 @@ describe('Customize Landing Page Flow', { tags: 'Settings' }, () => {
headers: { Authorization: `Bearer ${token}` },
});
});
});
beforeEach(() => {
cy.login();

View File

@ -13,6 +13,7 @@
import { interceptURL, verifyResponseStatusCode } from '../../common/common';
import { visitClassificationPage } from '../../common/TagUtils';
import { getToken } from '../../common/Utils/LocalStorage';
import {
NEW_CLASSIFICATION_FOR_VERSION_TEST,
NEW_CLASSIFICATION_PATCH_PAYLOAD,
@ -45,7 +46,8 @@ describe(
});
it('Prerequisites for classification version page tests', () => {
const token = localStorage.getItem('oidcIdToken');
cy.getAllLocalStorage().then((data) => {
const token = getToken(data);
cy.request({
method: 'PUT',
@ -70,6 +72,7 @@ describe(
});
});
});
});
it('Classification version page should display all the changes properly', () => {
cy.get('[data-testid="data-summary-container"]')

View File

@ -22,6 +22,7 @@ import {
verifyResponseStatusCode,
} from '../../common/common';
import { verifyKpiChart } from '../../common/DataInsightUtils';
import { getToken } from '../../common/Utils/LocalStorage';
import { SidebarItem } from '../../constants/Entity.interface';
import { GlobalSettingOptions } from '../../constants/settings.constant';
@ -43,7 +44,9 @@ const deleteKpiRequest = () => {
cy.wait('@getKpi').then(({ response }) => {
const data = response.body.data;
if (data.length > 0) {
const token = localStorage.getItem('oidcIdToken');
cy.getAllLocalStorage().then((storageData) => {
const token = getToken(storageData);
data.forEach((element) => {
cy.request({
method: 'DELETE',
@ -53,6 +56,7 @@ const deleteKpiRequest = () => {
expect(response.status).to.eq(200);
});
});
});
cy.reload();
}
});

View File

@ -24,6 +24,7 @@ import { deleteGlossary } from '../../common/GlossaryUtils';
import { dragAndDropElement } from '../../common/Utils/DragAndDrop';
import { visitEntityDetailsPage } from '../../common/Utils/Entity';
import { confirmationDragAndDropGlossary } from '../../common/Utils/Glossary';
import { getToken } from '../../common/Utils/LocalStorage';
import { addOwner, removeOwner } from '../../common/Utils/Owner';
import {
COLUMN_NAME_FOR_APPLY_GLOSSARY_TERM,
@ -684,7 +685,8 @@ const checkSummaryListItemSorting = ({ termFQN, columnName }) => {
};
const deleteUser = () => {
const token = localStorage.getItem('oidcIdToken');
cy.getAllLocalStorage().then((storageData) => {
const token = getToken(storageData);
cy.request({
method: 'DELETE',
@ -693,6 +695,7 @@ const deleteUser = () => {
}).then((response) => {
expect(response.status).to.eq(200);
});
});
};
describe('Glossary page should work properly', { tags: 'Glossary' }, () => {