cypress: fix cypress failure (#15694)

* cypress: fix cypress failure for teamDragAndDrop

* added cypress label

* move cleanup code in the after function

* remove the team creation from test part and put it in before

* remove service.spec as it is already covered in services.spec

* fixed DQ cypress

---------

Co-authored-by: Shailesh Parmar <shailesh.parmar.webdev@gmail.com>
This commit is contained in:
Ashish Gupta 2024-04-01 14:28:18 +05:30 committed by GitHub
parent c061522bbc
commit a64c8493f2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 109 additions and 250 deletions

View File

@ -68,102 +68,122 @@ const DRAG_AND_DROP_TEAM_DETAILS = [
}, },
]; ];
describe('Teams drag and drop should work properly', () => { describe(
beforeEach(() => { 'Teams drag and drop should work properly',
interceptURL('GET', `/api/v1/users?fields=*`, 'getUserDetails'); { tags: 'Settings' },
interceptURL('GET', `/api/v1/permissions/team/name/*`, 'permissions'); () => {
cy.login(); beforeEach(() => {
interceptURL('GET', `/api/v1/users?fields=*`, 'getUserDetails');
interceptURL('GET', `/api/v1/permissions/team/name/*`, 'permissions');
cy.login();
cy.sidebarClick(SidebarItem.SETTINGS); cy.sidebarClick(SidebarItem.SETTINGS);
// Clicking on teams // Clicking on teams
cy.settingClick(GlobalSettingOptions.TEAMS); cy.settingClick(GlobalSettingOptions.TEAMS);
});
it('Add new team for drag and drop', () => {
DRAG_AND_DROP_TEAM_DETAILS.map((team) => {
addTeam(team);
cy.reload();
// asserting the added values
cy.get(`[data-row-key="${team.name}"]`)
.scrollIntoView()
.should('be.visible');
cy.get(`[data-row-key="${team.name}"]`).should(
'contain',
team.description
);
}); });
});
it('Should fail when drop team type is Group', () => { before(() => {
[teamNameBusiness, teamNameDepartment, teamNameDivision].map((team) => { cy.login();
dragAndDropElement(team, teamNameGroup); cy.sidebarClick(SidebarItem.SETTINGS);
toastNotification( // Clicking on teams
`You cannot move to this team as Team Type ${TEAM_TYPE_BY_NAME[team]} can't be Group children` cy.settingClick(GlobalSettingOptions.TEAMS);
);
cy.get('.Toastify__toast-body', { timeout: 10000 }).should('not.exist'); DRAG_AND_DROP_TEAM_DETAILS.map((team) => {
}); addTeam(team);
}); cy.reload();
// asserting the added values
it('Should fail when droppable team type is Department', () => { cy.get(`[data-row-key="${team.name}"]`)
[teamNameBusiness, teamNameDivision].map((team) => { .scrollIntoView()
dragAndDropElement(team, teamNameDepartment); .should('be.visible');
toastNotification( cy.get(`[data-row-key="${team.name}"]`).should(
`You cannot move to this team as Team Type ${TEAM_TYPE_BY_NAME[team]} can't be Department children` 'contain',
); team.description
cy.get('.Toastify__toast-body', { timeout: 10000 }).should('not.exist'); );
});
});
it('Should fail when draggable team type is BusinessUnit and droppable team type is Division', () => {
dragAndDropElement(teamNameBusiness, teamNameDivision);
toastNotification(
`You cannot move to this team as Team Type BusinessUnit can't be Division children`
);
});
[teamNameBusiness, teamNameDivision, teamNameDepartment].map(
(droppableTeamName, index) => {
it(`Should drag and drop on ${TEAM_TYPE_BY_NAME[droppableTeamName]} team type`, () => {
// nested team will be shown once anything is moved under it
if (index !== 0) {
openDragDropDropdown(
[teamNameBusiness, teamNameDivision, teamNameDepartment][index - 1]
);
}
dragAndDropElement(teamNameGroup, droppableTeamName);
confirmationDragAndDropTeam(teamNameGroup, droppableTeamName);
// verify the team is moved under the business team
openDragDropDropdown(droppableTeamName);
cy.get(
`.ant-table-row-level-1[data-row-key="${teamNameGroup}"]`
).should('be.visible');
}); });
} });
);
it(`Should drag and drop team on table level`, () => { after(() => {
// open department team dropdown as it is moved under it from last test cy.login();
openDragDropDropdown(teamNameDepartment); cy.sidebarClick(SidebarItem.SETTINGS);
dragAndDropElement(teamNameGroup, '.ant-table-thead > tr', true); // Clicking on teams
confirmationDragAndDropTeam(teamNameGroup, 'Organization'); cy.settingClick(GlobalSettingOptions.TEAMS);
// verify the team is moved under the table level [
cy.get(`.ant-table-row-level-0[data-row-key="${teamNameGroup}"]`).should( teamNameBusiness,
'be.visible' teamNameDivision,
); teamNameDepartment,
}); teamNameGroup,
].map((teamName) => {
it('Permanently deleting a team for drag and drop', () => {
[teamNameBusiness, teamNameDivision, teamNameDepartment, teamNameGroup].map(
(teamName) => {
deleteTeamPermanently(teamName); deleteTeamPermanently(teamName);
});
});
it('Should fail when drop team type is Group', () => {
[teamNameBusiness, teamNameDepartment, teamNameDivision].map((team) => {
dragAndDropElement(team, teamNameGroup);
toastNotification(
`You cannot move to this team as Team Type ${TEAM_TYPE_BY_NAME[team]} can't be Group children`
);
cy.get('.Toastify__toast-body', { timeout: 10000 }).should('not.exist');
});
});
it('Should fail when droppable team type is Department', () => {
[teamNameBusiness, teamNameDivision].map((team) => {
dragAndDropElement(team, teamNameDepartment);
toastNotification(
`You cannot move to this team as Team Type ${TEAM_TYPE_BY_NAME[team]} can't be Department children`
);
cy.get('.Toastify__toast-body', { timeout: 10000 }).should('not.exist');
});
});
it('Should fail when draggable team type is BusinessUnit and droppable team type is Division', () => {
dragAndDropElement(teamNameBusiness, teamNameDivision);
toastNotification(
`You cannot move to this team as Team Type BusinessUnit can't be Division children`
);
});
[teamNameBusiness, teamNameDivision, teamNameDepartment].map(
(droppableTeamName, index) => {
it(`Should drag and drop on ${TEAM_TYPE_BY_NAME[droppableTeamName]} team type`, () => {
// nested team will be shown once anything is moved under it
if (index !== 0) {
openDragDropDropdown(
[teamNameBusiness, teamNameDivision, teamNameDepartment][
index - 1
]
);
}
dragAndDropElement(teamNameGroup, droppableTeamName);
confirmationDragAndDropTeam(teamNameGroup, droppableTeamName);
// verify the team is moved under the business team
openDragDropDropdown(droppableTeamName);
cy.get(
`.ant-table-row-level-1[data-row-key="${teamNameGroup}"]`
).should('be.visible');
});
} }
); );
});
}); it(`Should drag and drop team on table level`, () => {
// open department team dropdown as it is moved under it from last test
openDragDropDropdown(teamNameDepartment);
dragAndDropElement(teamNameGroup, '.ant-table-thead > tr', true);
confirmationDragAndDropTeam(teamNameGroup, 'Organization');
// verify the team is moved under the table level
cy.get(`.ant-table-row-level-0[data-row-key="${teamNameGroup}"]`)
.scrollIntoView()
.should('be.visible');
});
}
);

