2022-09-27 18:49:24 +05:30
|
|
|
/*
|
2022-12-27 12:37:58 +05:30
|
|
|
* Copyright 2022 Collate.
|
2022-09-27 18:49:24 +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-21 12:59:20 +05:30
|
|
|
// eslint-disable-next-line spaced-comment
|
|
|
|
|
/// <reference types="cypress" />
|
2023-01-15 18:24:10 +05:30
|
|
|
import {
|
|
|
|
|
addTeam,
|
|
|
|
|
interceptURL,
|
|
|
|
|
uuid,
|
|
|
|
|
verifyResponseStatusCode,
|
|
|
|
|
visitEntityDetailsPage,
|
|
|
|
|
} from '../../common/common';
|
2022-11-21 17:02:48 +05:30
|
|
|
import { SEARCH_ENTITY_TABLE } from '../../constants/constants';
|
2022-09-27 18:49:24 +05:30
|
|
|
|
|
|
|
|
const teamName = `team-group-test-${uuid()}`;
|
|
|
|
|
const TEAM_DETAILS = {
|
|
|
|
|
name: teamName,
|
|
|
|
|
teamType: 'Group',
|
|
|
|
|
description: `This is ${teamName} description`,
|
2023-05-11 21:46:29 +05:30
|
|
|
email: 'team@gmail.com',
|
2022-09-29 02:49:03 +05:30
|
|
|
...SEARCH_ENTITY_TABLE.table_1,
|
2022-09-27 18:49:24 +05:30
|
|
|
};
|
|
|
|
|
|
2023-10-14 16:45:28 +05:30
|
|
|
describe.skip('Create a team and add that team as a owner of the entity', () => {
|
2022-09-29 02:49:03 +05:30
|
|
|
beforeEach(() => {
|
2022-11-21 17:02:48 +05:30
|
|
|
cy.login();
|
2023-04-10 20:46:20 +05:30
|
|
|
interceptURL(
|
|
|
|
|
'GET',
|
2023-09-21 21:22:05 +05:30
|
|
|
`/api/v1/search/query?q=*${teamName}***teamType:Group&from=0&size=25&index=team_search_index`,
|
2023-04-10 20:46:20 +05:30
|
|
|
'waitForTeams'
|
|
|
|
|
);
|
|
|
|
|
interceptURL('PATCH', `/api/v1/tables/*`, 'updateTable');
|
2022-09-29 02:49:03 +05:30
|
|
|
});
|
|
|
|
|
|
2022-09-27 18:49:24 +05:30
|
|
|
/**
|
|
|
|
|
* Here we are adding team of type group as
|
|
|
|
|
* Only team of type group can own the entities
|
|
|
|
|
*/
|
2022-09-29 02:49:03 +05:30
|
|
|
it('Add a group team type and assign it as a owner of the entity', () => {
|
2023-07-31 18:27:08 +05:30
|
|
|
interceptURL('GET', '/api/v1/teams/name/*', 'getTeams');
|
2022-09-29 02:49:03 +05:30
|
|
|
|
2023-08-29 13:01:06 +05:30
|
|
|
cy.get('[data-testid="app-bar-item-settings"]')
|
|
|
|
|
.should('be.visible')
|
|
|
|
|
.click();
|
2023-04-05 00:06:11 +05:30
|
|
|
|
2023-01-15 18:24:10 +05:30
|
|
|
// Clicking on teams
|
|
|
|
|
cy.get('[data-testid="settings-left-panel"]')
|
|
|
|
|
.contains('Teams')
|
2022-09-27 18:49:24 +05:30
|
|
|
.should('exist')
|
|
|
|
|
.should('be.visible')
|
|
|
|
|
.click();
|
|
|
|
|
|
|
|
|
|
verifyResponseStatusCode('@getTeams', 200);
|
|
|
|
|
|
|
|
|
|
addTeam(TEAM_DETAILS);
|
2022-09-29 02:49:03 +05:30
|
|
|
|
2022-09-27 18:49:24 +05:30
|
|
|
cy.reload();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Check for added team details
|
|
|
|
|
*/
|
|
|
|
|
cy.get('table').find('.ant-table-row').should('contain', TEAM_DETAILS.name);
|
|
|
|
|
cy.get('table')
|
|
|
|
|
.find('.ant-table-row')
|
|
|
|
|
.should('contain', TEAM_DETAILS.description);
|
2023-04-10 20:46:20 +05:30
|
|
|
});
|
2022-09-27 18:49:24 +05:30
|
|
|
|
2023-04-10 20:46:20 +05:30
|
|
|
it('Add newly created group type team as owner, and remove it', () => {
|
2022-09-29 02:49:03 +05:30
|
|
|
visitEntityDetailsPage(
|
|
|
|
|
TEAM_DETAILS.term,
|
|
|
|
|
TEAM_DETAILS.serviceName,
|
|
|
|
|
TEAM_DETAILS.entity
|
|
|
|
|
);
|
2022-09-27 18:49:24 +05:30
|
|
|
|
2023-03-28 14:39:41 +05:30
|
|
|
cy.get('[data-testid="edit-owner"]').should('be.visible').click();
|
2023-07-31 11:23:31 +05:30
|
|
|
cy.get('[data-testid="owner-select-teams-search-bar"]')
|
2022-09-29 02:49:03 +05:30
|
|
|
.should('be.visible')
|
2022-12-06 15:19:52 +05:30
|
|
|
.type(TEAM_DETAILS.name);
|
2022-09-29 02:49:03 +05:30
|
|
|
|
2023-04-05 00:06:11 +05:30
|
|
|
verifyResponseStatusCode('@waitForTeams', 200);
|
|
|
|
|
|
2023-01-15 18:24:10 +05:30
|
|
|
// Selecting the team
|
2022-12-06 15:19:52 +05:30
|
|
|
cy.get(`[title="${TEAM_DETAILS.name}"]`)
|
2022-09-27 18:49:24 +05:30
|
|
|
.should('exist')
|
|
|
|
|
.should('be.visible')
|
|
|
|
|
.click();
|
|
|
|
|
|
2023-04-10 20:46:20 +05:30
|
|
|
verifyResponseStatusCode('@updateTable', 200);
|
2022-09-27 18:49:24 +05:30
|
|
|
|
|
|
|
|
cy.get('[data-testid="owner-link"]')
|
|
|
|
|
.scrollIntoView()
|
|
|
|
|
.invoke('text')
|
|
|
|
|
.then((text) => {
|
2022-12-06 15:19:52 +05:30
|
|
|
expect(text).equal(TEAM_DETAILS.name);
|
2022-09-27 18:49:24 +05:30
|
|
|
});
|
2022-09-29 02:49:03 +05:30
|
|
|
});
|
2023-04-10 20:46:20 +05:30
|
|
|
|
|
|
|
|
it('Remove newly created group type team as owner', () => {
|
|
|
|
|
visitEntityDetailsPage(
|
|
|
|
|
TEAM_DETAILS.term,
|
|
|
|
|
TEAM_DETAILS.serviceName,
|
|
|
|
|
TEAM_DETAILS.entity
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
cy.get('[data-testid="edit-owner"]').should('be.visible').click();
|
2023-07-31 11:23:31 +05:30
|
|
|
cy.get('[data-testid="owner-select-teams-search-bar"]')
|
2023-04-10 20:46:20 +05:30
|
|
|
.should('be.visible')
|
|
|
|
|
.type(TEAM_DETAILS.name);
|
|
|
|
|
|
|
|
|
|
verifyResponseStatusCode('@waitForTeams', 200);
|
|
|
|
|
|
|
|
|
|
cy.get('[data-testid="remove-owner"]').should('be.visible').click();
|
|
|
|
|
verifyResponseStatusCode('@updateTable', 200);
|
2023-07-24 10:16:08 +05:30
|
|
|
cy.get('[data-testid="owner-link"]').should(
|
|
|
|
|
'not.contain',
|
|
|
|
|
TEAM_DETAILS.name
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('Delete newly created team', () => {
|
|
|
|
|
const token = localStorage.getItem('oidcIdToken');
|
|
|
|
|
|
|
|
|
|
cy.request({
|
|
|
|
|
method: 'GET',
|
|
|
|
|
url: `/api/v1/teams/name/${teamName}`,
|
|
|
|
|
headers: { Authorization: `Bearer ${token}` },
|
|
|
|
|
}).then((response) => {
|
|
|
|
|
cy.request({
|
|
|
|
|
method: 'GET',
|
|
|
|
|
url: `/api/v1/teams/${response.body.id}?hardDelete=true&recursive=true`,
|
|
|
|
|
headers: { Authorization: `Bearer ${token}` },
|
|
|
|
|
}).then((response) => {
|
|
|
|
|
expect(response.status).to.eq(200);
|
|
|
|
|
});
|
|
|
|
|
});
|
2023-04-10 20:46:20 +05:30
|
|
|
});
|
2022-09-29 02:49:03 +05:30
|
|
|
});
|