Skip to content
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

bump to version 0.5.0 #100

Merged
merged 116 commits into from
Nov 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
1b0f124
Wizard alert tests
saulipurhonen Oct 13, 2020
693e975
Fixed typo
saulipurhonen Oct 13, 2020
bbeba96
Created tests folder and moved tests there. Moved enzyme config to src
saulipurhonen Oct 13, 2020
a9e5fc3
Installed snapshot-diff package for tests
saulipurhonen Oct 14, 2020
aa14cbf
Tests for stepper and footer
saulipurhonen Oct 14, 2020
fd631bd
Fixed home path for save dialog
saulipurhonen Oct 14, 2020
827770b
Basic test
saulipurhonen Oct 14, 2020
a33fcc5
Added more expectations
saulipurhonen Oct 14, 2020
4bbc3bb
Removed debug
saulipurhonen Oct 14, 2020
7646e2a
Rephrased comment
saulipurhonen Oct 15, 2020
b5186a2
Migrated from Enzyme to React testing library
saulipurhonen Oct 15, 2020
9e226b7
Migrated from Enzyme to RTL
saulipurhonen Oct 15, 2020
95eadbb
Enzyme config isn't needed anymore since we're using RTL instead
saulipurhonen Oct 15, 2020
900b7b8
Uninstalled Enzyme
saulipurhonen Oct 15, 2020
aaa464d
Rephrashed test
saulipurhonen Oct 15, 2020
de2a017
Installed @testing-library/user-event
saulipurhonen Oct 15, 2020
c2735dc
Base test for xml upload
saulipurhonen Oct 15, 2020
f58d932
Updated vulnerable packages
saulipurhonen Oct 15, 2020
b346df2
Updated React and outdated packages
saulipurhonen Oct 15, 2020
11b8622
jsdom-sixteen env config with tests
saulipurhonen Oct 16, 2020
afd36d9
Removed snapshot test and snapshot file
saulipurhonen Oct 16, 2020
5068c25
Removed snapshot test and snapshot file
saulipurhonen Oct 16, 2020
e75ac88
Removed snapshot test and snapshot file
saulipurhonen Oct 16, 2020
ac4a92c
Test for dialog
saulipurhonen Oct 16, 2020
d97bc2c
Test that upload for file works
saulipurhonen Oct 16, 2020
2d7024a
Synced with package.json
saulipurhonen Oct 16, 2020
1174a8e
add draftStatusSlice for reducer
lilachic Oct 9, 2020
e3e9f7c
refactor to dispatch xml file not saved from hidden field
lilachic Oct 11, 2020
a6bae02
add check for xml file draft status
lilachic Oct 11, 2020
34e3284
rebase develop branch
lilachic Oct 20, 2020
2ae1f05
fix save dialog and add similar dialog for publish
csc-jm Oct 30, 2020
aa72a81
add publish to submission folder slice
csc-jm Nov 2, 2020
812f568
Added test-id attributes to help with integration tests
saulipurhonen Nov 2, 2020
e5316f6
Object card render tests
saulipurhonen Nov 2, 2020
99bc1d1
Removed log
saulipurhonen Nov 2, 2020
9b7fc11
Container width for small screens
saulipurhonen Nov 2, 2020
90e74a4
Basic test for form rendering from localStorage
saulipurhonen Nov 2, 2020
5d22bee
Installed localstorage mock package for Jest
saulipurhonen Nov 2, 2020
9c00e05
Migrated from Formik to React Hook Form
saulipurhonen Nov 3, 2020
7b42998
Removed response.ok status check for error message. This is handled a…
saulipurhonen Nov 3, 2020
b6d4f29
Removed dispatch logic for error message since it's not needed in rea…
saulipurhonen Nov 3, 2020
a1bc0d0
Changed comment to point from Formik to React Hook Form
saulipurhonen Nov 3, 2020
767a9ee
add save/publish alerts, add publish folder slice, change cancel butt…
csc-jm Nov 3, 2020
60a596c
some code fixes
csc-jm Nov 3, 2020
d8e8a62
remove unneccesary reducer, reuse resetFolder reducer
csc-jm Nov 4, 2020
e4096d9
HTMLFormElement as reference for folder creation
saulipurhonen Nov 4, 2020
5134043
Migrated from Formik to react-hook-form
saulipurhonen Nov 4, 2020
07c5bfc
Trigger folder creation submit with dispatchEvent from ref. Moved inc…
saulipurhonen Nov 4, 2020
c28748f
Updated 'Form components' section to match current use of react-hook-…
saulipurhonen Nov 4, 2020
2975e71
Uninstalled Formik
saulipurhonen Nov 4, 2020
0dbea6a
Changed spelling
saulipurhonen Nov 4, 2020
c530b86
Merge pull request #87 from CSCfi/feature/formik-to-react-hook-form-m…
saulipurhonen Nov 5, 2020
0e9e26b
Enabled folder details update
saulipurhonen Nov 5, 2020
87636dd
Added update folder functionality
saulipurhonen Nov 5, 2020
d8cfaa6
Added folder property to FolderFromForm type
saulipurhonen Nov 5, 2020
b11537e
Merge branch 'develop' into feature/add-save-exit-publish
saulipurhonen Nov 5, 2020
ef51da0
Update src/features/wizardSubmissionFolderSlice.js
saulipurhonen Nov 5, 2020
2494aa0
Merge pull request #86 from CSCfi/feature/add-save-exit-publish
blankdots Nov 5, 2020
885176c
Merge pull request #89 from CSCfi/feature/folder-form-edit
blankdots Nov 5, 2020
abad770
merge fix
lilachic Nov 5, 2020
93ebb7b
update react-scripts packages
blankdots Nov 5, 2020
6470e94
add test for localstorage
blankdots Nov 5, 2020
9a47ad4
more expected tests about local storage
blankdots Nov 5, 2020
8c1ab68
Delete object base
saulipurhonen Nov 6, 2020
85576b7
Moved localstorage getItem test to separate test so it doesn't interf…
saulipurhonen Nov 6, 2020
9f090d1
Global localstorage mock for tests
saulipurhonen Nov 6, 2020
3f5e320
Uninstalled jest-localstorage-mock
saulipurhonen Nov 6, 2020
b7a8dcc
Merge pull request #90 from CSCfi/bugfix/security-object-path
blankdots Nov 6, 2020
cf94211
Added possibility to delete saved objects
saulipurhonen Nov 6, 2020
ae59ad0
List current submission types saved objects. Added possibility to del…
saulipurhonen Nov 6, 2020
8c6be2c
Added success color
saulipurhonen Nov 9, 2020
eb5a18e
Show temporary message on newly added items
saulipurhonen Nov 9, 2020
dc87d5b
Show temporary message on newly added items
saulipurhonen Nov 9, 2020
34e6d54
Add object to state with 'new' property
saulipurhonen Nov 9, 2020
a1b808e
Pass new object with 'new' property
saulipurhonen Nov 9, 2020
f4d92ba
Basic test form list
saulipurhonen Nov 9, 2020
5f15929
Removed object property for new object
saulipurhonen Nov 9, 2020
c144bbe
Modified test to not rely on 'new' property
saulipurhonen Nov 9, 2020
d578367
Toggle 'Added!' text by comparion between current and previous metada…
saulipurhonen Nov 9, 2020
9ed1fde
Removed 'new' property adding
saulipurhonen Nov 9, 2020
456a165
test changes
lilachic Nov 9, 2020
cf850d2
Merge branch 'bugfix/prevent-draft-version-alert-popping-incorrectly'…
saulipurhonen Nov 9, 2020
1146c1f
Check against drafStatus slice
saulipurhonen Nov 9, 2020
53478c3
Testing with useRef
saulipurhonen Nov 9, 2020
1784d67
Commented out conflicting code
saulipurhonen Nov 10, 2020
7c583bf
Merge pull request #92 from CSCfi/feature/saved-objects-info
blankdots Nov 10, 2020
b0ec3b3
Use form component with key, this destroys the component when object …
saulipurhonen Nov 10, 2020
7b484b1
Reset form with working function
saulipurhonen Nov 10, 2020
858f750
Handle form if draftStatus is set, reset draftStatus if user discards…
saulipurhonen Nov 11, 2020
6797911
Added draftStatus slice to store
saulipurhonen Nov 11, 2020
629875d
RNG on XML upload component key
saulipurhonen Nov 11, 2020
5341e6b
Removed log
saulipurhonen Nov 11, 2020
d2d6d7a
Check if upload is dirty and set state
saulipurhonen Nov 11, 2020
712db77
Merge branch 'develop' into bugfix/prevent-draft-version-alert-poppin…
saulipurhonen Nov 11, 2020
b4befaf
Clear timeout in useEffect
saulipurhonen Nov 11, 2020
b844a52
Use combination of current objectType and submissionType as key for c…
saulipurhonen Nov 11, 2020
ed22a8f
Changes to card render. XML upload has changes in state transfer so t…
saulipurhonen Nov 11, 2020
62a7c08
Wrapped tests in async
saulipurhonen Nov 11, 2020
16aceb1
Reset draft status after successful submission
saulipurhonen Nov 11, 2020
feb102b
Added dispatch to useEffect dependencies
saulipurhonen Nov 11, 2020
ced407a
Cleaned unnecessary statements from useEffect
saulipurhonen Nov 11, 2020
2bcbecd
Merge pull request #95 from CSCfi/bugfix/prevent-draft-version-alert-…
blankdots Nov 11, 2020
a113a66
Return action API responses as promise. Helps with catching and displ…
saulipurhonen Nov 13, 2020
7ec5069
Removed router navigation logic. This should be done in corresponding…
saulipurhonen Nov 13, 2020
eaa4caa
Removed log
saulipurhonen Nov 13, 2020
f04a571
Use folder and object actions based on promise from redux, show conne…
saulipurhonen Nov 13, 2020
0d62ce9
Removed unused line of code
saulipurhonen Nov 13, 2020
2c79f86
add handleButton to trigger click for form upload file
lilachic Nov 13, 2020
93721d8
Merge pull request #97 from CSCfi/feature/folder-backend-check
blankdots Nov 17, 2020
5afe20c
Testing
lilachic Nov 20, 2020
2b31b48
handlebutton upload
blankdots Nov 20, 2020
c9f3a66
Merge branch 'bugfix/keyboard-based-xml-upload' of github.com:CSCfi/m…
lilachic Nov 20, 2020
1820e5d
remove working comments
lilachic Nov 20, 2020
155eb68
Merge pull request #99 from CSCfi/bugfix/keyboard-based-xml-upload
blankdots Nov 23, 2020
f96d125
bump version to 0.5.0
blankdots Nov 23, 2020
6ba7f5f
npm update packages 23rd Nov 2020
blankdots Nov 23, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ React Router is used to render different views in App-component. All components

