Commit 80942423 authored by Yannis Barlas's avatar Yannis Barlas

chore(*): backup

parent 9d2d402e
......@@ -151,7 +151,7 @@ const SubmissionForm = props => {
)}
{(dataTypeSelectionState || !isValid) && (
<Button primary type="submit">
<Button data-test-id="submit-button" primary type="submit">
Submit
</Button>
)}
......
......@@ -128,6 +128,7 @@ class AutoComplete extends React.Component {
render() {
const {
className,
'data-test-id': dataTestId,
getSuggestionValue,
onChange,
onSuggestionSelected,
......@@ -142,6 +143,7 @@ class AutoComplete extends React.Component {
const otherProps = omit(this.props, [
'className',
'data',
'data-test-id',
'onChange',
'onBlur',
'value',
......@@ -157,7 +159,7 @@ class AutoComplete extends React.Component {
}
return (
<Wrapper className={className}>
<Wrapper className={className} data-test-id={dataTestId}>
<Autosuggest
getSuggestionValue={getSuggestionValue}
inputProps={inputProps}
......
......@@ -92,6 +92,7 @@ const Checkbox = props => {
checkBoxText,
checked,
className,
'data-test-id': dataTestId,
description,
errors,
label,
......@@ -105,7 +106,7 @@ const Checkbox = props => {
const error = typeof value !== 'undefined' && errors && errors[name]
return (
<Wrapper>
<Wrapper data-test-id={dataTestId}>
{label && <Label>{`${label}${required && ' *'}`}</Label>}
{description && <Description>{description}</Description>}
......@@ -114,6 +115,7 @@ const Checkbox = props => {
<Check
checked={checked}
className={className}
data-test-id={`${dataTestId}-checkbox`}
disabled={readOnly}
label={checkBoxText}
name={name}
......
......@@ -66,6 +66,8 @@ class DropArea extends React.Component {
const file = fileList[0]
const { name, setFieldValue } = this.props
console.log('FDSKLJFLSDFLJKss', fileList)
// console.log(file)
// console.log('event', e)
this.setState({
......@@ -90,6 +92,7 @@ class DropArea extends React.Component {
{!readOnly && (
<StyledDropzone
accept="image/*"
data-test-id={this.props['data-test-id']}
// onClick={this.handleClick}
onDrop={this.handleDrop}
style={{}}
......
......@@ -68,6 +68,7 @@ const InitialSubmission = props => {
<TextFieldGroup
authors
data={getWBPerson}
data-test-id="coauthors"
handleChange={handleChange}
label="Co-Authors"
name="coAuthors"
......@@ -76,6 +77,7 @@ const InitialSubmission = props => {
/>
<AutoComplete
data-test-id="laboratory"
error={get(errors, 'laboratory.name')}
fetchData={getWBLaboratory}
label="Laboratory"
......@@ -96,6 +98,7 @@ const InitialSubmission = props => {
/>
<TextField
data-test-id="funding"
error={get(errors, 'funding')}
label="Funding"
name="funding"
......@@ -107,6 +110,7 @@ const InitialSubmission = props => {
<TextEditor
bold
data-test-id="title"
error={get(errors, 'title')}
italic
key={`title-${props.readOnly}`}
......@@ -120,10 +124,17 @@ const InitialSubmission = props => {
{...props}
/>
<Image label="Image" name="image" required {...props} />
<Image
data-test-id="image"
label="Image"
name="image"
required
{...props}
/>
<TextEditor
bold
data-test-id="image-caption"
error={get(props.errors, 'imageCaption')}
italic
key={`image-caption-${props.readOnly}`}
......@@ -139,6 +150,7 @@ const InitialSubmission = props => {
<TextEditor
bold
data-test-id="pattern-description"
error={get(props.errors, 'patternDescription')}
italic
key={`pattern-description-${props.readOnly}`}
......@@ -154,6 +166,7 @@ const InitialSubmission = props => {
<TextEditor
bold
data-test-id="methods"
error={get(props.errors, 'methods')}
italic
key={`methods-${props.readOnly}`}
......@@ -169,6 +182,7 @@ const InitialSubmission = props => {
<TextEditor
bold
data-test-id="references"
error={get(props.errors, 'references')}
italic
key={`references-${props.readOnly}`}
......@@ -183,6 +197,7 @@ const InitialSubmission = props => {
/>
<TextField
data-test-id="acknowledgements"
error={get(errors, 'acknowledgements')}
label="Acknowledgements"
name="acknowledgements"
......@@ -191,6 +206,7 @@ const InitialSubmission = props => {
/>
<AutoComplete
data-test-id="suggested-reviewer"
error={get(errors, 'suggestedReviewer.name')}
fetchData={getWBPerson}
label="Suggested Reviewer"
......@@ -212,6 +228,7 @@ const InitialSubmission = props => {
<Checkbox
checkBoxText="I agree"
checked={get(values, 'disclaimer')}
data-test-id="disclaimer"
description={disclaimerDescription}
label="Disclaimer"
name="disclaimer"
......@@ -222,6 +239,7 @@ const InitialSubmission = props => {
/>
<TextEditor
data-test-id="comments"
error={get(props.errors, 'comments')}
key={`comments-${props.readOnly}`}
label="Comments to the editor"
......
......@@ -142,8 +142,10 @@ const TextFieldGroup = props => {
err = error
}
const passProps = omit(props, ['data-test-id'])
return (
<GroupWrapper>
<GroupWrapper data-test-id={props['data-test-id']}>
{label && (
<Label>
{label} {required ? ' *' : ''}{' '}
......@@ -160,7 +162,7 @@ const TextFieldGroup = props => {
return (
<LineWrapper key={itemName}>
<Field
{...props}
{...passProps}
authors={authors}
error={Array.isArray(error) && error[i] && error[i].name}
handleChange={handleChange}
......@@ -182,11 +184,15 @@ const TextFieldGroup = props => {
handleChange={handleChange}
name={authors ? `${name}[0]` : `${name}[0].name`}
value={authors ? data[0] : data[0].name}
{...props}
{...passProps}
/>
)}
{!readOnly && (
<StyledButton onClick={handleAdd} primary>
<StyledButton
data-test-id="text-field-group-add-button"
onClick={handleAdd}
primary
>
Add another
</StyledButton>
)}
......
......@@ -16,7 +16,8 @@ const isTeamMember = async (user, roles, object, context) => {
const team = teams.find(
aTeam =>
!aTeam.global &&
object.id === aTeam.object.objectId &&
// object.id === aTeam.object.objectId &&
object.id === aTeam.objectId &&
rolesArray.includes(aTeam.role),
)
......@@ -24,7 +25,7 @@ const isTeamMember = async (user, roles, object, context) => {
}
const isGlobalTeamMember = async (user, roles, context) => {
console.log(user)
// console.log(user)
const teams = await Promise.all(
user.teams.map(teamId => context.models.Team.find(getId(teamId))),
)
......@@ -91,7 +92,9 @@ const permissions = {
},
create: (userId, operation, object, context) => true,
read: async (userId, operation, object, context) => {
const user = await context.models.User.find(userId)
const user = await context.models.User.find(userId, {
eager: 'teams.members.[user, alias]',
})
// Everyone can list the manuscripts
if (object === 'Manuscript') {
......@@ -255,7 +258,8 @@ const permissions = {
if (!isEqual(affectedIds, [userId])) return false
const reviewerInvited = await isInvitedReviewer(
user,
{ id: current.object.objectId }, // pass article as object, not team
// { id: current.object.objectId }, // pass article as object, not team
{ id: current.objectId }, // pass article as object, not team
context,
)
const reviewerAllow = ['reviewersAccepted', 'reviewersRejected']
......
......@@ -21,9 +21,12 @@ describe('Author creates new submission', () => {
})
it('should make initial submission', () => {
// cy.wait(3000)
cy.getById('new-submission-button').click()
cy.getById('authorinput-author.name')
// cy.wait(7000)
cy.get('[data-test-id="authorinput-author.name"] input')
.type('John Brown')
.get('[data-test-id="authorinput-author"] .react-select__control')
.click()
......@@ -40,6 +43,82 @@ describe('Author creates new submission', () => {
.getById('author-email')
.type('johnbrown@example.com')
cy.getById('authorinput-coAuthors[0].name').type('Han')
cy.get('[data-test-id="authorinput-coAuthors[0].name"] input')
.type('Han')
.get(
'[data-test-id="authorinput-coAuthors[0]"] .react-autosuggest__suggestion--first',
)
.click()
.get('[data-test-id="authorinput-coAuthors[0]"] .react-select__control')
.click()
.get(
'[data-test-id="authorinput-coAuthors[0]"] .react-select__option:nth-child(3)',
)
.click()
.getById('authorinput-coAuthors[0].affiliations')
.type('University of Michigan')
cy.get(
'[data-test-id="coauthors"] [data-test-id="text-field-group-add-button"]',
).click()
cy.get('[data-test-id="authorinput-coAuthors[1].name"] input')
.type('Jack Black')
.get('[data-test-id="authorinput-coAuthors[1]"] .react-select__control')
.click()
.get(
'[data-test-id="authorinput-coAuthors[1]"] .react-select__option:nth-child(4)',
)
.click()
.getById('authorinput-coAuthors[1].affiliations')
.type('University of Wisconsin')
cy.get('[data-test-id="laboratory"] input')
.type('lab')
.get('[data-test-id="laboratory"] .react-autosuggest__suggestion--first')
.click()
cy.getById('funding').type('The McMoney Foundation')
cy.get('[data-test-id="title"] .ProseMirror').type('This is a great title')
cy.fixture('files/submission_image.png', 'base64').then(content => {
cy.get('[data-test-id=image]').upload(content, 'image.png')
})
cy.get('[data-test-id="image-caption"] .ProseMirror').type(
'A picture is a thousand words',
)
cy.get('[data-test-id="pattern-description"] .ProseMirror').type(
'Lorem ipsum dolor sit amet.',
)
cy.get('[data-test-id="methods"] .ProseMirror').type(
'Consectetur adipiscing elit.',
)
cy.get('[data-test-id="references"] .ProseMirror').type(
'Nunc aliquam mi massa, non egestas sem bibendum sit amet.',
)
cy.get('[data-test-id="disclaimer"] span').click()
cy.getById('acknowledgements').type('I acknowledge everything')
cy.get('[data-test-id="suggested-reviewer"] input').type('Jackie Brown')
cy.get('[data-test-id="comments"] .ProseMirror').type(
'Quisque bibendum, lectus et facilisis luctus.',
)
// cy.getById('submit-button').click()
cy.contains('button', 'Submit').click()
cy.get('.ReactModal__Content').should('be.visible')
cy.contains('button', 'yes').click()
cy.contains('successful submission').should('exist')
cy.contains('button', 'OK').click()
})
})
......@@ -57,3 +57,26 @@ Cypress.Commands.add('login', role => {
})
Cypress.Commands.add('getById', id => cy.get(`[data-test-id="${id}"]`))
// Custom comand to handle uploading a file using react-dropzone
// Adapted from https://gist.github.com/ZwaarContrast/00101934954980bcaa4ae70ac9930c60
Cypress.Commands.add(
'upload',
{ prevSubject: 'element' },
(subject, file, fileName) => {
// we need to access window in order to create a file below
cy.window().then(window => {
const contentType = 'image/png'
Cypress.Blob.base64StringToBlob(file, contentType).then(blob => {
const testFile = new window.File([blob], fileName, {
type: contentType,
})
cy.wrap(subject).trigger('drop', {
dataTransfer: { files: [testFile], types: ['Files'] },
})
})
})
},
)
......@@ -1242,14 +1242,14 @@
objection "^1.5.3"
uuid "^3.3.2"
"@pubsweet/base-model@^3.3.2":
version "3.3.2"
resolved "https://registry.yarnpkg.com/@pubsweet/base-model/-/base-model-3.3.2.tgz#c11c3fd0896f74300b0e1c424852db868abc58f3"
integrity sha512-tAGal16/MaKHVePCgj9wQig6gkF6HXS5e7MSGLnLenDxTJngKopX5aFx8HBtKGddk57xOq8vvfM9XxYVFFUggQ==
"@pubsweet/base-model@^3.3.4":
version "3.3.4"
resolved "https://registry.yarnpkg.com/@pubsweet/base-model/-/base-model-3.3.4.tgz#1b1fecf544a5446bb558d0fc0e56b9e6755e0a71"
integrity sha512-HG0axWRD8OP0W97e9zAX5m0GxgLJXHBq9k6WXYLkNd3H8twAgbrKsrLRIkVK8gPrlMJ7V0TVImPV2ql2apzB9g==
dependencies:
"@pubsweet/db-manager" "^3.0.12"
"@pubsweet/errors" "^2.0.16"
"@pubsweet/logger" "^0.2.26"
"@pubsweet/db-manager" "^3.0.14"
"@pubsweet/errors" "^2.0.18"
"@pubsweet/logger" "^0.2.28"
http-status-codes "^1.3.0"
knex "^0.16.3"
lodash "^4.17.11"
......@@ -1313,12 +1313,12 @@
tmp-promise "^1.0.5"
umzug "^2.1.0"
"@pubsweet/db-manager@^3.0.12":
version "3.0.12"
resolved "https://registry.yarnpkg.com/@pubsweet/db-manager/-/db-manager-3.0.12.tgz#b3082ab1d7aa2fc86cb473a595cb16ba2b4ebc55"
integrity sha512-drrKScmBfnt55z0o0nvmqhUu/Lmu4dUELTIrro3XPFQgtbISG9tbKTVXChlgHa0o/SxxPhdPQq1x/YloyywpYw==
"@pubsweet/db-manager@^3.0.14":
version "3.0.14"
resolved "https://registry.yarnpkg.com/@pubsweet/db-manager/-/db-manager-3.0.14.tgz#43f5bdf6092cba0ba7d66bd79a2362a7e55dd26a"
integrity sha512-38VvFY1H/y0ActjILOnY3UwWcI3abYSyyg9rhZv0p/Xv6Itik3ses8nhXkSIiqtEiZMrT/Z/Ydac20CSoO5bHg==
dependencies:
"@pubsweet/logger" "^0.2.26"
"@pubsweet/logger" "^0.2.28"
fs-extra "^4.0.2"
isomorphic-fetch "^2.2.1"
joi "^14.3.0"
......@@ -1336,10 +1336,10 @@
dependencies:
http-status-codes "^1.3.0"
"@pubsweet/errors@^2.0.16":
version "2.0.16"
resolved "https://registry.yarnpkg.com/@pubsweet/errors/-/errors-2.0.16.tgz#e43ee9dde0eb35ceba1ae8f63026c747c633cc2b"
integrity sha512-RaqBBjAF40qQtfUDsKpIlHQotUBHIOXyevpcofiRiTxi7sIoOpUJJEbug68mjEs/w1kERx1BF8GhTgNaEKLh3w==
"@pubsweet/errors@^2.0.18":
version "2.0.18"
resolved "https://registry.yarnpkg.com/@pubsweet/errors/-/errors-2.0.18.tgz#20400f64494cd5440cc91ba00fea2d60c4bf2264"
integrity sha512-nejferu/fte9+kD9RCHfH5+apAsMHGAUHEpQP9LxWhrVdTP2MnzInbb6oh2e3kAMvB5e/O6NuodzWPPiGq4T/g==
dependencies:
http-status-codes "^1.3.0"
......@@ -1352,10 +1352,10 @@
joi "^14.3.0"
lodash "^4.17.4"
"@pubsweet/logger@^0.2.26":
version "0.2.26"
resolved "https://registry.yarnpkg.com/@pubsweet/logger/-/logger-0.2.26.tgz#c7d2cea631e6a39a1dc973819e667c6fa08583a2"
integrity sha512-4Vygb2zBgXglZ834Pu5XoTaUIkShM3ZHbPthLobYZ6Ia+vabq0A4CNbxBJN5fKZxvVqAft+8/YWAuq9MF/TavA==
"@pubsweet/logger@^0.2.28":
version "0.2.28"
resolved "https://registry.yarnpkg.com/@pubsweet/logger/-/logger-0.2.28.tgz#341e2f7bd234f7ef4e91bfa6ff3f5ba7ed2ef0d9"
integrity sha512-LmJBvQVhRLo4tWou/fyIfq01DU9EIasmpe2EfVrDxqTDALZm+5ycIXhA8LqpYqP4GeoKdi3qgpzNOSgLyuizsw==
dependencies:
config "^3.0.1"
joi "^14.3.0"
......@@ -1371,14 +1371,14 @@
http-status-codes "^1.3.0"
passport "^0.4.0"
"@pubsweet/model-user@^5.0.2":
version "5.0.2"
resolved "https://registry.yarnpkg.com/@pubsweet/model-user/-/model-user-5.0.2.tgz#9b024eb6f9efd06e621eed94d373c02fc5287f2b"
integrity sha512-qXd2jGFB8DnnvoTvRCFjT8r4fMl5Vc9Rk/3u+kwePOtsHrGFdLHDbbu0Pno+UIs2WpmD/2+Ke6JFjIFr9eKFUg==
"@pubsweet/model-user@^5.0.4":
version "5.0.4"
resolved "https://registry.yarnpkg.com/@pubsweet/model-user/-/model-user-5.0.4.tgz#f950504acbd22b3313ab649cdf30dfefe8def0f6"
integrity sha512-wwuaBK3m5gSmonvvJ8siHBH/61CANxyBMuCETygw4fwhOM/67osHD8lVznOtkEwHJunJDRq9lJa9I/GBu76k6w==
dependencies:
"@pubsweet/base-model" "^3.3.2"
"@pubsweet/errors" "^2.0.16"
"@pubsweet/logger" "^0.2.26"
"@pubsweet/base-model" "^3.3.4"
"@pubsweet/errors" "^2.0.18"
"@pubsweet/logger" "^0.2.28"
bcrypt "3.0.2"
http-status-codes "^1.3.0"
jsonwebtoken "^8.4.0"
......@@ -1403,6 +1403,15 @@
lodash "^4.17.4"
styled-components "^4.1.1"
"@pubsweet/ui-toolkit@^2.2.7":
version "2.2.7"
resolved "https://registry.yarnpkg.com/@pubsweet/ui-toolkit/-/ui-toolkit-2.2.7.tgz#a8a8cbb3279bf41d06c93bc3f0cff2fce46a23cf"
integrity sha512-KNl1dPGyU8NyGhvzv1rardhzUNU0HLmm99qmVOY+3q5valQPTZkiYE3aiHHzzItpnbN206zlfXnGxK/wR+xo0Q==
dependencies:
color "^3.0.0"
lodash "^4.17.4"
styled-components "^4.1.1"
"@pubsweet/ui@^10.3.4":
version "10.3.4"
resolved "https://registry.yarnpkg.com/@pubsweet/ui/-/ui-10.3.4.tgz#6e6152f0396142ddd9219f23e54d510c66cb35a4"
......@@ -1425,6 +1434,28 @@
recompose "^0.30.0"
styled-components "^4.1.1"
"@pubsweet/ui@^10.3.7":
version "10.3.7"
resolved "https://registry.yarnpkg.com/@pubsweet/ui/-/ui-10.3.7.tgz#b4c6266ed6cbaefbf5136826c1c82baecdaf1d08"
integrity sha512-4ljKKKq7yyOd1GpOWOCkv2EzU3w/XajEgcX3QG1sIK3DrWTnsOQDtgxRgtw0oyCsbRXKeLbrxTFC3PgZLeF9hg==
dependencies:
"@pubsweet/ui-toolkit" "^2.2.7"
classnames "^2.2.5"
enzyme "^3.7.0"
enzyme-adapter-react-16 "^1.12.1"
formik "^1.4.2"
invariant "^2.2.3"
lodash "^4.17.4"
moment "^2.22.1"
prop-types "^15.5.10"
react "^16.8.6"
react-dom "^16.8.6"
react-feather "^1.0.8"
react-router-dom "^5.0.0"
react-tag-autocomplete "^5.5.0"
recompose "^0.30.0"
styled-components "^4.1.1"
"@samverschueren/stream-to-observable@^0.3.0":
version "0.3.0"
resolved "https://registry.yarnpkg.com/@samverschueren/stream-to-observable/-/stream-to-observable-0.3.0.tgz#ecdf48d532c58ea477acfcab80348424f8d0662f"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment