-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from CSCfi/develop
bump to version 0.5.0
- Loading branch information
Showing
34 changed files
with
13,746 additions
and
9,513 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,59 @@ | ||
import React from "react" | ||
|
||
import "@testing-library/jest-dom/extend-expect" | ||
import { render, screen, act } from "@testing-library/react" | ||
import { Provider } from "react-redux" | ||
import configureStore from "redux-mock-store" | ||
import { toMatchDiffSnapshot } from "snapshot-diff" | ||
|
||
import WizardAddObjectStep from "../components/NewDraftWizard/WizardSteps/WizardAddObjectStep" | ||
|
||
const mockStore = configureStore([]) | ||
|
||
expect.extend({ toMatchDiffSnapshot }) | ||
|
||
describe("WizardAddObjectStep", () => { | ||
it("should not render any cards if no selected object type", () => { | ||
const store = mockStore({ | ||
objectType: "", | ||
submissionType: "xml", | ||
submissionFolder: { | ||
name: "folder name", | ||
description: "folder description", | ||
published: false, | ||
metadataObjects: [], | ||
id: "FOL12341234", | ||
}, | ||
}) | ||
render( | ||
<Provider store={store}> | ||
<WizardAddObjectStep /> | ||
</Provider> | ||
) | ||
expect(screen.getByText("Add objects by clicking the name, then fill form or upload XML File.")).toBeInTheDocument() | ||
}) | ||
|
||
it("should render appropriate card", async () => { | ||
const typeList = ["form", "xml", "existing"] | ||
await act(async () => { | ||
typeList.forEach(typeName => { | ||
const store = mockStore({ | ||
objectType: "study", | ||
submissionType: typeName, | ||
submissionFolder: { | ||
description: "Test", | ||
id: "FOL12341234", | ||
name: "Testname", | ||
published: false, | ||
}, | ||
}) | ||
render( | ||
<Provider store={store}> | ||
<WizardAddObjectStep /> | ||
</Provider> | ||
) | ||
expect(screen.getByTestId(typeName)).toBeInTheDocument() | ||
}) | ||
}) | ||
}) | ||
}) |
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,36 @@ | ||
import React from "react" | ||
|
||
import { render, screen } from "@testing-library/react" | ||
import { Provider } from "react-redux" | ||
import { BrowserRouter } from "react-router-dom" | ||
import configureStore from "redux-mock-store" | ||
|
||
import WizardAlert from "../components/NewDraftWizard/WizardComponents/WizardAlert" | ||
|
||
const mockStore = configureStore([]) | ||
|
||
describe("WizardAlert", () => { | ||
const store = mockStore({ | ||
submissionType: "", | ||
}) | ||
|
||
it("should render appropriate dialogs", () => { | ||
const alerts = [ | ||
{ submission: { types: ["form", "xml", "existing"] } }, | ||
{ footer: { types: ["cancel", "save"] } }, | ||
{ stepper: { types: ["form", "xml", "existing"] } }, | ||
] | ||
alerts.forEach(item => { | ||
item[Object.keys(item)].types.forEach(type => { | ||
render( | ||
<BrowserRouter> | ||
<Provider store={store}> | ||
<WizardAlert alertType={type} parentLocation={Object.keys(item)[0]} onAlert="true" /> | ||
</Provider> | ||
</BrowserRouter> | ||
) | ||
expect(screen.getByRole("dialog")).toBeDefined() | ||
}) | ||
}) | ||
}) | ||
}) |
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,69 @@ | ||
import React from "react" | ||
|
||
import "@testing-library/jest-dom/extend-expect" | ||
import { render, screen, waitFor } from "@testing-library/react" | ||
import { Provider } from "react-redux" | ||
import configureStore from "redux-mock-store" | ||
|
||
import WizardFillObjectDetailsForm from "../components/NewDraftWizard/WizardForms/WizardFillObjectDetailsForm" | ||
|
||
const mockStore = configureStore([]) | ||
|
||
describe("WizardFillObjectDetailsForm", () => { | ||
const schema = { | ||
title: "Study", | ||
type: "object", | ||
required: ["descriptor"], | ||
properties: { | ||
descriptor: { | ||
type: "object", | ||
title: "Study Description", | ||
required: ["studyTitle"], | ||
properties: { | ||
studyTitle: { | ||
title: "Study Title", | ||
description: "Title of the study as would be used in a publication.", | ||
type: "string", | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
const store = mockStore({ | ||
objectType: "study", | ||
submissionType: "form", | ||
submissionFolder: { | ||
description: "AWD", | ||
id: "FOL90524783", | ||
name: "Testname", | ||
published: false, | ||
}, | ||
}) | ||
|
||
localStorage.setItem(`cached_study_schema`, JSON.stringify(schema)) | ||
|
||
it("should create study form from schema in localstorage", async () => { | ||
render( | ||
<Provider store={store}> | ||
<WizardFillObjectDetailsForm /> | ||
</Provider> | ||
) | ||
await waitFor(() => screen.getByText("Study Description")) | ||
expect(screen.getByText("Study Description")).toBeDefined() | ||
}) | ||
|
||
// Note: If this test runs before form creation, form creation fails because getItem spy messes localstorage init somehow | ||
it("should call localstorage", async () => { | ||
const spy = jest.spyOn(Storage.prototype, "getItem") | ||
render( | ||
<Provider store={store}> | ||
<WizardFillObjectDetailsForm /> | ||
</Provider> | ||
) | ||
expect(spy).toBeCalledWith("cached_study_schema") | ||
await waitFor(() => { | ||
expect(spy.mock.calls.length).toBe(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React from "react" | ||
|
||
import "@testing-library/jest-dom/extend-expect" | ||
import { render, screen, fireEvent } from "@testing-library/react" | ||
import { Provider } from "react-redux" | ||
import { BrowserRouter } from "react-router-dom" | ||
import configureStore from "redux-mock-store" | ||
|
||
import WizardFooter from "../components/NewDraftWizard/WizardComponents/WizardFooter" | ||
|
||
const mockStore = configureStore([]) | ||
|
||
describe("WizardStepper", () => { | ||
let store | ||
let wrapper | ||
|
||
beforeEach(() => { | ||
store = mockStore({ | ||
submissionType: "form", | ||
wizardStep: 1, | ||
}) | ||
wrapper = ( | ||
<BrowserRouter> | ||
<Provider store={store}> | ||
<WizardFooter /> | ||
</Provider> | ||
</BrowserRouter> | ||
) | ||
}) | ||
|
||
it("should open dialog on click of cancel", () => { | ||
render(wrapper) | ||
const button = screen.getByRole("button", { name: /Cancel/i }) | ||
fireEvent.click(button) | ||
expect(screen.getByRole("dialog")).toBeDefined() | ||
}) | ||
}) |
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,33 @@ | ||
import React from "react" | ||
|
||
import "@testing-library/jest-dom/extend-expect" | ||
import { render, screen } from "@testing-library/react" | ||
import { Provider } from "react-redux" | ||
import configureStore from "redux-mock-store" | ||
|
||
import WizardSavedObjectsList from "../components/NewDraftWizard/WizardComponents/WizardSavedObjectsList" | ||
|
||
const mockStore = configureStore([]) | ||
|
||
describe("WizardStepper", () => { | ||
const store = mockStore({ | ||
submissionType: "sample", | ||
wizardStep: 1, | ||
}) | ||
|
||
const submissions = [ | ||
{ accessionId: "EDAG1", schema: "sample" }, | ||
{ accessionId: "EDAG2", schema: "sample" }, | ||
] | ||
|
||
it("should have 'Added!' message rendered on item that has 'new' property", () => { | ||
render( | ||
<Provider store={store}> | ||
<WizardSavedObjectsList submissions={submissions} submissionType="sample" /> | ||
</Provider> | ||
) | ||
submissions.forEach(item => { | ||
expect(screen.getByText(item.accessionId)).toBeInTheDocument() | ||
}) | ||
}) | ||
}) |
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,44 @@ | ||
import React from "react" | ||
|
||
import "@testing-library/jest-dom/extend-expect" | ||
import { render, screen } from "@testing-library/react" | ||
import { Provider } from "react-redux" | ||
import configureStore from "redux-mock-store" | ||
import { toMatchDiffSnapshot } from "snapshot-diff" | ||
|
||
import WizardShowSummaryStep from "../components/NewDraftWizard/WizardSteps/WizardShowSummaryStep" | ||
|
||
const mockStore = configureStore([]) | ||
|
||
expect.extend({ toMatchDiffSnapshot }) | ||
|
||
describe("WizardShowSummaryStep", () => { | ||
let store | ||
let wrapper | ||
|
||
beforeEach(() => { | ||
store = mockStore({ | ||
submissionFolder: { | ||
description: "AWD", | ||
id: "FOL90524783", | ||
metadataObjects: [ | ||
{ accessionId: "EDAG2584421211413887", schema: "study" }, | ||
{ accessionId: "EDAG9880663174234413", schema: "study" }, | ||
], | ||
name: "AA", | ||
published: false, | ||
}, | ||
}) | ||
wrapper = ( | ||
<Provider store={store}> | ||
<WizardShowSummaryStep /> | ||
</Provider> | ||
) | ||
}) | ||
|
||
it("should have uploaded objects listed", async () => { | ||
render(wrapper) | ||
const items = await screen.findAllByRole("button") | ||
expect(items).toHaveLength(4) // Screen renders stepper back and next buttons | ||
}) | ||
}) |
Oops, something went wrong.