-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MDS-6011] Fix buttons in modal footers, only show allowed type in re…
…place modal (#3220) * add space around buttons in modal footers * fix an actions/consistency issue, clean up document table, clean up & test doc modals, only show the actual allowed type in replace doc modal * move test * fix spelling, remove imports from proptypes, fix duplicate key in datamocks * fix a nesting issue for spatial doc modal test, add in missing test id * test if the only CSS change is breaking the build * see if adding a default geomark URL helps Index.js pass, and if adding an equivalent rule on MS helps the build error * update styles * attempt to target the correct actions button
- Loading branch information
Showing
24 changed files
with
933 additions
and
439 deletions.
There are no files selected for viewing
This file contains 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
19 changes: 19 additions & 0 deletions
19
services/common/src/components/documents/ArchiveDocumentModal.spec.tsx
This file contains 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,19 @@ | ||
import React from "react"; | ||
import { render } from "@testing-library/react"; | ||
import { ReduxWrapper } from "@mds/common/tests/utils/ReduxWrapper"; | ||
import { MINEDOCUMENTS } from "@mds/common/tests/mocks/dataMocks"; | ||
import ArchiveDocumentModal from "./ArchiveDocumentModal"; | ||
|
||
describe("ArchiveDocumentModal", () => { | ||
it("renders correctly and matches the snapshot", () => { | ||
const { container } = render( | ||
<ReduxWrapper> | ||
<ArchiveDocumentModal | ||
documents={MINEDOCUMENTS.records} | ||
handleSubmit={jest.fn().mockReturnValue(Promise.resolve())} | ||
/> | ||
</ReduxWrapper> | ||
); | ||
expect(container.firstChild).toMatchSnapshot(); | ||
}); | ||
}); |
This file contains 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
20 changes: 20 additions & 0 deletions
20
services/common/src/components/documents/DeleteDocumentModal.spec.tsx
This file contains 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,20 @@ | ||
import React from "react"; | ||
import { render } from "@testing-library/react"; | ||
import { ReduxWrapper } from "@mds/common/tests/utils/ReduxWrapper"; | ||
import { MINEDOCUMENTS } from "@mds/common/tests/mocks/dataMocks"; | ||
import DeleteDocumentModal from "./DeleteDocumentModal"; | ||
import { MineDocument } from "@mds/common/models/documents/document"; | ||
|
||
describe("DeleteDocumentModal", () => { | ||
it("renders correctly and matches the snapshot", () => { | ||
const { container } = render( | ||
<ReduxWrapper> | ||
<DeleteDocumentModal | ||
documents={MINEDOCUMENTS.records.map((d) => new MineDocument(d))} | ||
handleSubmit={jest.fn().mockReturnValue(Promise.resolve())} | ||
/> | ||
</ReduxWrapper> | ||
); | ||
expect(container.firstChild).toMatchSnapshot(); | ||
}); | ||
}); |
This file contains 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
26 changes: 22 additions & 4 deletions
26
services/common/src/components/documents/DocumentTable.spec.tsx
This file contains 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 |
---|---|---|
@@ -1,19 +1,37 @@ | ||
import React from "react"; | ||
import { render } from "@testing-library/react"; | ||
import { render, fireEvent } from "@testing-library/react"; | ||
import * as MOCK from "@mds/common/tests/mocks/dataMocks"; | ||
import DocumentTable from "./DocumentTable"; | ||
import { MineDocument } from "@mds/common/models/documents/document"; | ||
import { ReduxWrapper } from "@mds/common/tests/utils/ReduxWrapper"; | ||
import * as modalActions from "@mds/common/redux/actions/modalActions"; | ||
|
||
const documents = MOCK.PROJECT_SUMMARY.documents.map((d) => new MineDocument(d)); | ||
|
||
describe("DocumentTable", () => { | ||
it("renders properly", () => { | ||
const { container } = render( | ||
const removeFunc = jest.fn(); | ||
const onArchiveFunc = jest.fn(); | ||
const onReplaceFunc = jest.fn(); | ||
|
||
const openModalSpy = jest.spyOn(modalActions, "openModal"); | ||
it("renders properly", async () => { | ||
const { container, getAllByText, findByTestId } = render( | ||
<ReduxWrapper> | ||
<DocumentTable documents={documents} /> | ||
<DocumentTable | ||
documents={documents} | ||
showVersionHistory | ||
canArchiveDocuments | ||
removeDocument={removeFunc} | ||
onArchivedDocuments={onArchiveFunc} | ||
onReplaceDocument={onReplaceFunc} | ||
/> | ||
</ReduxWrapper> | ||
); | ||
expect(container).toMatchSnapshot(); | ||
const actionsButton = getAllByText("Actions")[0]; | ||
fireEvent.mouseEnter(actionsButton); | ||
const archiveAction = await findByTestId("action-button-archive"); | ||
fireEvent.click(archiveAction); | ||
expect(openModalSpy).toHaveBeenCalledTimes(1); | ||
}); | ||
}); |
This file contains 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 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.