fix: table does not show data issue fixed (#17459)

This commit is contained in:
sneha122 2022-10-19 11:30:04 +05:30 committed by GitHub
parent 3a96547815
commit 2139382928
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 4 deletions

View File

@ -0,0 +1,30 @@
const testdata = require("../../../../fixtures/testdata.json");
import { ObjectsRegistry } from "../../../../support/Objects/Registry";
import apiEditor from "../../../../locators/ApiEditor";
const testUrl1 = "http://localhost:5001/v1/dynamicrecords/getstudents";
const agHelper = ObjectsRegistry.AggregateHelper,
apiPage = ObjectsRegistry.ApiPage;
describe("Bug 14666: Api Response Test Functionality ", function() {
it("Test table loading when data is in array format", function() {
cy.log("Login Successful");
cy.NavigateToAPI_Panel();
cy.log("Navigation to API Panel screen successful");
apiPage.CreateAndFillApi(testUrl1, "TableTestAPI");
agHelper.AssertAutoSave();
apiPage.RunAPI();
cy.get(apiEditor.tableResponseTab).should('exist');
cy.DeleteAPI();
});
it("Test table loading when data is not in array format", function() {
cy.log("Login Successful");
cy.NavigateToAPI_Panel();
cy.log("Navigation to API Panel screen successful");
apiPage.CreateAndFillApi(testdata.baseUrl + testdata.methods, "TableTestAPI");
agHelper.AssertAutoSave();
apiPage.RunAPI();
cy.get(apiEditor.tableResponseTab).should('not.exist');
cy.DeleteAPI();
});
});

View File

@ -369,9 +369,21 @@ function ApiResponseView(props: Props) {
});
};
let filteredResponseDataTypes: { key: string; title: string }[] = [
...responseDataTypes,
];
if (!!response.body && !isArray(response.body)) {
filteredResponseDataTypes = responseDataTypes.filter(
(item) => item.key !== API_RESPONSE_TYPE_OPTIONS.TABLE,
);
if (responseDisplayFormat.title === API_RESPONSE_TYPE_OPTIONS.TABLE) {
onResponseTabSelect(filteredResponseDataTypes[0]?.title);
}
}
const selectedTabIndex =
responseDataTypes &&
responseDataTypes.findIndex(
filteredResponseDataTypes &&
filteredResponseDataTypes.findIndex(
(dataType) => dataType.title === responseDisplayFormat?.title,
);
@ -386,8 +398,8 @@ function ApiResponseView(props: Props) {
}, []);
const responseTabs =
responseDataTypes &&
responseDataTypes.map((dataType, index) => {
filteredResponseDataTypes &&
filteredResponseDataTypes.map((dataType, index) => {
return {
index: index,
key: dataType.key,