View File

@ -909,8 +909,8 @@ describe(
verifyResponseStatusCode('@tableProfiler', 200); verifyResponseStatusCode('@tableProfiler', 200);
verifyResponseStatusCode('@systemProfiler', 200); verifyResponseStatusCode('@systemProfiler', 200);
cy.get('[data-testid="profiler-setting-btn"]').click(); cy.get('[data-testid="profiler-setting-btn"]').click();
verifyResponseStatusCode('@tableProfilerConfig', 200);
cy.get('.ant-modal-body').should('be.visible'); cy.get('.ant-modal-body').should('be.visible');
verifyResponseStatusCode('@tableProfilerConfig', 200);
cy.get('[data-testid="slider-input"]') cy.get('[data-testid="slider-input"]')
.clear() .clear()
.type(profilerSetting.profileSample); .type(profilerSetting.profileSample);

View File

@ -1,161 +0,0 @@
/*
* Copyright 2022 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 {
descriptionBox,
interceptURL,
verifyResponseStatusCode,
} from '../../common/common';
import { searchServiceFromSettingPage } from '../../common/serviceUtils';
import { service } from '../../constants/constants';
import { GlobalSettingOptions } from '../../constants/settings.constant';
describe('Services page should work properly', { tags: 'Integration' }, () => {
beforeEach(() => {
interceptURL(
'GET',
'/api/v1/system/config/pipeline-service-client',
'pipelineServiceClient'
);
interceptURL(
'GET',
`/api/v1/*?service=${service.name}&fields=*`,
'serviceDetails'
);
interceptURL(
'GET',
`/api/v1/services/ingestionPipelines?fields=*&service=${service.name}*&serviceType=${service.serviceType}`,
'ingestionPipelines'
);
cy.login();
// redirecting to services page
cy.settingClick(GlobalSettingOptions.DATABASES);
});
it('Update service description', () => {
searchServiceFromSettingPage(service.name);
cy.get(`[data-testid="service-name-${service.name}"]`)
.should('be.visible')
.click();
verifyResponseStatusCode('@serviceDetails', 200);
verifyResponseStatusCode('@ingestionPipelines', 200);
verifyResponseStatusCode('@pipelineServiceClient', 200);
// need wait here
cy.get('[data-testid="edit-description"]')
.should('exist')
.should('be.visible')
.click({ force: true });
cy.get(descriptionBox).clear().type(service.newDescription);
cy.get('[data-testid="save"]').click();
cy.get(
'[data-testid="description-container"] [data-testid="viewer-container"] [data-testid="markdown-parser"] :nth-child(1) .toastui-editor-contents p'
).contains(service.newDescription);
cy.get(':nth-child(1) > .link-title').click();
searchServiceFromSettingPage(service.name);
cy.get('.toastui-editor-contents > p').contains(service.newDescription);
});
it('Update owner and check description', () => {
searchServiceFromSettingPage(service.name);
cy.get(`[data-testid="service-name-${service.name}"]`)
.should('be.visible')
.click();
verifyResponseStatusCode('@serviceDetails', 200);
verifyResponseStatusCode('@ingestionPipelines', 200);
verifyResponseStatusCode('@pipelineServiceClient', 200);
interceptURL(
'GET',
'/api/v1/search/query?q=*%20AND%20teamType:Group&from=0&size=*&index=team_search_index&sort_field=displayName.keyword&sort_order=asc',
'editOwner'
);
cy.get('[data-testid="edit-owner"]')
.should('exist')
.should('be.visible')
.click();
verifyResponseStatusCode('@editOwner', 200);
cy.get(
'.ant-popover-inner-content > .ant-tabs > .ant-tabs-nav > .ant-tabs-nav-wrap'
)
.contains('Users')
.click();
interceptURL(
'PATCH',
'/api/v1/services/databaseServices/*',
'updateService'
);
interceptURL(
'GET',
'/api/v1/search/query?q=*%20AND%20isBot:false*&index=user_search_index',
'searchApi'
);
cy.get('[data-testid="owner-select-users-search-bar"]').type(service.Owner);
verifyResponseStatusCode('@searchApi', 200);
cy.get('[data-testid="selectable-list"]')
.contains(service.Owner)
.scrollIntoView()
.click();
verifyResponseStatusCode('@updateService', 200);
// Checking if description exists after assigning the owner
cy.get(':nth-child(1) > .link-title').click();
// need wait here
searchServiceFromSettingPage(service.name);
cy.get('[data-testid="viewer-container"]').contains(service.newDescription);
});
it('Remove owner from service', () => {
interceptURL(
'GET',
'/api/v1/system/config/pipeline-service-client',
'getService'
);
interceptURL('GET', '/api/v1/users?*', 'waitForUsers');
searchServiceFromSettingPage(service.name);
cy.get(`[data-testid="service-name-${service.name}"]`)
.should('be.visible')
.click();
verifyResponseStatusCode('@serviceDetails', 200);
verifyResponseStatusCode('@ingestionPipelines', 200);
verifyResponseStatusCode('@pipelineServiceClient', 200);
cy.get('[data-testid="edit-owner"]')
.should('exist')
.should('be.visible')
.click();
verifyResponseStatusCode('@waitForUsers', 200);
interceptURL('PATCH', '/api/v1/services/databaseServices/*', 'removeOwner');
cy.get('[data-testid="selectable-list"]')
.contains(service.Owner)
.should('be.visible');
cy.get('[data-testid="remove-owner"]')
.should('exist')
.should('be.visible')
.click();
verifyResponseStatusCode('@removeOwner', 200);
// Check if Owner exist
cy.get('[data-testid="owner-link"]')
.scrollIntoView()
.should('exist')
.contains('No Owner');
});
});

View File

@ -45,7 +45,7 @@ const HARD_DELETE_TEAM_DETAILS = {
email: 'team@gmail.com', email: 'team@gmail.com',
}; };
describe('Teams flow should work properly', () => { describe('Teams flow should work properly', { tags: 'Settings' }, () => {
beforeEach(() => { beforeEach(() => {
interceptURL('GET', `/api/v1/users?fields=*`, 'getUserDetails'); interceptURL('GET', `/api/v1/users?fields=*`, 'getUserDetails');
interceptURL('GET', `/api/v1/permissions/team/name/*`, 'permissions'); interceptURL('GET', `/api/v1/permissions/team/name/*`, 'permissions');