Commit ee616fbd authored by Adi Onofrei's avatar Adi Onofrei

Merge branch 'automation' into 'develop'

Automation

See merge request !235
parents d4907a35 4a6a8777
Pipeline #11177 passed with stages
in 10 minutes and 17 seconds
#https://github.com/direnv/direnv/wiki/Node#load-nodejs-version-from-a-node-version-or-nvmrc-file
set -e
use node 8
use node 8
\ No newline at end of file
......@@ -71,6 +71,30 @@ push:qa:
- docker tag ${CI_PROJECT_NAME}:$CI_COMMIT_SHA $DOCKER_REPO:latest
- docker push $DOCKER_REPO:latest
push:automation:
image: docker:latest
stage: push
only:
- automation
when: manual
variables:
NODE_ENV: test
script:
# Setup
- export AWS_REGION="eu-west-1"
- export AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID
- export AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY
- apk update
- apk --no-cache add --update curl python python-dev py-pip
- pip install awscli --upgrade --user
- export PATH=~/.local/bin:/usr/bin/:$PATH
# AUTH
- CERT=`aws ecr get-login --no-include-email --region ${AWS_REGION}`
- ${CERT}
# Tag
- docker tag ${CI_PROJECT_NAME}:$CI_COMMIT_SHA $DOCKER_REPO:automation
- docker push $DOCKER_REPO:automation
push:staging:
image: docker:latest
when: manual
......@@ -137,6 +161,24 @@ deploy:qa:
- source deploy.sh
- create_deployment
deploy:automation:
image: pubsweet/deployer:latest
stage: deploy
when: manual
only:
- automation
variables:
PACKAGE_NAME: xpub-faraday
IMAGE_REPO: $CI_ECR_URL
IMAGE_TAG: automation
NODE_ENV: test
environment:
name: qa
url: http://qa.review.hindawi.com
script:
- source deploy.sh
- create_deployment
deploy:styleguide:
image: pubsweet/deployer:latest
stage: deploy
......
......@@ -21,7 +21,7 @@ const AuthorReply = ({
onDownload,
onPreview,
}) => (
<Root>
<Root data-test-id="author-reply">
<Row justify="space-between" mb={2}>
<Item justify="flex-end">
<Row mb={1}>
......
......@@ -22,7 +22,7 @@ const EditorialReportCard = ({
collection,
report: { createdOn, reviewer },
}) => (
<Root>
<Root data-test-id="editorial-report-card">
<Row justify="space-between" mb={2}>
<Item vertical>
<Label mb={1 / 2}>
......
......@@ -71,6 +71,7 @@ const FileItem = ({
/>
{hasDelete && (
<IconButton
data-test-id="delete-file"
fontIcon="deleteIcon"
iconSize={1.8}
mr={1}
......
......@@ -49,8 +49,10 @@ const FileSection = ({
onPreview,
onDownload,
onDelete,
testId,
}) => (
<Root
data-test-id={testId}
isFileItemOver={isFileItemOver && canDropFileItem}
isFirst={isFirst}
isLast={isLast}
......
......@@ -33,6 +33,7 @@ const PersonInvitation = ({
>
{showModal => (
<IconButton
data-test-id="resend-invitation-to-HE"
fontIcon="resendIcon"
mb={1}
ml={2}
......@@ -52,6 +53,7 @@ const PersonInvitation = ({
>
{showModal => (
<IconButton
data-test-id="revoke-button"
fontIcon="removeIcon"
mb={1}
ml={2}
......@@ -75,6 +77,7 @@ const PersonInvitation = ({
>
{showModal => (
<IconButton
data-test-id="revoke-button"
fontIcon="removeIcon"
mb={1}
ml={2}
......
......@@ -28,7 +28,7 @@ const ReviewerReportAuthor = ({
recommendation,
report: { submittedOn },
}) => (
<Root>
<Root data-test-id="reviewer-reports-for-author">
<Row justify="space-between" mb={2}>
<Item justify="flex-end">
{publicReport && (
......
......@@ -171,7 +171,7 @@ const EditUserProfile = compose(
</Row>
<RowOverrideAlert alignItems="baseline" mt={2}>
<Item mr={1} vertical>
<Item data-test-id="title" mr={1} vertical>
<Label required>Title</Label>
<ValidatedField
component={input => <Menu {...input} options={title} />}
......@@ -179,7 +179,7 @@ const EditUserProfile = compose(
validate={[requiredValidator]}
/>
</Item>
<Item ml={1} vertical>
<Item data-test-id="country" ml={1} vertical>
<Label required>Country</Label>
<ValidatedField
component={MenuCountry}
......
......@@ -39,6 +39,7 @@ const WizardFiles = ({
onFilePick={addFile('manuscripts')}
onPreview={previewFile}
required
testId="main-manuscript"
title="Main Manuscript"
/>
<FileSection
......@@ -54,6 +55,7 @@ const WizardFiles = ({
onFileDrop={addFile('coverLetter')}
onFilePick={addFile('coverLetter')}
onPreview={previewFile}
testId="cover-letter"
title="Cover Letter"
/>
<FileSection
......@@ -68,6 +70,7 @@ const WizardFiles = ({
onFileDrop={addFile('supplementary')}
onFilePick={addFile('supplementary')}
onPreview={previewFile}
testId="supplemental-files"
title="Supplemental Files"
/>
</Fragment>
......
......@@ -30,7 +30,7 @@ const AssignHE = ({
handlingEditors,
inviteHandlingEditor,
}) => (
<Root pb={2}>
<Root data-test-id="assign-handling-editor" pb={2}>
<TextContainer>
<TextField
data-test-id="manuscript-assign-he-filter"
......
......@@ -88,6 +88,7 @@ const HERecommendation = ({
...rest
}) => (
<ContextualBox
data-test-id="contextual-box-he-recommendation"
expanded={expanded}
highlight={highlight}
label="Your Editorial Recommendation"
......@@ -95,7 +96,7 @@ const HERecommendation = ({
toggle={toggle}
{...rest}
>
<Root>
<Root data-test-id="contextual-box-he-recommendation-response">
<Row justify="flex-start">
<ItemOverrideAlert
data-test-id="editorial-recommendation-choose-options"
......@@ -120,14 +121,11 @@ const HERecommendation = ({
</Row>
{(minorRevisionRecommendation || majorRevisionRecommendation) && (
<Row mt={2}>
<ResponsiveItem
data-test-id="editorial-recommendation-message-for-author"
mr={1}
vertical
>
<ResponsiveItem mr={1} vertical>
<Label required>Message for Author</Label>
<ValidatedField
component={Textarea}
data-test-id="editorial-recommendation-message-for-author"
name="public"
validate={[required]}
/>
......@@ -136,31 +134,28 @@ const HERecommendation = ({
)}
{(publishRecommendation || rejectRecommendation) && (
<ResponsiveRow mt={2}>
<ResponsiveItem
data-test-id="editorial-recommendation-message-for-author"
mr={1}
vertical
>
<ResponsiveItem mr={1} vertical>
<Label required={!!rejectRecommendation}>
Message for Author{' '}
{publishRecommendation ? <Text secondary> Optional</Text> : ''}
</Label>
<ValidatedField
component={Textarea}
data-test-id="editorial-recommendation-message-for-author"
name="public"
validate={rejectRecommendation ? [required] : false}
/>
</ResponsiveItem>
<ResponsiveItem
data-test-id="editorial-recommendation-message-for-eic"
ml={1}
vertical
>
<ResponsiveItem ml={1} vertical>
<Label>
Message for Editor in Chief <Text secondary>Optional</Text>
</Label>
<ValidatedField component={Textarea} name="private" />
<ValidatedField
component={Textarea}
data-test-id="editorial-recommendation-message-for-eic"
name="private"
/>
</ResponsiveItem>
</ResponsiveRow>
)}
......
......@@ -19,6 +19,7 @@ const ResponseToRevisionRequest = ({
...rest
}) => (
<ContextualBox
data-test-id="response-to-revision-request"
expanded={expanded}
label="Response to Revision Request"
mb={2}
......
......@@ -48,6 +48,7 @@ const ReviewerDetails = ({
...rest
}) => (
<ContextualBox
data-test-id="reviewer-details-and-reports-box"
expanded={expanded}
highlight={highlight}
label="Reviewer Details & Reports"
......@@ -58,7 +59,7 @@ const ReviewerDetails = ({
<Tabs selectedTab={reports.length ? 1 : 0}>
{({ selectedTab, changeTab }) => (
<Fragment>
<TabsHeader>
<TabsHeader data-test-id="reviewer-details-and-reports-tabs">
<TabButton
ml={1}
mr={1}
......
......@@ -38,13 +38,14 @@ const ReviewerReportForm = ({
isFetchingFromAutosave,
}) => (
<ContextualBox
data-test-id="submit-report-box"
expanded={expanded}
highlight
label="Your report"
scrollIntoView
toggle={toggle}
>
<Root>
<Root data-test-id="report-box-response">
<Row justify="flex-start">
<ItemOverrideAlert
data-test-id="form-report-recommendation"
......
......@@ -22,7 +22,7 @@ const Form = compose(
form: 'deleteManuscript',
}),
)(({ fetchingError, hideModal, handleSubmit, isFetching }) => (
<Root>
<Root data-test-id="delete-manuscript-modal">
<IconButton
icon="x"
iconSize={2}
......
......@@ -39,7 +39,11 @@ const ManuscriptDetailsTop = ({
Dashboard
</ActionLink>
</Item>
<Item alignItems="baseline" justify="flex-end">
<Item
alignItems="baseline"
data-test-id="item-details-top"
justify="flex-end"
>
{canOverrideTechChecks && (
<ActionLink
data-test-id="button-qa-manuscript-technical-checks"
......@@ -86,6 +90,7 @@ const ManuscriptDetailsTop = ({
</DateParser>
<ManuscriptVersion
collection={collection}
data-test-id="versions-dropdown"
fragment={fragment}
history={history}
versions={versions}
......
......@@ -65,14 +65,10 @@ const ManuscriptEicDecision = ({
lastHeRecommendation,
...rest
}) => (
<ContextualBox
data-test-id="your-editorial-decision-id"
label="Your Editorial Decision"
{...rest}
>
<Root>
<ContextualBox label="Your Editorial Decision" {...rest}>
<Root data-test-id="contextual-box-manuscript-eic-response">
<Row justify="flex-start" pl={1} pt={1}>
<ItemOverrideAlert flex={0} vertical>
<ItemOverrideAlert data-test-id="form-eic-decision" flex={0} vertical>
<Label required>Decision</Label>
<ValidatedField
component={input => <Menu {...input} options={options} />}
......@@ -91,6 +87,7 @@ const ManuscriptEicDecision = ({
</Label>
<ValidatedField
component={ValidatedTextArea}
data-test-id="eic-decision-message"
name="message"
validate={decision !== 'reject' ? [required] : undefined}
/>
......@@ -105,6 +102,7 @@ const ManuscriptEicDecision = ({
</Label>
<ValidatedField
component={ValidatedTextArea}
data-test-id="eic-decision-message"
name="message"
validate={
lastHeRecommendation !== 'reject' ? [required] : undefined
......@@ -115,7 +113,12 @@ const ManuscriptEicDecision = ({
)}
<Row justify="flex-end" mt={1} pr={1}>
<Button onClick={handleSubmit} primary size="medium">
<Button
data-test-id="submit-decision-eic"
onClick={handleSubmit}
primary
size="medium"
>
SUBMIT DECISION
</Button>
</Row>
......
......@@ -49,14 +49,22 @@ const ManuscriptMetadata = ({
toggle={toggleConflictsOfInterest}
transparent
>
<Row alignItems="center" justify="flex-start">
<Row
alignItems="center"
data-test-id="conflict-of-interest-text"
justify="flex-start"
>
<Text mb={1} mt={1}>
Conflicts of interest:
</Text>
<Text ml={1 / 2}>{get(conflicts, 'message', '')}</Text>
</Row>
{get(conflicts, 'dataAvailabilityMessage', '') && (
<Row alignItems="center" justify="flex-start">
<Row
alignItems="center"
data-test-id="data-availability-message"
justify="flex-start"
>
<Text mb={1} mt={1}>
Data availability statment:
</Text>
......@@ -66,7 +74,11 @@ const ManuscriptMetadata = ({
</Row>
)}
{get(conflicts, 'fundingMessage', '') && (
<Row alignItems="center" justify="flex-start">
<Row
alignItems="center"
data-test-id="funding-message"
justify="flex-start"
>
<Text mb={1} mt={1}>
Funding statment:
</Text>
......
......@@ -36,6 +36,7 @@ const ResponseToInvitation = ({
buttonLabel = 'RESPOND TO INVITATION',
}) => (
<ContextualBox
data-test-id="respond-to-invitation-he-box"
expanded={expanded}
highlight
label={title}
......@@ -44,7 +45,7 @@ const ResponseToInvitation = ({
toggle={toggle}
>
<RowOverrideAlert justify="flex-start" ml={1} mt={1}>
<Item vertical>
<Item data-test-id="respond-to-editorial-invitation" vertical>
<Label required>{label}</Label>
<ValidatedField
component={input => (
......
......@@ -23,7 +23,12 @@ const ManuscriptFiles = ({
getSignedUrl,
formErrors,
}) => (
<ContextualBox label="Manuscript Files" startExpanded transparent>
<ContextualBox
data-test-id="manuscript-files"
label="Manuscript Files"
startExpanded
transparent
>
<Root>
<Row justify="flex-start" mb={2}>
<Text secondary>
......
......@@ -29,6 +29,7 @@ const ResponseToReviewer = ({
downloadFile,
}) => (
<ContextualBox
data-test-id="response-to-reviewer-comments"
label="Response to Reviewer Comments"
startExpanded
transparent
......@@ -42,6 +43,7 @@ const ResponseToReviewer = ({
) : (
<FilePicker
allowedFileExtensions={allowedFileExtensions}
data-test-id="submit-revision-reply-file"
disabled={!isEmpty(file)}
onUpload={onUpload}
>
......
......@@ -33,8 +33,13 @@ const SubmitRevision = ({
formErrors,
formName,
}) => (
<ContextualBox highlight label="Submit Revision" mb={2}>
<Root>
<ContextualBox
data-test-id="submit-revision"
highlight
label="Submit Revision"
mb={2}
>
<Root data-test-id="submit-revision-details">
<DetailsAndAuthors
addAuthor={addAuthor}
changeForm={changeForm}
......
......@@ -14,6 +14,7 @@ const EditorialCommentCard = ({
collection,
}) => (
<ContextualBox
data-test-id="contextual-box-editorial-comments"
expanded={expanded}
label="Editorial Comments"
mb={2}
......
......@@ -285,6 +285,7 @@ const ManuscriptLayout = ({
get(currentUser, 'permissions.canMakeDecision', false) && (
<ManuscriptEicDecision
collection={collection}
data-test-id="contextual-box-manuscript-eic-decision"
expanded={eicDecisionExpanded}
formValues={get(formValues, 'eicDecision')}
fragment={fragment}
......
......@@ -18,6 +18,7 @@ class Modal extends React.Component {
const { component: Component, overlayColor, ...rest } = this.props
return ReactDOM.createPortal(
<ModalRoot
data-test-id="modal-root"
onClick={rest.dismissable ? rest.hideModal : null}
overlayColor={overlayColor}
>
......
......@@ -121,7 +121,7 @@ const FormModal = ({
</Row>
<RowOverrideAlert alignItems="center" mb={2}>
<ItemOverrideAlert mr={1} vertical>
<ItemOverrideAlert data-test-id="title" mr={1} vertical>
<Label>Title</Label>
<ValidatedFormField
component={Menu}
......@@ -130,7 +130,7 @@ const FormModal = ({
/>
</ItemOverrideAlert>
<ItemOverrideAlert ml={1} vertical>
<ItemOverrideAlert data-test-id="country" ml={1} vertical>
<Label>Country</Label>
<ValidatedFormField component={MenuCountry} name="country" />
</ItemOverrideAlert>
......@@ -138,7 +138,7 @@ const FormModal = ({
<Row mb={3}>
{edit && (
<ItemOverrideAlert mr={1} vertical>
<ItemOverrideAlert data-test-id="role" mr={1} vertical>
<Label required>Role</Label>
<ValidatedFormField
component={Menu}
......
cypress/screenshots
cypress/videos
cypress.json
\ No newline at end of file
cypress.json
cypress/Reports
\ No newline at end of file
const fs = require('fs')
const path = require('path')
function getFiles(dir, ext, fileList = []) {
const files = fs.readdirSync(dir)
files.forEach(file => {
const filePath = `${dir}/${file}`
if (fs.statSync(filePath).isDirectory()) {
getFiles(filePath, fileList)
} else if (path.extname(file) === ext) {
fileList.push(filePath)
}
})
return fileList
}
function traverseAndModifyTimedOut(target, deep) {
if (target.tests && target.tests.length) {
target.tests.forEach(test => {
test.timedOut = false
})
}
if (target.suites) {
target.suites.forEach(suite => {
traverseAndModifyTimedOut(suite, deep + 1)
})
}
}
function combineMochaAwesomeReports(reportFolderName = 'mochawesome-report') {
const reportDir = path.join(__dirname, '..', reportFolderName)
const reports = getFiles(reportDir, '.json', [])
const suites = []
let totalSuites = 0
let totalTests = 0
let totalPasses = 0
let totalFailures = 0
let totalPending = 0
let startTime
let endTime
let totalskipped = 0
reports.forEach((report, idx) => {
const rawdata = fs.readFileSync(report)
const parsedData = JSON.parse(rawdata)
if (idx === 0) {
startTime = parsedData.stats.start
}
if (idx === reports.length - 1) {
endTime = parsedData.stats.end
}
totalSuites += parseInt(parsedData.stats.suites, 10)
totalskipped += parseInt(parsedData.stats.skipped, 10)
totalPasses += parseInt(parsedData.stats.passes, 10)
totalFailures += parseInt(parsedData.stats.failures, 10)
totalPending += parseInt(parsedData.stats.pending, 10)
totalTests += parseInt(parsedData.stats.tests, 10)
if (parsedData && parsedData.suites && parsedData.suites.suites) {
parsedData.suites.suites.forEach(suite => {
suites.push(suite)
})
}
})
return {
totalSuites,
totalTests,
totalPasses,
totalFailures,
totalPending,
startTime,
endTime,
totalskipped,
suites,
}
}
function getPercentClass(pct) {
if (pct <= 50) {
return 'danger'
} else if (pct > 50 && pct < 80) {
return 'warning'
}
return 'success'
}
function writeReport(obj, uuid) {
const sampleFile = path.join(__dirname, 'sample.json')
const outFile = path.join(__dirname, '..', `${uuid}.json`)
fs.readFile(sampleFile, 'utf8', (err, data) => {
if (err) throw err
const parsedSampleFile = JSON.parse(data)