forked from OpenStackweb/summit-admin
-
Notifications
You must be signed in to change notification settings - Fork 4
fix: restore selection plan edit route and page, remove popup #1069
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tomrndom
wants to merge
12
commits into
master
Choose a base branch
from
fix/edit-selection-plan-page
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c5e2557
fix: restore selection plan edit route and page, remove popup, update…
tomrndom 9dddaf5
fix: add missing catch on save selection plan
tomrndom 475df1f
fix: keep form in sync with layout, add tests
tomrndom 1ebd0de
fix: adjust breadcrumb, fix issue on new selection plans
tomrndom 26c1409
fix: add missing catch, update test
tomrndom c3ea40d
fix: add unit tests, clean layout component, adjust redirect
tomrndom 8a34514
fix: connect reducer with form, add sequenced to actions, adjust and …
tomrndom 8e570a2
fix: redirect to list after save
tomrndom e710b14
fix: add sequenced dispatch on mkt settings, fix redirect, seq select…
tomrndom c78c899
fix: update test cases with redirect to list after save
tomrndom 28a1d3b
fix: change showConfirmDialog import route
tomrndom a9b2021
fix: update mock on test file
tomrndom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| /** | ||
| * @jest-environment jsdom | ||
| */ | ||
| import configureStore from "redux-mock-store"; | ||
| import thunk from "redux-thunk"; | ||
| import flushPromises from "flush-promises"; | ||
| import { getRequest } from "openstack-uicore-foundation/lib/utils/actions"; | ||
| import { getMarketingSettingsBySelectionPlan } from "../marketing-actions"; | ||
|
|
||
| jest.mock("openstack-uicore-foundation/lib/utils/actions", () => ({ | ||
| __esModule: true, | ||
| ...jest.requireActual("openstack-uicore-foundation/lib/utils/actions"), | ||
| getRequest: jest.fn() | ||
| })); | ||
|
|
||
| const storeState = { | ||
| currentSummitState: { currentSummit: { id: 1 } } | ||
| }; | ||
|
|
||
| describe("getMarketingSettingsBySelectionPlan - stale response guard", () => { | ||
| const middlewares = [thunk]; | ||
| const mockStore = configureStore(middlewares); | ||
|
|
||
| afterEach(() => { | ||
| jest.restoreAllMocks(); | ||
| }); | ||
|
|
||
| it("drops an older plan's settings response after a newer plan's response already landed", async () => { | ||
| const resolvers = {}; | ||
| getRequest.mockImplementation( | ||
| (requestActionCreator, receiveActionCreator) => | ||
| (params) => | ||
| (dispatch) => { | ||
| const { selection_plan_id: id } = params; | ||
| return new Promise((resolve) => { | ||
| resolvers[id] = () => { | ||
| if (requestActionCreator) dispatch(requestActionCreator({})); | ||
| dispatch(receiveActionCreator({ response: { id } })); | ||
| resolve(); | ||
| }; | ||
| }); | ||
| } | ||
| ); | ||
|
|
||
| const store = mockStore(storeState); | ||
|
|
||
| // User opens plan 5, then quickly navigates to plan 8 before plan 5's | ||
| // settings fetch settles - both requests are genuinely in flight when | ||
| // plan 8's response lands first. | ||
| store.dispatch(getMarketingSettingsBySelectionPlan("5")); | ||
| await flushPromises(); | ||
| store.dispatch(getMarketingSettingsBySelectionPlan("8")); | ||
| await flushPromises(); | ||
| resolvers[8](); | ||
| await flushPromises(); | ||
| resolvers[5](); | ||
| await flushPromises(); | ||
|
|
||
| const receivedIds = store | ||
| .getActions() | ||
| .filter((a) => a.type === "RECEIVE_SELECTION_PLAN_SETTINGS") | ||
| .map((a) => a.payload.response.id); | ||
|
|
||
| expect(receivedIds).toEqual(["8"]); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import React from "react"; | ||
| import { withRouter } from "react-router-dom"; | ||
| import Button from "@mui/material/Button"; | ||
| import AddIcon from "@mui/icons-material/Add"; | ||
| import T from "i18n-react"; | ||
|
|
||
| function AddNewButtonMui({ entity, history }) { | ||
| if (!entity?.id) return null; | ||
|
|
||
| const handleClick = () => { | ||
| history.push("new"); | ||
| }; | ||
|
|
||
| return ( | ||
| <Button | ||
| variant="contained" | ||
| onClick={handleClick} | ||
| startIcon={<AddIcon />} | ||
| sx={{ float: "right" }} | ||
| > | ||
| {T.translate("general.add_new")} | ||
| </Button> | ||
| ); | ||
| } | ||
|
|
||
| export default withRouter(AddNewButtonMui); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.