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:
parent
15a00f4982
commit
17ded71de3
|
|
@ -2,8 +2,12 @@ const pages = require("../../../locators/Pages.json");
|
||||||
|
|
||||||
describe("Pages", function() {
|
describe("Pages", function() {
|
||||||
let veryLongPageName = `abcdefghijklmnopqrstuvwxyz1234`;
|
let veryLongPageName = `abcdefghijklmnopqrstuvwxyz1234`;
|
||||||
|
let apiName = "someApi";
|
||||||
|
|
||||||
it("Clone page", function() {
|
it("Clone page", function() {
|
||||||
|
cy.NavigateToAPI_Panel();
|
||||||
|
cy.CreateAPI(apiName);
|
||||||
|
|
||||||
cy.xpath(pages.popover)
|
cy.xpath(pages.popover)
|
||||||
.last()
|
.last()
|
||||||
.click({ force: true });
|
.click({ force: true });
|
||||||
|
|
@ -15,7 +19,12 @@ describe("Pages", function() {
|
||||||
201,
|
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", () => {
|
it("Creates a page with long name and checks if it shows tooltip on hover", () => {
|
||||||
|
|
|
||||||
|
|
@ -55,17 +55,32 @@ const actionsReducer = createReducer(initialState, {
|
||||||
action: ReduxAction<RestAction[]>,
|
action: ReduxAction<RestAction[]>,
|
||||||
): ActionDataState => {
|
): ActionDataState => {
|
||||||
if (action.payload.length > 0) {
|
if (action.payload.length > 0) {
|
||||||
const payloadActionMap = _.keyBy(action.payload, "id");
|
const stateActionMap = _.keyBy(state, "config.id");
|
||||||
return state.map((stateAction: ActionData) => {
|
const result: ActionDataState = [];
|
||||||
if (stateAction.config.pageId === action.payload[0].pageId) {
|
|
||||||
return {
|
action.payload.forEach((actionPayload: RestAction) => {
|
||||||
|
const stateAction = stateActionMap[actionPayload.id];
|
||||||
|
if (stateAction) {
|
||||||
|
result.push({
|
||||||
data: stateAction.data,
|
data: stateAction.data,
|
||||||
isLoading: false,
|
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;
|
return state;
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -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));
|
history.push(BUILDER_PAGE_URL(applicationId, response.data.id));
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user