forked from OpenStackweb/summit-admin
-
Notifications
You must be signed in to change notification settings - Fork 4
feature: migrate media upload types grid to MUI #1005
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
3111a01
chore: migrate to MUI - WIP
santipalenque 681bdca
chore: fix tests and change to file size input
santipalenque efe8c9f
chore: update uicore
santipalenque c374d40
fix: pr review
santipalenque ce8ee9d
chore: rebase master
santipalenque 05b6578
chore: fix tests
santipalenque acaaa15
chore: fix pr review
santipalenque c1a551b
chore: update uicore
santipalenque 4924f20
chore: rollback edit in dialog
santipalenque 51d23a2
chore: pr review and html rendering
santipalenque 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,74 @@ | ||
| /** | ||
| * @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 { getMediaUpload } from "../media-upload-actions"; | ||
| import * as methods from "../../utils/methods"; | ||
|
|
||
| jest.mock("openstack-uicore-foundation/lib/utils/actions", () => ({ | ||
| __esModule: true, | ||
| ...jest.requireActual("openstack-uicore-foundation/lib/utils/actions"), | ||
| getRequest: jest.fn() | ||
| })); | ||
|
|
||
| const requestMock = | ||
| (requestActionCreator, receiveActionCreator) => () => (dispatch) => { | ||
| if (typeof receiveActionCreator === "function") { | ||
| dispatch(receiveActionCreator({ response: { id: 7, name: "Slides" } })); | ||
| } | ||
| return Promise.resolve({ response: { id: 7, name: "Slides" } }); | ||
| }; | ||
|
|
||
| describe("getMediaUpload", () => { | ||
| const middlewares = [thunk]; | ||
| const mockStore = configureStore(middlewares); | ||
|
|
||
| beforeEach(() => { | ||
| jest.spyOn(methods, "getAccessTokenSafely").mockResolvedValue("TOKEN"); | ||
| getRequest.mockImplementation(requestMock); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| jest.restoreAllMocks(); | ||
| }); | ||
|
|
||
| // Regression test for a bug where the fetch omitted `relations`, so the API | ||
| // response never included presentation_types. The reducer then defaulted it | ||
| // to [], the form rendered no chips, and saving wiped every real | ||
| // association even though nothing about them was touched. See | ||
| // SummitMediaUploadTypeSerializer::serialize (only emits presentation_types | ||
| // when the relation is requested) and | ||
| // SummitMediaUploadTypeService::update() (isset() on an empty array is | ||
| // still true, so clearPresentationTypes() runs and nothing is re-added). | ||
| it("requests the presentation_types relation so an existing entity's associations survive a fetch", async () => { | ||
| let capturedParams; | ||
| getRequest.mockImplementation((req, res) => (params) => (dispatch) => { | ||
| capturedParams = params; | ||
| return requestMock(req, res)(params)(dispatch); | ||
| }); | ||
|
|
||
| const store = mockStore({ | ||
| currentSummitState: { currentSummit: { id: 42 } } | ||
| }); | ||
|
|
||
| await store.dispatch(getMediaUpload(7)); | ||
| await flushPromises(); | ||
|
|
||
| expect(capturedParams).toMatchObject({ relations: "presentation_types" }); | ||
| }); | ||
|
|
||
| it("dispatches RECEIVE_MEDIA_UPLOAD with the fetched entity", async () => { | ||
| const store = mockStore({ | ||
| currentSummitState: { currentSummit: { id: 42 } } | ||
| }); | ||
|
|
||
| store.dispatch(getMediaUpload(7)); | ||
| await flushPromises(); | ||
|
|
||
| const actionTypes = store.getActions().map((a) => a.type); | ||
| expect(actionTypes).toContain("RECEIVE_MEDIA_UPLOAD"); | ||
| }); | ||
| }); |
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
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.