2024-01-08 15:23:39 +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.
|
|
|
|
|
*/
|
2024-01-16 16:38:40 +05:30
|
|
|
|
|
|
|
|
|
import { EntityType } from '../../constants/Entity.interface';
|
2024-01-08 15:23:39 +05:30
|
|
|
|
import { interceptURL, verifyResponseStatusCode } from '../common';
|
|
|
|
|
|
|
|
|
|
export const assignGlossaryTerm = (
|
2024-03-27 00:56:02 +05:30
|
|
|
|
glossaryTermFQN: string,
|
|
|
|
|
glossaryTermName: string,
|
2024-01-08 15:23:39 +05:30
|
|
|
|
endPoint: EntityType
|
|
|
|
|
) => {
|
|
|
|
|
interceptURL('PATCH', `/api/v1/${endPoint}/*`, 'addGlossaryTerm');
|
2024-05-11 19:31:34 +05:30
|
|
|
|
interceptURL(
|
|
|
|
|
'GET',
|
|
|
|
|
`/api/v1/search/query?*index=glossary_term_search_index*`,
|
|
|
|
|
'searchGlossaryTerm'
|
|
|
|
|
);
|
2024-01-08 15:23:39 +05:30
|
|
|
|
cy.get(
|
|
|
|
|
'[data-testid="entity-right-panel"] [data-testid="glossary-container"] [data-testid="add-tag"]'
|
|
|
|
|
).click();
|
|
|
|
|
|
|
|
|
|
cy.get('[data-testid="tag-selector"] input')
|
|
|
|
|
.should('be.visible')
|
2024-03-27 00:56:02 +05:30
|
|
|
|
.type(glossaryTermName);
|
2024-05-11 19:31:34 +05:30
|
|
|
|
verifyResponseStatusCode('@searchGlossaryTerm', 200);
|
2024-01-08 15:23:39 +05:30
|
|
|
|
|
2024-04-26 12:55:40 +05:30
|
|
|
|
cy.get(
|
|
|
|
|
`[data-testid="tag-${glossaryTermFQN}"] .ant-select-tree-checkbox`
|
|
|
|
|
).click();
|
2024-01-08 15:23:39 +05:30
|
|
|
|
|
2024-05-11 19:31:34 +05:30
|
|
|
|
cy.get(`[data-testid="selected-tag-${glossaryTermFQN}"]`).should(
|
|
|
|
|
'be.visible'
|
|
|
|
|
);
|
2024-01-08 15:23:39 +05:30
|
|
|
|
|
2024-05-11 19:31:34 +05:30
|
|
|
|
cy.get('[data-testid="saveAssociatedTag"]').click();
|
2024-01-08 15:23:39 +05:30
|
|
|
|
verifyResponseStatusCode('@addGlossaryTerm', 200);
|
|
|
|
|
cy.get(
|
2024-03-27 00:56:02 +05:30
|
|
|
|
`[data-testid="entity-right-panel"] [data-testid="glossary-container"] [data-testid="tag-${glossaryTermFQN}"]`
|
2024-01-08 15:23:39 +05:30
|
|
|
|
).should('be.visible');
|
|
|
|
|
};
|
|
|
|
|
|
2024-04-26 12:55:40 +05:30
|
|
|
|
export const updateGlossaryTerm = (
|
2024-03-27 00:56:02 +05:30
|
|
|
|
glossaryTermFQN: string,
|
|
|
|
|
glossaryTermName: string,
|
2024-01-08 15:23:39 +05:30
|
|
|
|
endPoint: EntityType
|
|
|
|
|
) => {
|
|
|
|
|
interceptURL('PATCH', `/api/v1/${endPoint}/*`, 'addGlossaryTerm');
|
2024-05-11 19:31:34 +05:30
|
|
|
|
interceptURL(
|
|
|
|
|
'GET',
|
|
|
|
|
`/api/v1/search/query?*index=glossary_term_search_index*`,
|
|
|
|
|
'searchGlossaryTerm'
|
|
|
|
|
);
|
2024-01-08 15:23:39 +05:30
|
|
|
|
cy.get(
|
|
|
|
|
'[data-testid="entity-right-panel"] [data-testid="glossary-container"] [data-testid="edit-button"]'
|
|
|
|
|
).click();
|
|
|
|
|
|
|
|
|
|
cy.get('[data-testid="tag-selector"] input')
|
|
|
|
|
.should('be.visible')
|
2024-03-27 00:56:02 +05:30
|
|
|
|
.type(glossaryTermName);
|
2024-05-11 19:31:34 +05:30
|
|
|
|
verifyResponseStatusCode('@searchGlossaryTerm', 200);
|
2024-01-08 15:23:39 +05:30
|
|
|
|
|
2024-03-27 00:56:02 +05:30
|
|
|
|
cy.get(`[data-testid="tag-${glossaryTermFQN}"]`).click();
|
2024-01-08 15:23:39 +05:30
|
|
|
|
|
2024-05-11 19:31:34 +05:30
|
|
|
|
cy.get(`[data-testid="selected-tag-${glossaryTermFQN}"]`).should(
|
|
|
|
|
'be.visible'
|
|
|
|
|
);
|
|
|
|
|
cy.get('[data-testid="saveAssociatedTag"]').click();
|
2024-01-08 15:23:39 +05:30
|
|
|
|
verifyResponseStatusCode('@addGlossaryTerm', 200);
|
|
|
|
|
cy.get(
|
2024-03-27 00:56:02 +05:30
|
|
|
|
`[data-testid="entity-right-panel"] [data-testid="glossary-container"] [data-testid="tag-${glossaryTermFQN}"]`
|
2024-01-08 15:23:39 +05:30
|
|
|
|
).should('be.visible');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const removeGlossaryTerm = (
|
|
|
|
|
inputGlossaryTerm: string | string[],
|
|
|
|
|
endPoint: EntityType
|
|
|
|
|
) => {
|
|
|
|
|
const glossaryTerms = Array.isArray(inputGlossaryTerm)
|
|
|
|
|
? inputGlossaryTerm
|
|
|
|
|
: [inputGlossaryTerm];
|
|
|
|
|
interceptURL('PATCH', `/api/v1/${endPoint}/*`, 'removeTags');
|
2024-05-11 19:31:34 +05:30
|
|
|
|
interceptURL('GET', `/api/v1/glossaries?*`, 'fetchGlossaries');
|
2024-01-08 15:23:39 +05:30
|
|
|
|
glossaryTerms.forEach((glossaryTerm) => {
|
|
|
|
|
cy.get(
|
|
|
|
|
'[data-testid="entity-right-panel"] [data-testid="glossary-container"] [data-testid="edit-button"]'
|
|
|
|
|
).click();
|
|
|
|
|
|
2024-05-16 18:19:54 +05:30
|
|
|
|
verifyResponseStatusCode('@fetchGlossaries', 200);
|
|
|
|
|
|
2024-01-08 15:23:39 +05:30
|
|
|
|
// Remove all added tags
|
|
|
|
|
cy.get(
|
|
|
|
|
`[data-testid="selected-tag-${glossaryTerm}"] [data-testid="remove-tags"]`
|
|
|
|
|
).click();
|
|
|
|
|
|
2024-05-11 19:31:34 +05:30
|
|
|
|
cy.get('[data-testid="saveAssociatedTag"]').click();
|
|
|
|
|
verifyResponseStatusCode('@removeTags', 200, {
|
|
|
|
|
requestTimeout: 15000,
|
|
|
|
|
});
|
2024-01-08 15:23:39 +05:30
|
|
|
|
});
|
|
|
|
|
cy.get(
|
|
|
|
|
'[data-testid="entity-right-panel"] [data-testid="glossary-container"] [data-testid="add-tag"]'
|
|
|
|
|
).should('be.visible');
|
|
|
|
|
};
|
2024-02-19 19:52:46 +05:30
|
|
|
|
|
|
|
|
|
export const confirmationDragAndDropGlossary = (
|
|
|
|
|
dragElement: string,
|
|
|
|
|
dropElement: string,
|
|
|
|
|
isHeader?: boolean
|
|
|
|
|
) => {
|
|
|
|
|
interceptURL('PATCH', `/api/v1/glossaryTerms/*`, 'patchGlossaryTerm');
|
|
|
|
|
|
|
|
|
|
// confirmation message before the transfer
|
|
|
|
|
cy.get('[data-testid="confirmation-modal"] .ant-modal-body').contains(
|
|
|
|
|
`Click on Confirm if you’d like to move ${
|
|
|
|
|
isHeader
|
|
|
|
|
? `${dragElement} under ${dropElement} .`
|
|
|
|
|
: `${dragElement} term under ${dropElement} term.`
|
|
|
|
|
}`
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// click on submit modal button to confirm the transfer
|
|
|
|
|
cy.get('.ant-modal-footer > .ant-btn-primary').click();
|
|
|
|
|
|
|
|
|
|
verifyResponseStatusCode('@patchGlossaryTerm', 200);
|
|
|
|
|
};
|