2023-05-19 10:37:40 +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.
|
|
|
|
*/
|
|
|
|
import { interceptURL, verifyResponseStatusCode } from './common';
|
|
|
|
|
2023-10-25 18:03:13 +05:30
|
|
|
export const searchServiceFromSettingPage = (service) => {
|
|
|
|
interceptURL(
|
|
|
|
'GET',
|
|
|
|
'api/v1/search/query?q=*&from=0&size=15&index=*',
|
|
|
|
'searchService'
|
|
|
|
);
|
|
|
|
cy.get('[data-testid="searchbar"]').type(service);
|
|
|
|
|
|
|
|
verifyResponseStatusCode('@searchService', 200);
|
|
|
|
};
|
|
|
|
|
2023-05-19 10:37:40 +05:30
|
|
|
export const visitServiceDetailsPage = (service, verifyHeader = true) => {
|
|
|
|
// Click on settings page
|
|
|
|
interceptURL(
|
|
|
|
'GET',
|
|
|
|
'api/v1/teams/name/Organization?fields=*',
|
|
|
|
'getSettingsPage'
|
|
|
|
);
|
2023-08-29 13:01:06 +05:30
|
|
|
cy.get('[data-testid="app-bar-item-settings"]').should('be.visible').click();
|
2023-07-28 14:54:38 +05:30
|
|
|
|
2023-05-19 10:37:40 +05:30
|
|
|
verifyResponseStatusCode('@getSettingsPage', 200);
|
|
|
|
// Services page
|
|
|
|
interceptURL('GET', '/api/v1/services/*', 'getServices');
|
|
|
|
|
|
|
|
cy.get('.ant-menu-title-content')
|
|
|
|
.contains(service.type)
|
|
|
|
.should('be.visible')
|
|
|
|
.click();
|
|
|
|
|
2023-10-20 10:07:51 +05:30
|
|
|
cy.wait('@getServices');
|
|
|
|
|
2023-10-25 18:03:13 +05:30
|
|
|
searchServiceFromSettingPage(service.name);
|
2023-05-19 10:37:40 +05:30
|
|
|
|
|
|
|
// click on created service
|
|
|
|
cy.get(`[data-testid="service-name-${service.name}"]`)
|
|
|
|
.should('exist')
|
|
|
|
.should('be.visible')
|
|
|
|
.click();
|
|
|
|
|
|
|
|
if (verifyHeader) {
|
2023-05-19 23:29:54 +05:30
|
|
|
cy.get(`[data-testid="entity-header-display-name"]`)
|
2023-05-19 10:37:40 +05:30
|
|
|
.should('exist')
|
|
|
|
.should('be.visible')
|
|
|
|
.invoke('text')
|
|
|
|
.then((text) => {
|
2023-07-28 14:54:38 +05:30
|
|
|
expect(text).to.equal(service.displayName);
|
2023-05-19 10:37:40 +05:30
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
verifyResponseStatusCode('@getServices', 200);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const createDataWithApi = (data, token) => {
|
|
|
|
data.map(({ method, url, body }) => {
|
|
|
|
cy.request({
|
|
|
|
method,
|
|
|
|
url,
|
|
|
|
auth: {
|
|
|
|
bearer: token,
|
|
|
|
},
|
|
|
|
body,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|