2023-07-24 14:11:09 +05:30
|
|
|
/*
|
|
|
|
* Copyright 2023 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.
|
|
|
|
*/
|
|
|
|
// eslint-disable-next-line spaced-comment
|
|
|
|
/// <reference types="cypress" />
|
|
|
|
|
|
|
|
import {
|
|
|
|
interceptURL,
|
|
|
|
toastNotification,
|
|
|
|
verifyResponseStatusCode,
|
|
|
|
visitEntityDetailsPage,
|
|
|
|
} from '../../common/common';
|
2023-11-01 10:36:41 +05:30
|
|
|
import { createEntityTable, hardDeleteService } from '../../common/entityUtils';
|
2023-07-26 15:20:01 +05:30
|
|
|
import {
|
|
|
|
createAndUpdateDescriptionTask,
|
|
|
|
editAssignee,
|
|
|
|
verifyTaskDetails,
|
|
|
|
} from '../../common/TaskUtils';
|
2023-11-01 10:36:41 +05:30
|
|
|
import { MYDATA_SUMMARY_OPTIONS } from '../../constants/constants';
|
|
|
|
import { DATABASE_SERVICE } from '../../constants/entityConstant';
|
|
|
|
import { SERVICE_CATEGORIES } from '../../constants/service.constants';
|
|
|
|
|
|
|
|
const ENTITY_TABLE = {
|
2023-11-02 10:39:10 +05:30
|
|
|
term: DATABASE_SERVICE.tables.name,
|
|
|
|
displayName: DATABASE_SERVICE.tables.name,
|
2023-11-01 10:36:41 +05:30
|
|
|
entity: MYDATA_SUMMARY_OPTIONS.tables,
|
|
|
|
serviceName: DATABASE_SERVICE.service.name,
|
|
|
|
schemaName: DATABASE_SERVICE.schema.name,
|
|
|
|
entityType: 'Table',
|
|
|
|
};
|
2023-07-24 14:11:09 +05:30
|
|
|
|
|
|
|
describe('Task flow should work', () => {
|
2023-11-01 10:36:41 +05:30
|
|
|
before(() => {
|
|
|
|
cy.login();
|
|
|
|
cy.getAllLocalStorage().then((data) => {
|
|
|
|
const token = Object.values(data)[0].oidcIdToken;
|
|
|
|
|
|
|
|
createEntityTable({
|
|
|
|
token,
|
|
|
|
...DATABASE_SERVICE,
|
|
|
|
tables: [DATABASE_SERVICE.tables],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
after(() => {
|
|
|
|
cy.login();
|
|
|
|
cy.getAllLocalStorage().then((data) => {
|
|
|
|
const token = Object.values(data)[0].oidcIdToken;
|
|
|
|
|
|
|
|
hardDeleteService({
|
|
|
|
token,
|
|
|
|
serviceFqn: ENTITY_TABLE.serviceName,
|
|
|
|
serviceType: SERVICE_CATEGORIES.DATABASE_SERVICES,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2023-07-24 14:11:09 +05:30
|
|
|
beforeEach(() => {
|
|
|
|
cy.login();
|
|
|
|
interceptURL('GET', '/api/v1/permissions/*/name/*', 'entityPermission');
|
|
|
|
interceptURL('GET', '/api/v1/feed/count?entityLink=*', 'entityFeed');
|
|
|
|
interceptURL('GET', '/api/v1/search/suggest?q=*', 'suggestApi');
|
|
|
|
interceptURL('PUT', '/api/v1/feed/tasks/*/resolve', 'taskResolve');
|
|
|
|
interceptURL(
|
|
|
|
'GET',
|
2023-09-20 23:17:54 +05:30
|
|
|
`/api/v1/search/query?q=*%20AND%20disabled:false&index=tag_search_index*`,
|
2023-07-24 14:11:09 +05:30
|
|
|
'suggestTag'
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2023-07-28 16:46:34 +05:30
|
|
|
const assignee = 'adam_rodriguez9';
|
2023-07-24 14:11:09 +05:30
|
|
|
const tag = 'Personal';
|
|
|
|
|
|
|
|
const createTagTask = (value) => {
|
|
|
|
interceptURL('POST', 'api/v1/feed', 'createTask');
|
|
|
|
|
|
|
|
cy.get('#title').should(
|
|
|
|
'have.value',
|
2023-07-28 16:46:34 +05:30
|
|
|
value.tagCount > 0
|
|
|
|
? `Update tags for table ${value.term}`
|
|
|
|
: `Request tags for table ${value.term}`
|
2023-07-24 14:11:09 +05:30
|
|
|
);
|
|
|
|
|
|
|
|
cy.get('[data-testid="select-assignee"] > .ant-select-selector').type(
|
|
|
|
assignee
|
|
|
|
);
|
|
|
|
// select value from dropdown
|
|
|
|
verifyResponseStatusCode('@suggestApi', 200);
|
|
|
|
|
|
|
|
cy.get(`[data-testid="assignee-option-${assignee}"]`)
|
|
|
|
.trigger('mouseover')
|
|
|
|
.trigger('click');
|
|
|
|
|
|
|
|
cy.clickOutside();
|
2023-07-28 16:46:34 +05:30
|
|
|
if (value.tagCount > 0) {
|
|
|
|
cy.get('[data-testid="tag-selector"]')
|
|
|
|
.find('[data-testid="remove-tags"]')
|
|
|
|
.each(($btn) => {
|
|
|
|
cy.wrap($btn).click();
|
|
|
|
});
|
|
|
|
}
|
2023-07-24 14:11:09 +05:30
|
|
|
cy.get('[data-testid="tag-selector"]').click().type(tag);
|
|
|
|
|
|
|
|
verifyResponseStatusCode('@suggestTag', 200);
|
|
|
|
cy.get('[data-testid="tag-PersonalData.Personal"]').click();
|
|
|
|
|
|
|
|
cy.get('[data-testid="tags-label"]').click();
|
|
|
|
|
|
|
|
cy.get('button[type="submit"]').click();
|
|
|
|
verifyResponseStatusCode('@createTask', 201);
|
|
|
|
toastNotification('Task created successfully.');
|
|
|
|
|
|
|
|
// verify the task details
|
2023-07-28 16:46:34 +05:30
|
|
|
verifyTaskDetails(
|
|
|
|
value.tagCount > 0
|
|
|
|
? /#(\d+) UpdateTagfortags/
|
|
|
|
: /#(\d+) RequestTagfortags/
|
|
|
|
);
|
2023-07-24 14:11:09 +05:30
|
|
|
|
|
|
|
// edit task assignees
|
|
|
|
editAssignee();
|
|
|
|
|
|
|
|
// Accept the description suggestion which is created
|
|
|
|
cy.get('.ant-btn-compact-first-item').contains('Accept Suggestion').click();
|
|
|
|
|
|
|
|
verifyResponseStatusCode('@taskResolve', 200);
|
|
|
|
|
|
|
|
toastNotification('Task resolved successfully');
|
|
|
|
|
|
|
|
verifyResponseStatusCode('@entityFeed', 200);
|
|
|
|
};
|
|
|
|
|
|
|
|
it('Task flow for table description', () => {
|
2023-11-01 10:36:41 +05:30
|
|
|
interceptURL(
|
|
|
|
'GET',
|
|
|
|
`/api/v1/${ENTITY_TABLE.entity}/name/*`,
|
|
|
|
'getEntityDetails'
|
|
|
|
);
|
2023-07-24 14:11:09 +05:30
|
|
|
|
2023-11-02 10:39:10 +05:30
|
|
|
visitEntityDetailsPage({
|
|
|
|
term: ENTITY_TABLE.term,
|
|
|
|
serviceName: ENTITY_TABLE.serviceName,
|
|
|
|
entity: ENTITY_TABLE.entity,
|
|
|
|
});
|
2023-07-24 14:11:09 +05:30
|
|
|
|
|
|
|
cy.get('[data-testid="request-description"]').click();
|
|
|
|
|
2023-07-28 16:46:34 +05:30
|
|
|
cy.wait('@getEntityDetails').then((res) => {
|
|
|
|
const entity = res.response.body;
|
|
|
|
|
|
|
|
// create description task
|
2023-07-24 14:11:09 +05:30
|
|
|
|
2023-07-28 16:46:34 +05:30
|
|
|
createAndUpdateDescriptionTask({
|
2023-11-01 10:36:41 +05:30
|
|
|
...ENTITY_TABLE,
|
2023-07-28 16:46:34 +05:30
|
|
|
term: entity.displayName ?? entity.name,
|
|
|
|
});
|
|
|
|
});
|
2023-07-24 14:11:09 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('Task flow for table tags', () => {
|
2023-11-01 10:36:41 +05:30
|
|
|
interceptURL(
|
|
|
|
'GET',
|
|
|
|
`/api/v1/${ENTITY_TABLE.entity}/name/*`,
|
|
|
|
'getEntityDetails'
|
|
|
|
);
|
2023-07-24 14:11:09 +05:30
|
|
|
|
2023-11-02 10:39:10 +05:30
|
|
|
visitEntityDetailsPage({
|
|
|
|
term: ENTITY_TABLE.term,
|
|
|
|
serviceName: ENTITY_TABLE.serviceName,
|
|
|
|
entity: ENTITY_TABLE.entity,
|
|
|
|
});
|
2023-07-24 14:11:09 +05:30
|
|
|
|
|
|
|
cy.get('[data-testid="request-entity-tags"]').click();
|
|
|
|
|
2023-07-28 16:46:34 +05:30
|
|
|
cy.wait('@getEntityDetails').then((res) => {
|
|
|
|
const entity = res.response.body;
|
|
|
|
|
|
|
|
// create tag task
|
|
|
|
createTagTask({
|
2023-11-01 10:36:41 +05:30
|
|
|
...ENTITY_TABLE,
|
2023-07-28 16:46:34 +05:30
|
|
|
term: entity.displayName ?? entity.name,
|
|
|
|
tagCount: entity.tags.length ?? 0,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2023-07-24 14:11:09 +05:30
|
|
|
});
|