fix actions/queries not fetched after cloning a page (#2196)

* fix actions/queries not fetched after cloning a page

* cf fix

* update type

* update test to check if api is cloned

* trigger tests
This commit is contained in:
Rishabh Saxena 2020-12-16 14:51:31 +05:30 committed by GitHub
parent 15a00f4982
commit 17ded71de3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 8 deletions

View File

@ -2,8 +2,12 @@ const pages = require("../../../locators/Pages.json");
describe("Pages", function() {
let veryLongPageName = `abcdefghijklmnopqrstuvwxyz1234`;
let apiName = "someApi";
it("Clone page", function() {
cy.NavigateToAPI_Panel();
cy.CreateAPI(apiName);
cy.xpath(pages.popover)
.last()
.click({ force: true });
@ -15,7 +19,12 @@ describe("Pages", function() {
201,
);
cy.get(".t--entity-name:contains(Page1 Copy)");
// to check if apis are cloned
cy.get(".t--entity-name:contains(Page1)").click({ multiple: true });
cy.get(".t--entity-name:contains(APIs)")
.last()
.click();
cy.get(`.t--entity-name:contains(${apiName})`).should("have.length", 2);
});
it("Creates a page with long name and checks if it shows tooltip on hover", () => {

View File

@ -55,17 +55,32 @@ const actionsReducer = createReducer(initialState, {
action: ReduxAction<RestAction[]>,
): ActionDataState => {
if (action.payload.length > 0) {
const payloadActionMap = _.keyBy(action.payload, "id");
return state.map((stateAction: ActionData) => {
if (stateAction.config.pageId === action.payload[0].pageId) {
return {
const stateActionMap = _.keyBy(state, "config.id");
const result: ActionDataState = [];
action.payload.forEach((actionPayload: RestAction) => {
const stateAction = stateActionMap[actionPayload.id];
if (stateAction) {
result.push({
data: stateAction.data,
isLoading: false,
config: payloadActionMap[stateAction.config.id],
};
config: actionPayload,
});
delete stateActionMap[actionPayload.id];
} else {
result.push({
isLoading: false,
config: actionPayload,
});
}
return stateAction;
});
Object.keys(stateActionMap).forEach(stateActionKey => {
result.push(stateActionMap[stateActionKey]);
});
return result;
}
return state;
},

View File

@ -511,6 +511,8 @@ export function* clonePageSaga(clonePageAction: ReduxAction<ClonePageRequest>) {
},
});
yield put(fetchActionsForPage(response.data.id));
history.push(BUILDER_PAGE_URL(applicationId, response.data.id));
}
} catch (error) {