Form components are crucial part of the application:

- Forms for XML upload and folder creation are made with `Formik` and customized fields for material-UI.
- All submissions and folder creation are made with `react-hook-form`. Latter uses form as a reference so submission can be triggered outside the form.
- Form for json schema based forms are created with custom json schema parser, which builds `react-hook-form` based forms from given json schema. Json schema-based forms are validated against json schema with `Ajv`. React-hook-form is used for performance reasons: it uses uncontrolled components so adding a lot of fields to array doesn't slow rendering of the application.

## Redux store
Expand Down
6 changes: 0 additions & 6 deletions enzyme.js

This file was deleted.

21,953 changes: 12,773 additions & 9,180 deletions package-lock.json

Large diffs are not rendered by default.

46 changes: 23 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
{
"name": "metadata-submitter-frontend",
"version": "0.4.0",
"version": "0.5.0",
"private": true,
"dependencies": {
"@apidevtools/json-schema-ref-parser": "^9.0.6",
"@material-ui/core": "^4.11.0",
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "^4.0.0-alpha.56",
"@reduxjs/toolkit": "^1.4.0",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"ajv": "^6.12.3",
"@testing-library/jest-dom": "^5.11.5",
"@testing-library/react": "^11.1.1",
"ajv": "^6.12.6",
"apisauce": "^1.1.2",
"formik": "^2.1.5",
"lodash": "^4.17.19",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-hook-form": "^6.3.1",
"react-redux": "^7.2.1",
"jest-environment-jsdom-sixteen": "^1.0.3",
"lodash": "^4.17.20",
"react": "^16.14.0",
"react-dom": "^16.14.0",
"react-hook-form": "^6.10.1",
"react-redux": "^7.2.2",
"react-router-dom": "^5.2.0",
"react-scripts": "^3.4.3"
"react-scripts": "^4.0.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"test:noninteractive": "react-scripts test --watchAll=false",
"test": "react-scripts test --env=jest-environment-jsdom-sixteen",
"test:noninteractive": "react-scripts test --watchAll=false --env=jest-environment-jsdom-sixteen",
"lint": "eslint --fix .",
"lint:check": "eslint .",
"format": "prettier --write \"**/*.+(json|yml|yaml|css|md)\"",
Expand Down Expand Up @@ -55,19 +54,20 @@
]
},
"devDependencies": {
"@testing-library/user-event": "^12.2.0",
"concurrently": "^5.3.0",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.5",
"eslint-config-prettier": "^6.11.0",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-flowtype": "^5.2.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jest": "^23.20.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^24.1.3",
"eslint-plugin-prettier": "^3.1.4",
"flow-bin": "^0.126.1",
"http-proxy-middleware": "^1.0.5",
"husky": "^4.2.5",
"prettier": "^2.0.5",
"redux-mock-store": "^1.5.4"
"http-proxy-middleware": "^1.0.6",
"husky": "^4.3.0",
"jest-environment-jsdom-sixteen": "^1.0.3",
"prettier": "^2.2.0",
"redux-mock-store": "^1.5.4",
"snapshot-diff": "^0.8.1"
},
"husky": {
"hooks": {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Nav.test.js → src/__tests__/Nav.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "@testing-library/jest-dom/extend-expect"
import { render } from "@testing-library/react"
import { MemoryRouter } from "react-router-dom"

import Nav from "./Nav"
import Nav from "../components/Nav"

describe("NavBar", () => {
let component
Expand Down
59 changes: 59 additions & 0 deletions src/__tests__/WizardAddObjectStep.test.js
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()
})
})
})
})
36 changes: 36 additions & 0 deletions src/__tests__/WizardAlert.test.js
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()
})
})
})
})
69 changes: 69 additions & 0 deletions src/__tests__/WizardFillObjectDetailsForm.test.js
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)
})
})
})
37 changes: 37 additions & 0 deletions src/__tests__/WizardFooter.test.js
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()
})
})
33 changes: 33 additions & 0 deletions src/__tests__/WizardSavedObjectsList.test.js
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()
})
})
})
44 changes: 44 additions & 0 deletions src/__tests__/WizardShowSummaryStep.test.js
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
})
})
Loading