2022-08-17 19:08:35 +05:30
|
|
|
/*
|
2022-12-27 12:37:58 +05:30
|
|
|
* Copyright 2022 Collate.
|
2022-08-17 19:08:35 +05:30
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2023-06-01 21:27:26 +05:30
|
|
|
// eslint-disable-next-line spaced-comment
|
|
|
|
/// <reference types="Cypress" />
|
|
|
|
|
2022-11-14 18:09:38 +05:30
|
|
|
import {
|
2023-01-15 18:24:10 +05:30
|
|
|
addTeam,
|
|
|
|
descriptionBox,
|
|
|
|
interceptURL,
|
|
|
|
toastNotification,
|
|
|
|
updateOwner,
|
|
|
|
uuid,
|
|
|
|
verifyResponseStatusCode,
|
2022-11-14 18:09:38 +05:30
|
|
|
} from '../../common/common';
|
2022-09-23 16:05:54 +05:30
|
|
|
|
2023-10-02 18:12:23 +05:30
|
|
|
const updatedDescription = 'This is updated description';
|
2022-08-17 19:08:35 +05:30
|
|
|
|
2023-10-16 23:08:07 +05:30
|
|
|
const teamName = `team-ct-test-${uuid()}`;
|
2022-08-17 19:08:35 +05:30
|
|
|
const TEAM_DETAILS = {
|
|
|
|
name: teamName,
|
2023-10-02 18:12:23 +05:30
|
|
|
updatedName: `${teamName}-updated`,
|
2023-04-21 10:20:40 +05:30
|
|
|
teamType: 'Group',
|
2022-08-17 19:08:35 +05:30
|
|
|
description: `This is ${teamName} description`,
|
2022-12-23 11:07:07 +05:30
|
|
|
username: 'Aaron Johnson',
|
2023-04-21 10:20:40 +05:30
|
|
|
userId: 'aaron_johnson0',
|
2022-08-17 19:08:35 +05:30
|
|
|
assetname: 'dim_address',
|
2023-05-11 21:46:29 +05:30
|
|
|
email: 'team1@gmail.com',
|
2023-05-17 23:58:09 +05:30
|
|
|
updatedEmail: 'updatedemail@gmail.com',
|
2022-08-17 19:08:35 +05:30
|
|
|
};
|
2022-10-08 00:07:24 +05:30
|
|
|
const hardDeleteTeamName = `team-ct-test-${uuid()}`;
|
|
|
|
const HARD_DELETE_TEAM_DETAILS = {
|
|
|
|
name: hardDeleteTeamName,
|
|
|
|
displayName: hardDeleteTeamName,
|
|
|
|
teamType: 'Department',
|
|
|
|
description: `This is ${hardDeleteTeamName} description`,
|
2023-05-11 21:46:29 +05:30
|
|
|
email: 'team@gmail.com',
|
2022-10-08 00:07:24 +05:30
|
|
|
};
|
2022-08-17 19:08:35 +05:30
|
|
|
|
|
|
|
describe('Teams flow should work properly', () => {
|
2022-09-29 15:21:33 +05:30
|
|
|
beforeEach(() => {
|
2022-10-08 00:07:24 +05:30
|
|
|
interceptURL('GET', `/api/v1/users?fields=*`, 'getUserDetails');
|
2023-07-31 18:27:08 +05:30
|
|
|
interceptURL('GET', `/api/v1/permissions/team/name/*`, 'permissions');
|
2022-11-16 13:21:23 +05:30
|
|
|
cy.login();
|
2022-08-17 19:08:35 +05:30
|
|
|
|
2023-08-29 13:01:06 +05:30
|
|
|
cy.get('[data-testid="app-bar-item-settings"]')
|
|
|
|
.should('be.visible')
|
|
|
|
.click();
|
2022-09-29 15:21:33 +05:30
|
|
|
|
2023-01-15 18:24:10 +05:30
|
|
|
// Clicking on teams
|
2022-11-14 18:09:38 +05:30
|
|
|
cy.get('[data-testid="settings-left-panel"]')
|
2022-08-17 19:08:35 +05:30
|
|
|
.should('exist')
|
|
|
|
.should('be.visible')
|
2023-06-21 12:59:20 +05:30
|
|
|
.contains('Teams')
|
2022-08-17 19:08:35 +05:30
|
|
|
.click();
|
|
|
|
});
|
|
|
|
|
2022-08-19 19:34:01 +05:30
|
|
|
it('Add new team', () => {
|
2022-09-26 19:43:34 +05:30
|
|
|
addTeam(TEAM_DETAILS);
|
2022-08-17 19:08:35 +05:30
|
|
|
|
|
|
|
cy.reload();
|
|
|
|
|
2023-01-15 18:24:10 +05:30
|
|
|
// asserting the added values
|
2022-11-14 18:09:38 +05:30
|
|
|
cy.get(`[data-row-key="${TEAM_DETAILS.name}"]`)
|
2023-07-28 16:46:34 +05:30
|
|
|
.scrollIntoView()
|
2022-11-14 18:09:38 +05:30
|
|
|
.should('be.visible');
|
|
|
|
cy.get(`[data-row-key="${TEAM_DETAILS.name}"]`).should(
|
|
|
|
'contain',
|
|
|
|
TEAM_DETAILS.description
|
|
|
|
);
|
2022-08-17 19:08:35 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('Add owner to created team', () => {
|
2023-01-15 18:24:10 +05:30
|
|
|
// Clicking on created team
|
2022-11-14 18:09:38 +05:30
|
|
|
cy.get(`[data-row-key="${TEAM_DETAILS.name}"]`)
|
|
|
|
.contains(TEAM_DETAILS.name)
|
|
|
|
.click();
|
2023-03-28 14:39:41 +05:30
|
|
|
updateOwner();
|
2022-08-17 19:08:35 +05:30
|
|
|
});
|
|
|
|
|
2023-05-17 23:58:09 +05:30
|
|
|
it('Update email of created team', () => {
|
|
|
|
interceptURL('PATCH', '/api/v1/teams/*', 'updateEmail');
|
|
|
|
interceptURL('GET', '/api/v1/teams/name/*', 'getTeam');
|
|
|
|
|
|
|
|
// Clicking on created team
|
|
|
|
cy.get(`[data-row-key="${TEAM_DETAILS.name}"]`)
|
|
|
|
.contains(TEAM_DETAILS.name)
|
|
|
|
.click();
|
|
|
|
verifyResponseStatusCode('@getTeam', 200);
|
|
|
|
|
2023-06-01 21:27:26 +05:30
|
|
|
cy.get('[data-testid="edit-email"]').should('be.visible').scrollIntoView();
|
|
|
|
cy.get('[data-testid="edit-email"]').click();
|
2023-05-17 23:58:09 +05:30
|
|
|
cy.get('[data-testid="email-input"]')
|
|
|
|
.should('be.visible')
|
|
|
|
.clear()
|
|
|
|
.type(TEAM_DETAILS.updatedEmail);
|
|
|
|
|
|
|
|
cy.get('[data-testid="save-edit-email"]').should('be.visible').click();
|
|
|
|
|
|
|
|
verifyResponseStatusCode('@updateEmail', 200);
|
|
|
|
|
|
|
|
cy.reload();
|
|
|
|
|
|
|
|
// check for updated email
|
|
|
|
cy.get('[data-testid="email-value"]')
|
|
|
|
.should('be.visible')
|
|
|
|
.contains(TEAM_DETAILS.updatedEmail);
|
|
|
|
});
|
|
|
|
|
2023-04-21 10:20:40 +05:30
|
|
|
it('Add user to created team', () => {
|
2023-09-15 09:27:21 +05:30
|
|
|
interceptURL('GET', '/api/v1/users?limit=25&isBot=false', 'getUsers');
|
2023-04-21 10:20:40 +05:30
|
|
|
interceptURL('PATCH', '/api/v1/teams/*', 'updateTeam');
|
|
|
|
// Clicking on created team
|
2022-11-14 18:09:38 +05:30
|
|
|
cy.get(`[data-row-key="${TEAM_DETAILS.name}"]`)
|
|
|
|
.contains(TEAM_DETAILS.name)
|
|
|
|
.click();
|
2023-04-21 10:20:40 +05:30
|
|
|
verifyResponseStatusCode('@permissions', 200);
|
2023-10-02 18:12:23 +05:30
|
|
|
cy.get('[data-testid="users"]').click();
|
|
|
|
cy.get('[data-testid="add-new-user"]').scrollIntoView().click();
|
2022-09-14 19:19:42 +05:30
|
|
|
verifyResponseStatusCode('@getUsers', 200);
|
2023-07-28 16:46:34 +05:30
|
|
|
cy.get('[data-testid="selectable-list"] [data-testid="searchbar"]').type(
|
|
|
|
TEAM_DETAILS.username
|
|
|
|
);
|
2023-04-21 10:20:40 +05:30
|
|
|
cy.get('[data-testid="selectable-list"]')
|
|
|
|
.find(`[title="${TEAM_DETAILS.username}"]`)
|
2022-09-14 19:19:42 +05:30
|
|
|
.click();
|
2023-06-01 21:27:26 +05:30
|
|
|
cy.get('[data-testid="selectable-list"]')
|
|
|
|
.find(`[title="${TEAM_DETAILS.username}"] input[type='checkbox']`)
|
|
|
|
.should('be.checked');
|
|
|
|
|
2023-04-21 10:20:40 +05:30
|
|
|
cy.get('[data-testid="selectable-list-update-btn"]')
|
2022-08-17 19:08:35 +05:30
|
|
|
.should('be.visible')
|
|
|
|
.click();
|
2023-04-21 10:20:40 +05:30
|
|
|
verifyResponseStatusCode('@updateTeam', 200);
|
|
|
|
cy.get(`[data-testid="${TEAM_DETAILS.userId}"]`).should('be.visible');
|
2022-12-23 11:07:07 +05:30
|
|
|
});
|
|
|
|
|
2023-04-21 10:20:40 +05:30
|
|
|
it('Remove added user from created team', () => {
|
2023-09-15 09:27:21 +05:30
|
|
|
interceptURL('GET', '/api/v1/users?limit=25&isBot=false', 'getUsers');
|
2023-04-21 10:20:40 +05:30
|
|
|
interceptURL('PATCH', '/api/v1/teams/*', 'updateTeam');
|
|
|
|
// Clicking on created team
|
2022-12-23 11:07:07 +05:30
|
|
|
cy.get(`[data-row-key="${TEAM_DETAILS.name}"]`)
|
|
|
|
.contains(TEAM_DETAILS.name)
|
|
|
|
.click();
|
2023-10-02 18:12:23 +05:30
|
|
|
cy.get('[data-testid="users"]').click();
|
2023-04-21 10:20:40 +05:30
|
|
|
verifyResponseStatusCode('@getUserDetails', 200);
|
|
|
|
verifyResponseStatusCode('@permissions', 200);
|
|
|
|
cy.get('[data-testid="add-new-user"]').should('be.visible').click();
|
2022-12-23 11:07:07 +05:30
|
|
|
verifyResponseStatusCode('@getUsers', 200);
|
2023-04-21 10:20:40 +05:30
|
|
|
cy.get('[data-testid="selectable-list"]')
|
|
|
|
.find(`[title="${TEAM_DETAILS.username}"]`)
|
2022-08-26 14:14:22 +05:30
|
|
|
.click();
|
2023-04-21 10:20:40 +05:30
|
|
|
cy.get('[data-testid="selectable-list-update-btn"]')
|
2022-08-17 19:08:35 +05:30
|
|
|
.should('be.visible')
|
2022-09-07 18:50:29 +05:30
|
|
|
.click();
|
2023-04-21 10:20:40 +05:30
|
|
|
verifyResponseStatusCode('@updateTeam', 200);
|
|
|
|
verifyResponseStatusCode('@getUserDetails', 200);
|
|
|
|
cy.get(`[data-testid="${TEAM_DETAILS.userId}"]`).should('not.exist');
|
2023-01-15 18:24:10 +05:30
|
|
|
});
|
2022-08-17 19:08:35 +05:30
|
|
|
|
|
|
|
it('Join team should work properly', () => {
|
2022-10-04 11:42:39 +05:30
|
|
|
interceptURL('GET', '/api/v1/users*', 'getUsers');
|
2023-01-15 18:24:10 +05:30
|
|
|
// Click on created team
|
2022-11-14 18:09:38 +05:30
|
|
|
cy.get(`[data-row-key="${TEAM_DETAILS.name}"]`)
|
|
|
|
.contains(TEAM_DETAILS.name)
|
|
|
|
.click();
|
2022-08-17 19:08:35 +05:30
|
|
|
|
2023-10-02 18:12:23 +05:30
|
|
|
cy.get('[data-testid="users"]').click();
|
|
|
|
|
2022-10-04 11:42:39 +05:30
|
|
|
verifyResponseStatusCode('@getUsers', 200);
|
|
|
|
|
2023-01-15 18:24:10 +05:30
|
|
|
// Click on join teams button
|
2023-10-02 18:12:23 +05:30
|
|
|
cy.get('[data-testid="join-teams"]')
|
|
|
|
.scrollIntoView()
|
|
|
|
.should('be.visible')
|
|
|
|
.click();
|
2022-08-17 19:08:35 +05:30
|
|
|
|
2023-01-15 18:24:10 +05:30
|
|
|
// Verify toast notification
|
2022-08-17 19:08:35 +05:30
|
|
|
toastNotification('Team joined successfully!');
|
|
|
|
|
|
|
|
cy.get('body').find('[data-testid="leave-team-button"]').should('exist');
|
|
|
|
});
|
|
|
|
|
2022-10-08 00:07:24 +05:30
|
|
|
it('Update display name for created team', () => {
|
2022-09-14 19:19:42 +05:30
|
|
|
interceptURL(
|
|
|
|
'GET',
|
|
|
|
`/api/v1/teams/name/${TEAM_DETAILS.name}*`,
|
|
|
|
'getSelectedTeam'
|
|
|
|
);
|
2022-10-08 00:07:24 +05:30
|
|
|
interceptURL('PATCH', `/api/v1/teams/*`, 'patchTeam');
|
2023-01-15 18:24:10 +05:30
|
|
|
// Click on created team name
|
2022-11-14 18:09:38 +05:30
|
|
|
cy.get(`[data-row-key="${TEAM_DETAILS.name}"]`)
|
|
|
|
.contains(TEAM_DETAILS.name)
|
|
|
|
.click();
|
2022-08-17 19:08:35 +05:30
|
|
|
|
2022-09-14 19:19:42 +05:30
|
|
|
verifyResponseStatusCode('@getSelectedTeam', 200);
|
2023-01-15 18:24:10 +05:30
|
|
|
// Click on edit display name
|
2023-10-02 18:12:23 +05:30
|
|
|
cy.get('[data-testid="edit-team-name"]').should('be.visible').click();
|
2022-08-17 19:08:35 +05:30
|
|
|
|
2023-01-15 18:24:10 +05:30
|
|
|
// Enter the updated team name
|
2023-10-02 18:12:23 +05:30
|
|
|
cy.get('[data-testid="team-name-input"]')
|
2022-08-17 19:08:35 +05:30
|
|
|
.should('exist')
|
|
|
|
.should('be.visible')
|
|
|
|
.clear()
|
2023-10-02 18:12:23 +05:30
|
|
|
.type(TEAM_DETAILS.updatedName);
|
2022-08-17 19:08:35 +05:30
|
|
|
|
2023-01-15 18:24:10 +05:30
|
|
|
// Save the updated display name
|
2022-08-17 19:08:35 +05:30
|
|
|
cy.get('[data-testid="saveAssociatedTag"]')
|
|
|
|
.should('exist')
|
|
|
|
.should('be.visible')
|
|
|
|
.click();
|
2022-09-20 19:57:13 +05:30
|
|
|
|
2022-10-08 00:07:24 +05:30
|
|
|
verifyResponseStatusCode('@patchTeam', 200);
|
|
|
|
verifyResponseStatusCode('@getSelectedTeam', 200);
|
2023-01-15 18:24:10 +05:30
|
|
|
// Validate the updated display name
|
2022-10-08 00:07:24 +05:30
|
|
|
cy.get('[data-testid="team-heading"]').then(($el) => {
|
2023-10-02 18:12:23 +05:30
|
|
|
cy.wrap($el).should('have.text', TEAM_DETAILS.updatedName);
|
2022-10-08 00:07:24 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
cy.get('[data-testid="inactive-link"]')
|
2023-10-02 18:12:23 +05:30
|
|
|
.scrollIntoView()
|
|
|
|
.should('contain', TEAM_DETAILS.updatedName);
|
2022-10-08 00:07:24 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('Update description for created team', () => {
|
2023-01-15 18:24:10 +05:30
|
|
|
interceptURL(
|
|
|
|
'GET',
|
|
|
|
`/api/v1/teams/name/${TEAM_DETAILS.name}?fields=*&include=all`,
|
|
|
|
'getSelectedTeam'
|
|
|
|
);
|
2022-12-23 11:07:07 +05:30
|
|
|
interceptURL('PATCH', '/api/v1/teams/*', 'patchDescription');
|
2023-01-15 18:24:10 +05:30
|
|
|
// Click on created team name
|
2022-11-14 18:09:38 +05:30
|
|
|
cy.get(`[data-row-key="${TEAM_DETAILS.name}"]`)
|
|
|
|
.contains(TEAM_DETAILS.name)
|
2022-10-08 00:07:24 +05:30
|
|
|
.click();
|
|
|
|
|
|
|
|
verifyResponseStatusCode('@getSelectedTeam', 200);
|
|
|
|
|
2023-01-15 18:24:10 +05:30
|
|
|
// Validate the updated display name
|
|
|
|
cy.get('[data-testid="team-heading"]').should(
|
|
|
|
'contain',
|
2023-10-02 18:12:23 +05:30
|
|
|
`${TEAM_DETAILS.updatedName}`
|
2023-01-15 18:24:10 +05:30
|
|
|
);
|
2022-10-04 22:49:36 +05:30
|
|
|
|
|
|
|
cy.get('[data-testid="inactive-link"]')
|
|
|
|
.should('be.visible')
|
2023-10-02 18:12:23 +05:30
|
|
|
.should('contain', TEAM_DETAILS.updatedName);
|
2022-08-17 19:08:35 +05:30
|
|
|
|
2023-10-25 18:03:13 +05:30
|
|
|
cy.get('[role="tablist"] [data-icon="right"]').click();
|
|
|
|
|
2023-01-15 18:24:10 +05:30
|
|
|
// Click on edit description button
|
2022-10-04 22:49:36 +05:30
|
|
|
cy.get('[data-testid="edit-description"]')
|
2022-10-08 00:07:24 +05:30
|
|
|
.should('be.visible')
|
|
|
|
.click({ force: true });
|
2022-08-17 19:08:35 +05:30
|
|
|
|
2023-01-15 18:24:10 +05:30
|
|
|
// Entering updated description
|
2023-10-02 18:12:23 +05:30
|
|
|
cy.get(descriptionBox).clear().type(updatedDescription);
|
2022-08-17 19:08:35 +05:30
|
|
|
|
|
|
|
cy.get('[data-testid="save"]').should('be.visible').click();
|
2023-01-15 18:24:10 +05:30
|
|
|
verifyResponseStatusCode('@patchDescription', 200);
|
|
|
|
|
|
|
|
// Validating the updated description
|
2022-08-17 19:08:35 +05:30
|
|
|
cy.get('[data-testid="description"] p').should(
|
|
|
|
'contain',
|
2023-10-02 18:12:23 +05:30
|
|
|
updatedDescription
|
2022-08-17 19:08:35 +05:30
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Leave team flow should work properly', () => {
|
2022-09-14 19:19:42 +05:30
|
|
|
interceptURL(
|
|
|
|
'GET',
|
|
|
|
`/api/v1/teams/name/${TEAM_DETAILS.name}*`,
|
|
|
|
'getSelectedTeam'
|
|
|
|
);
|
|
|
|
|
2023-01-15 18:24:10 +05:30
|
|
|
// Click on created team
|
2022-11-14 18:09:38 +05:30
|
|
|
cy.get(`[data-row-key="${TEAM_DETAILS.name}"]`)
|
|
|
|
.contains(TEAM_DETAILS.name)
|
|
|
|
.click();
|
2022-08-17 19:08:35 +05:30
|
|
|
|
2022-09-14 19:19:42 +05:30
|
|
|
verifyResponseStatusCode('@getSelectedTeam', 200);
|
2022-10-08 00:07:24 +05:30
|
|
|
cy.get('[data-testid="team-heading"]')
|
|
|
|
.should('be.visible')
|
|
|
|
.contains(TEAM_DETAILS.name);
|
2022-08-17 19:08:35 +05:30
|
|
|
// //Click on Leave team
|
2023-10-02 18:12:23 +05:30
|
|
|
cy.get('[data-testid="leave-team-button"]').click();
|
2022-08-17 19:08:35 +05:30
|
|
|
|
|
|
|
// //Click on confirm button
|
|
|
|
cy.get('[data-testid="save-button"]').should('be.visible').click();
|
|
|
|
|
|
|
|
toastNotification('Left the team successfully');
|
|
|
|
|
|
|
|
cy.get('body').find('[data-testid="join-teams"]').should('exist');
|
|
|
|
});
|
|
|
|
|
2022-09-26 19:43:34 +05:30
|
|
|
it('Permanently deleting soft deleted team should work properly', () => {
|
2022-09-14 19:19:42 +05:30
|
|
|
interceptURL(
|
|
|
|
'GET',
|
|
|
|
`/api/v1/teams/name/${TEAM_DETAILS.name}*`,
|
|
|
|
'getSelectedTeam'
|
|
|
|
);
|
2022-09-26 19:43:34 +05:30
|
|
|
|
2023-01-15 18:24:10 +05:30
|
|
|
// Click on created team
|
2022-11-14 18:09:38 +05:30
|
|
|
cy.get(`[data-row-key="${TEAM_DETAILS.name}"]`)
|
|
|
|
.contains(TEAM_DETAILS.name)
|
|
|
|
.click();
|
2022-08-17 19:08:35 +05:30
|
|
|
|
2022-09-14 19:19:42 +05:30
|
|
|
verifyResponseStatusCode('@getSelectedTeam', 200);
|
2022-10-08 00:07:24 +05:30
|
|
|
cy.get('[data-testid="team-heading"]')
|
|
|
|
.should('be.visible')
|
2023-10-02 18:12:23 +05:30
|
|
|
.contains(TEAM_DETAILS.updatedName);
|
|
|
|
cy.get('[data-testid="manage-button"]')
|
2022-08-17 19:08:35 +05:30
|
|
|
.should('exist')
|
|
|
|
.should('be.visible')
|
|
|
|
.click();
|
|
|
|
|
2022-09-14 19:19:42 +05:30
|
|
|
cy.get('[data-menu-id*="delete-button"]').should('be.visible');
|
|
|
|
|
2022-09-03 12:17:35 +05:30
|
|
|
cy.get('[data-testid="delete-button-title"]')
|
2022-08-26 14:14:22 +05:30
|
|
|
.should('exist')
|
|
|
|
.should('be.visible')
|
|
|
|
.click();
|
|
|
|
|
2022-09-26 19:43:34 +05:30
|
|
|
cy.get('[data-testid="confirm-button"]')
|
|
|
|
.should('exist')
|
|
|
|
.should('be.disabled');
|
|
|
|
|
2023-01-15 18:24:10 +05:30
|
|
|
// Click on soft delete option
|
2022-09-26 19:43:34 +05:30
|
|
|
cy.get('[data-testid="soft-delete-option"]')
|
|
|
|
.should('contain', TEAM_DETAILS.name)
|
|
|
|
.should('be.visible')
|
|
|
|
.click();
|
|
|
|
|
|
|
|
cy.get('[data-testid="confirmation-text-input"]').type('DELETE');
|
|
|
|
|
|
|
|
interceptURL('DELETE', '/api/v1/teams/*', 'softDeleteTeam');
|
|
|
|
|
|
|
|
cy.get('[data-testid="confirm-button"]')
|
|
|
|
.should('exist')
|
|
|
|
.should('be.visible')
|
|
|
|
.click();
|
|
|
|
|
|
|
|
verifyResponseStatusCode('@softDeleteTeam', 200);
|
|
|
|
|
2023-01-15 18:24:10 +05:30
|
|
|
// Verify the toast message
|
2022-09-26 19:43:34 +05:30
|
|
|
toastNotification('Team deleted successfully!');
|
|
|
|
|
2023-01-15 18:24:10 +05:30
|
|
|
// Check if soft deleted team is shown when 'Deleted Teams' switch is on
|
2022-09-26 19:43:34 +05:30
|
|
|
cy.get('table').should('not.contain', TEAM_DETAILS.name);
|
|
|
|
|
2023-06-22 11:22:39 +05:30
|
|
|
cy.get('[data-testid="show-deleted"').should('exist').click();
|
2022-09-26 19:43:34 +05:30
|
|
|
|
|
|
|
interceptURL(
|
|
|
|
'GET',
|
|
|
|
`/api/v1/teams/name/${TEAM_DETAILS.name}*`,
|
|
|
|
'getSelectedTeam'
|
|
|
|
);
|
2023-08-08 10:42:34 +05:30
|
|
|
interceptURL(
|
|
|
|
'GET',
|
|
|
|
`/api/v1/teams?limit=100000&parentTeam=${TEAM_DETAILS.name}&include=all`,
|
|
|
|
'getTeamParent'
|
|
|
|
);
|
|
|
|
interceptURL(
|
|
|
|
'GET',
|
|
|
|
`/api/v1/teams?fields=userCount%2CchildrenCount%2Cowns%2Cparents&limit=100000&parentTeam=${TEAM_DETAILS.name}&include=all`,
|
|
|
|
'getChildrenCount'
|
|
|
|
);
|
2022-09-26 19:43:34 +05:30
|
|
|
|
|
|
|
cy.get('table').should('contain', TEAM_DETAILS.name).click();
|
|
|
|
|
|
|
|
cy.get('table').find('.ant-table-row').contains(TEAM_DETAILS.name).click();
|
|
|
|
|
|
|
|
verifyResponseStatusCode('@getSelectedTeam', 200);
|
2023-08-08 10:42:34 +05:30
|
|
|
verifyResponseStatusCode('@getTeamParent', 200);
|
|
|
|
verifyResponseStatusCode('@getChildrenCount', 200);
|
|
|
|
|
2022-10-08 00:07:24 +05:30
|
|
|
cy.get('[data-testid="team-heading"]')
|
|
|
|
.should('be.visible')
|
2023-10-02 18:12:23 +05:30
|
|
|
.contains(TEAM_DETAILS.updatedName);
|
2022-09-26 19:43:34 +05:30
|
|
|
|
2023-10-02 18:12:23 +05:30
|
|
|
cy.get('[data-testid="manage-button"]')
|
2022-09-26 19:43:34 +05:30
|
|
|
.should('exist')
|
|
|
|
.should('be.visible')
|
|
|
|
.click();
|
|
|
|
|
|
|
|
cy.get('[data-menu-id*="delete-button"]').should('be.visible');
|
|
|
|
|
|
|
|
cy.get('[data-testid="delete-button-title"]')
|
|
|
|
.should('exist')
|
|
|
|
.should('be.visible')
|
|
|
|
.click();
|
|
|
|
|
2023-01-15 18:24:10 +05:30
|
|
|
// Check if soft delete option is not present
|
2022-09-26 19:43:34 +05:30
|
|
|
cy.get('[data-testid="soft-delete-option"]').should('not.exist');
|
|
|
|
|
2023-01-15 18:24:10 +05:30
|
|
|
// Click on permanent delete option
|
2022-09-26 19:43:34 +05:30
|
|
|
cy.get('[data-testid="hard-delete-option"]')
|
|
|
|
.should('contain', TEAM_DETAILS.name)
|
|
|
|
.should('be.visible')
|
|
|
|
.click();
|
|
|
|
|
|
|
|
cy.get('[data-testid="confirmation-text-input"]').type('DELETE');
|
|
|
|
|
|
|
|
interceptURL('DELETE', '/api/v1/teams/*', 'deleteTeam');
|
|
|
|
cy.get('[data-testid="confirm-button"]')
|
|
|
|
.should('exist')
|
|
|
|
.should('be.visible')
|
|
|
|
.click();
|
|
|
|
|
|
|
|
verifyResponseStatusCode('@deleteTeam', 200);
|
|
|
|
|
2023-01-15 18:24:10 +05:30
|
|
|
// Verify the toast message
|
2022-09-26 19:43:34 +05:30
|
|
|
toastNotification('Team deleted successfully!');
|
|
|
|
|
2023-01-15 18:24:10 +05:30
|
|
|
// Validating the deleted team
|
2022-09-26 19:43:34 +05:30
|
|
|
|
|
|
|
cy.get('table').should('not.contain', TEAM_DETAILS.name);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Permanently deleting a team without soft deleting should work properly', () => {
|
2023-01-15 18:24:10 +05:30
|
|
|
// Add a new team
|
2022-10-08 00:07:24 +05:30
|
|
|
addTeam(HARD_DELETE_TEAM_DETAILS);
|
2022-09-26 19:43:34 +05:30
|
|
|
|
|
|
|
interceptURL(
|
|
|
|
'GET',
|
2022-10-08 00:07:24 +05:30
|
|
|
`/api/v1/teams/name/${HARD_DELETE_TEAM_DETAILS.name}*`,
|
2022-09-26 19:43:34 +05:30
|
|
|
'getSelectedTeam'
|
|
|
|
);
|
2023-01-15 18:24:10 +05:30
|
|
|
// Click on created team
|
2022-11-14 18:09:38 +05:30
|
|
|
cy.get(`[data-row-key="${HARD_DELETE_TEAM_DETAILS.name}"]`)
|
2022-10-08 00:07:24 +05:30
|
|
|
.contains(HARD_DELETE_TEAM_DETAILS.name)
|
|
|
|
.click();
|
2022-09-26 19:43:34 +05:30
|
|
|
|
|
|
|
verifyResponseStatusCode('@getSelectedTeam', 200);
|
2023-10-02 18:12:23 +05:30
|
|
|
cy.get('[data-testid="manage-button"]')
|
2022-09-26 19:43:34 +05:30
|
|
|
.should('exist')
|
|
|
|
.should('be.visible')
|
|
|
|
.click();
|
|
|
|
|
|
|
|
cy.get('[data-menu-id*="delete-button"]').should('be.visible');
|
|
|
|
|
|
|
|
cy.get('[data-testid="delete-button-title"]')
|
|
|
|
.should('exist')
|
|
|
|
.should('be.visible')
|
|
|
|
.click();
|
|
|
|
|
|
|
|
cy.get('[data-testid="confirm-button"]')
|
|
|
|
.should('exist')
|
|
|
|
.should('be.disabled');
|
|
|
|
|
2023-01-15 18:24:10 +05:30
|
|
|
// Check if soft delete option is present
|
2022-09-26 19:43:34 +05:30
|
|
|
cy.get('[data-testid="soft-delete-option"]')
|
2022-10-08 00:07:24 +05:30
|
|
|
.should('contain', HARD_DELETE_TEAM_DETAILS.name)
|
2022-09-26 19:43:34 +05:30
|
|
|
.should('be.visible');
|
|
|
|
|
2023-01-15 18:24:10 +05:30
|
|
|
// Click on permanent delete option
|
2022-08-17 19:08:35 +05:30
|
|
|
cy.get('[data-testid="hard-delete-option"]')
|
2022-10-08 00:07:24 +05:30
|
|
|
.should('contain', HARD_DELETE_TEAM_DETAILS.name)
|
2022-08-17 19:08:35 +05:30
|
|
|
.should('be.visible')
|
|
|
|
.click();
|
|
|
|
|
|
|
|
cy.get('[data-testid="confirmation-text-input"]').type('DELETE');
|
2022-09-14 19:19:42 +05:30
|
|
|
|
|
|
|
interceptURL('DELETE', '/api/v1/teams/*', 'deleteTeam');
|
2022-08-17 19:08:35 +05:30
|
|
|
cy.get('[data-testid="confirm-button"]')
|
|
|
|
.should('exist')
|
|
|
|
.should('be.visible')
|
|
|
|
.click();
|
|
|
|
|
2022-09-14 19:19:42 +05:30
|
|
|
verifyResponseStatusCode('@deleteTeam', 200);
|
2022-08-17 19:08:35 +05:30
|
|
|
|
2023-01-15 18:24:10 +05:30
|
|
|
// Verify the toast message
|
2022-08-17 19:08:35 +05:30
|
|
|
toastNotification('Team deleted successfully!');
|
|
|
|
|
2023-01-15 18:24:10 +05:30
|
|
|
// Validating the deleted team
|
2022-08-17 19:08:35 +05:30
|
|
|
|
2022-10-08 00:07:24 +05:30
|
|
|
cy.get('table').should('not.contain', HARD_DELETE_TEAM_DETAILS.name);
|
2022-08-17 19:08:35 +05:30
|
|
|
});
|
|
|
|
});
|