diff --git a/.gitlab-ci.ncrc.yml b/.gitlab-ci.ncrc.yml index b50dadbb38e3bd06f0c466075ec5fb01105286d6..7ee00b72f452af436498de78978f3040e81958c1 100644 --- a/.gitlab-ci.ncrc.yml +++ b/.gitlab-ci.ncrc.yml @@ -70,31 +70,31 @@ deploy: # - cd ${HOME} # - npm run lint -# test-chrome: -# image: $IMAGE_ORG/$IMAGE_NAME-dev:$CI_COMMIT_SHA -# stage: test -# variables: -# GIT_STRATEGY: none -# # setup data for postgres image -# POSTGRES_USER: kotahidev -# POSTGRES_PASSWORD: kotahidev -# # used by psql -# PGUSER: kotahidev -# PGPASSWORD: kotahidev -# # this is used to ignore self signed certs -# #START_SERVER_AND_TEST_INSECURE: 1 -# services: -# - postgres -# script: -# - cd ${HOME} -# - apt-get -y install postgresql-client -# # this is needed for pgboss initial setup -# - psql -h postgres -U kotahidev -d kotahidev -c "create extension pgcrypto;" -# # use the example env for tests -# - cp .env.example .env -# # specify host here else it confuses the linked postgres image -# - echo $INSTANCE_NAME -# - POSTGRES_HOST=postgres yarn test:all:chrome:ncrc + test-chrome: + image: $IMAGE_ORG/$IMAGE_NAME-dev:$CI_COMMIT_SHA + stage: test + variables: + GIT_STRATEGY: none + # setup data for postgres image + POSTGRES_USER: kotahidev + POSTGRES_PASSWORD: kotahidev + # used by psql + PGUSER: kotahidev + PGPASSWORD: kotahidev + # this is used to ignore self signed certs + #START_SERVER_AND_TEST_INSECURE: 1 + services: + - postgres + script: + - cd ${HOME} + - apt-get -y install postgresql-client + # this is needed for pgboss initial setup + - psql -h postgres -U kotahidev -d kotahidev -c "create extension pgcrypto;" + # use the example env for tests + - cp .env.example .env + # specify host here else it confuses the linked postgres image + - echo $INSTANCE_NAME + - POSTGRES_HOST=postgres yarn test:all:chrome:ncrc # test-chrome-samsung: # image: $IMAGE_ORG/$IMAGE_NAME-dev:$CI_COMMIT_SHA diff --git a/cypress/fixtures/form_option.json b/cypress/fixtures/form_option.json index 1b461de8d54d849ba7e09c7e74fcf98335626e79..772d54070dee3d411687333cc4f6f72ef90331ce 100644 --- a/cypress/fixtures/form_option.json +++ b/cypress/fixtures/form_option.json @@ -1,13 +1,58 @@ { - "title": "Research Object Submission Form", - "field1": "Article ID", - "field2": "Article URL", - "field3": "Description", - "field4": "Evaluation Content", - "field5": "Evaluation Type", - "field6": "Creator", - "fieldOption": "Required", - "evaluationTypeOption1": "Evaluation Summary", - "evaluationTypeOption2": "Peer Review", - "evaluationTypeOption3": "Author Response" + "elife": { + "title": "Research Object Submission Form", + "articleId": "Article ID", + "articleUrl": "Article URL", + "description": "Description", + "evaluationContent": "Evaluation Content", + "evaluationType": "Evaluation Type", + "creator": "Creator", + "required": "Required", + "evaluationTypes" : { + "evaluationSummary": "Evaluation Summary", + "peerReview": "Peer Review", + "authorResponse": "Author Response" + } + }, + "ncrc": { + "title": "NCRC Submission Form", + "articleUrl" : "Article URL", + "description": "Article Description", + "ourTake": "Our take", + "studyDesign": "Study design", + "studyPopulation": "Study population and setting", + "mainFindings": "Summary of main findings", + "studyStrengths": "Study strengths", + "limitations": "Limitations", + "valueAdded": "Value added", + "labels": "Labels", + "topics": "Topics", + "studyDesignTypes": { + "caseSeries": "Case-series", + "caseControl": "Case-control", + "crossSectional": "Cross-sectional", + "prospectiveCohort": "Prospective cohort", + "retrospectiveCohort": "Retrospective cohort", + "ecological": "Ecological", + "ranomizedControlTrial": "Randomized Control Trial", + "nonRandomizedTrial": "Non-Randomized Trial", + "modelingSimulation": "Modeling/Simulation", + "other": "Other" + }, + "labelTypes": { + "readyToEvaluate": "Ready to evaluate", + "evaluated": "Evaluated", + "readyToPublish": "Ready to publish" + }, + "topicTypes": { + "ecologyAndSpillover": "ecologyAndSpillover", + "vaccines": "vaccines", + "interventions": "nonPharmaceuticalAndPharmaceuticalInterventions", + "epidemiology": "epidemiology", + "diagnostics": "diagnostics", + "modeling": "modeling", + "clinicalPresentation": "clinicalPresentation", + "prognosticRiskFactors": "prognosticRiskFactors" + } + } } \ No newline at end of file diff --git a/cypress/integration/elife/form_builer_page_spec.js b/cypress/integration/elife/form_builer_page_spec.js index e4045a911079600071030cff59c56875d0c10e9b..bc0d68e67741a84c59d7fd3c860489b55ae75ba1 100644 --- a/cypress/integration/elife/form_builer_page_spec.js +++ b/cypress/integration/elife/form_builer_page_spec.js @@ -1,9 +1,8 @@ import { FormsPage } from '../../page-object/forms-page' import { NewSubmissionPage } from '../../page-object/new-submission-page' -import { Menu } from '../../page-object/page-component/menu' import { SubmissionFormPage } from '../../page-object/submission-form-page' import { ManuscriptsPage } from '../../page-object/manuscripts-page' -import { dashboard } from '../../support/routes' +import { formBuilder, manuscripts } from '../../support/routes' describe('Form builder page tests', () => { // check the title and the elements in Form Builder @@ -14,23 +13,38 @@ describe('Form builder page tests', () => { // login as admin // eslint-disable-next-line jest/valid-expect-in-promise cy.fixture('role_names').then(name => { - cy.login(name.role.admin, dashboard) + cy.login(name.role.admin, formBuilder) }) - - // enter the from page and assert the fileds - Menu.clickForms() }) - it('check title and elements from form buider', () => { + it('check title and elements from form builder', () => { // eslint-disable-next-line jest/valid-expect-in-promise cy.fixture('form_option').then(data => { - FormsPage.getFormTitleTab(0).should('contain', data.title) - FormsPage.getFormBuilderElementName(0).should('contain', data.field1) - FormsPage.getFormBuilderElementName(1).should('contain', data.field2) - FormsPage.getFormBuilderElementName(2).should('contain', data.field3) - FormsPage.getFormBuilderElementName(3).should('contain', data.field4) - FormsPage.getFormBuilderElementName(4).should('contain', data.field5) - FormsPage.getFormBuilderElementName(5).should('contain', data.field6) + FormsPage.getFormTitleTab(0).should('contain', data.elife.articleId) + FormsPage.getFormBuilderElementName(0).should( + 'contain', + data.elife.articleUrl, + ) + FormsPage.getFormBuilderElementName(1).should( + 'contain', + data.elife.description, + ) + FormsPage.getFormBuilderElementName(2).should( + 'contain', + data.elife.evaluationContent, + ) + FormsPage.getFormBuilderElementName(3).should( + 'contain', + data.elife.evaluationType, + ) + FormsPage.getFormBuilderElementName(4).should( + 'contain', + data.elife.creator, + ) + FormsPage.getFormBuilderElementName(5).should( + 'contain', + data.elife.required, + ) }) }) @@ -63,11 +77,8 @@ describe('Form builder page tests', () => { cy.task('restore', 'initialState') // login as admin cy.fixture('role_names').then(name => { - cy.login(name.role.admin, dashboard) + cy.login(name.role.admin, manuscripts) }) - - // enter the from page and assert the fileds - Menu.clickManuscripts() ManuscriptsPage.clickSubmit() NewSubmissionPage.clickSubmitURL() }) @@ -76,12 +87,30 @@ describe('Form builder page tests', () => { it('check if the form contain all the colums', () => { // eslint-disable-next-line jest/valid-expect-in-promise cy.fixture('form_option').then(data => { - SubmissionFormPage.getFormOptionList(0).should('contain', data.field1) - SubmissionFormPage.getFormOptionList(1).should('contain', data.field2) - SubmissionFormPage.getFormOptionList(2).should('contain', data.field3) - SubmissionFormPage.getFormOptionList(3).should('contain', data.field4) - SubmissionFormPage.getFormOptionList(4).should('contain', data.field5) - SubmissionFormPage.getFormOptionList(5).should('contain', data.field6) + SubmissionFormPage.getFormOptionList(0).should( + 'contain', + data.elife.articleId, + ) + SubmissionFormPage.getFormOptionList(1).should( + 'contain', + data.elife.articleUrl, + ) + SubmissionFormPage.getFormOptionList(2).should( + 'contain', + data.elife.description, + ) + SubmissionFormPage.getFormOptionList(3).should( + 'contain', + data.elife.evaluationContent, + ) + SubmissionFormPage.getFormOptionList(4).should( + 'contain', + data.elife.evaluationType, + ) + SubmissionFormPage.getFormOptionList(5).should( + 'contain', + data.elife.creator, + ) }) }) @@ -92,43 +121,43 @@ describe('Form builder page tests', () => { cy.fixture('form_option').then(data => { SubmissionFormPage.getFormOptionList(0).should( 'contain', - data.fieldOption, + data.elife.required, ) SubmissionFormPage.getFormOptionList(1).should( 'contain', - data.fieldOption, + data.elife.required, ) SubmissionFormPage.getFormOptionList(2).should( 'contain', - data.fieldOption, + data.elife.required, ) SubmissionFormPage.getFormOptionList(3).should( 'contain', - data.fieldOption, + data.elife.required, ) SubmissionFormPage.getFormOptionList(4).should( 'contain', - data.fieldOption, + data.elife.required, ) }) }) - // check if the options: Evaluation Summary, Peer Review and Author Response are avaible in Evaluation Type field + // check if the options: Evaluation Summary, Peer Review and Author Response are available in Evaluation Type field it('check Evaluation Type filed options', () => { // eslint-disable-next-line jest/valid-expect-in-promise cy.fixture('form_option').then(data => { SubmissionFormPage.clickElementFromFormOptionList(4) SubmissionFormPage.getDropdownOption(0).should( 'contain', - data.evaluationTypeOption1, + data.elife.evaluationTypes.evaluationSummary, ) SubmissionFormPage.getDropdownOption(1).should( 'contain', - data.evaluationTypeOption2, + data.elife.evaluationTypes.peerReview, ) SubmissionFormPage.getDropdownOption(2).should( 'contain', - data.evaluationTypeOption3, + data.elife.evaluationTypes.authorResponse, ) }) }) diff --git a/cypress/integration/ncrc/form_builder_page_spec.js b/cypress/integration/ncrc/form_builder_page_spec.js new file mode 100644 index 0000000000000000000000000000000000000000..85364540eb6ceb80c9ef314f0b0985d2e941384f --- /dev/null +++ b/cypress/integration/ncrc/form_builder_page_spec.js @@ -0,0 +1,202 @@ +import { formBuilder, manuscripts } from '../../support/routes' +import { FormsPage } from '../../page-object/forms-page' +import { ManuscriptsPage } from '../../page-object/manuscripts-page' +import { NewSubmissionPage } from '../../page-object/new-submission-page' +import { SubmissionFormPage } from '../../page-object/submission-form-page' + +describe('form builder tests', () => { + context('check form builder elements visibility', () => { + beforeEach(() => { + // task to restore the database as per the dumps/initialState.sql + cy.task('restore', 'initialState') + // login as admin + // eslint-disable-next-line jest/valid-expect-in-promise + cy.fixture('role_names').then(name => { + cy.login(name.role.admin, formBuilder) + }) + }) + it('check form entries are correct', () => { + // eslint-disable-next-line jest/valid-expect-in-promise + cy.fixture('form_option').then(data => { + FormsPage.getFormTitleTab(0).should('contain', data.ncrc.title) + + const dataArray = [ + data.ncrc.articleUrl, + data.ncrc.description, + data.ncrc.ourTake, + data.ncrc.studyDesign, + data.ncrc.studyPopulation, + data.ncrc.mainFindings, + data.ncrc.studyStrengths, + data.ncrc.limitations, + data.ncrc.valueAdded, + data.ncrc.labels, + data.ncrc.topics, + ] + + // eslint-disable-next-line no-plusplus + for (let i = 0; i < 11; i++) { + FormsPage.getFormBuilderElementName(i).should('contain', dataArray[i]) + } + }) + }) + it('check form field type & assert field is mandatory', () => { + FormsPage.clickFormOption(0) + FormsPage.getComponentType().should('contain', 'TextField') + FormsPage.getFieldValidate().should('contain', 'Required') + FormsPage.clickFormOption(1) + FormsPage.getComponentType().should('contain', 'TextField') + FormsPage.getFieldValidate().should('contain', 'Required') + FormsPage.clickFormOption(2) + FormsPage.getComponentType().should('contain', 'AbstractEditor') + FormsPage.getFieldValidate().should('contain', 'Required') + FormsPage.clickFormOption(3) + FormsPage.getComponentType().should('contain', 'Select') + FormsPage.getFieldValidate().should('contain', 'Required') + FormsPage.clickFormOption(4) + FormsPage.getComponentType().should('contain', 'AbstractEditor') + FormsPage.getFieldValidate().should('contain', 'Required') + FormsPage.clickFormOption(5) + FormsPage.getComponentType().should('contain', 'AbstractEditor') + FormsPage.getFieldValidate().should('contain', 'Required') + FormsPage.clickFormOption(6) + FormsPage.getComponentType().should('contain', 'AbstractEditor') + FormsPage.getFieldValidate().should('contain', 'Required') + FormsPage.clickFormOption(7) + FormsPage.getComponentType().should('contain', 'AbstractEditor') + FormsPage.getFieldValidate().should('contain', 'Required') + FormsPage.clickFormOption(8) + FormsPage.getComponentType().should('contain', 'AbstractEditor') + FormsPage.getFieldValidate().should('contain', 'Required') + FormsPage.clickFormOption(9) + FormsPage.getComponentType().should('contain', 'Select') + FormsPage.getFieldValidate().should('contain', 'Required') + FormsPage.clickFormOption(10) + FormsPage.getComponentType().should('contain', 'CheckboxGroup') + FormsPage.getFieldValidate().should('contain', 'Required') + }) + context('check submission form corresponds to form builder', () => { + beforeEach(() => { + // task to restore the database as per the dumps/initialState.sql + cy.task('restore', 'initialState') + // login as admin + cy.fixture('role_names').then(name => { + cy.login(name.role.admin, manuscripts) + }) + ManuscriptsPage.clickSubmit() + NewSubmissionPage.clickSubmitURL() + }) + + it('check submission form contains the same fields', () => { + // eslint-disable-next-line jest/valid-expect-in-promise + cy.fixture('form_option').then(data => { + const dataArray = [ + data.ncrc.articleUrl, + data.ncrc.description, + data.ncrc.ourTake, + data.ncrc.studyDesign, + data.ncrc.studyPopulation, + data.ncrc.mainFindings, + data.ncrc.studyStrengths, + data.ncrc.limitations, + data.ncrc.valueAdded, + data.ncrc.labels, + data.ncrc.topics, + ] + + // eslint-disable-next-line no-plusplus + for (let i = 0; i < 11; i++) { + SubmissionFormPage.getFormOptionList(i).should( + 'contain', + dataArray[i], + ) + } + }) + }) + + it('check required message is displayed for all fields', () => { + SubmissionFormPage.clickSubmitManuscript() + // eslint-disable-next-line jest/valid-expect-in-promise + cy.fixture('form_option').then(data => { + // eslint-disable-next-line no-plusplus + for (let i = 0; i < 11; i++) { + SubmissionFormPage.getFormOptionList(i).should( + 'contain', + data.elife.required, + ) + } + }) + }) + + it('check study design dropdown options', () => { + // eslint-disable-next-line jest/valid-expect-in-promise + cy.fixture('form_option').then(data => { + const dataArray = [ + data.ncrc.studyDesignTypes.caseSeries, + data.ncrc.studyDesignTypes.caseControl, + data.ncrc.studyDesignTypes.crossSectional, + data.ncrc.studyDesignTypes.prospectiveCohort, + data.ncrc.studyDesignTypes.retrospectiveCohort, + data.ncrc.studyDesignTypes.ecological, + data.ncrc.studyDesignTypes.ranomizedControlTrial, + data.ncrc.studyDesignTypes.nonRandomizedTrial, + data.ncrc.studyDesignTypes.modelingSimulation, + data.ncrc.studyDesignTypes.other, + ] + + SubmissionFormPage.clickElementFromFormOptionList(3) + + // eslint-disable-next-line no-plusplus + for (let i = 0; i < 10; i++) { + SubmissionFormPage.getDropdownOption(i).should( + 'contain', + dataArray[i], + ) + } + }) + }) + it('check label dropdown options', () => { + // eslint-disable-next-line jest/valid-expect-in-promise + cy.fixture('form_option').then(data => { + const dataArray = [ + data.ncrc.labelTypes.readyToEvaluate, + data.ncrc.labelTypes.evaluated, + data.ncrc.labelTypes.readyToPublish, + ] + + SubmissionFormPage.clickElementFromFormOptionList(9) + + // eslint-disable-next-line no-plusplus + for (let i = 0; i < 3; i++) { + SubmissionFormPage.getDropdownOption(i).should( + 'contain', + dataArray[i], + ) + } + }) + }) + it('check topic checkbox options', () => { + // eslint-disable-next-line jest/valid-expect-in-promise + cy.fixture('form_option').then(data => { + const valueArray = [ + data.ncrc.topicTypes.ecologyAndSpillover, + data.ncrc.topicTypes.vaccines, + data.ncrc.topicTypes.interventions, + data.ncrc.topicTypes.epidemiology, + data.ncrc.topicTypes.diagnostics, + data.ncrc.topicTypes.modeling, + data.ncrc.topicTypes.clinicalPresentation, + data.ncrc.topicTypes.prognosticRiskFactors, + ] + + // eslint-disable-next-line no-plusplus + for (let i = 0; i < 8; i++) { + SubmissionFormPage.getTopicsCheckboxWithText(`"${valueArray[i]}"`) + .scrollIntoView() + .should('be.visible') + } + }) + }) + }) + }) +}) diff --git a/cypress/page-object/submission-form-page.js b/cypress/page-object/submission-form-page.js index 81cc5c75e9112ae6081f22282d9b33fc69acc470..8b34966fe1da816e013402ecdedaaf05a0a11ba2 100644 --- a/cypress/page-object/submission-form-page.js +++ b/cypress/page-object/submission-form-page.js @@ -42,6 +42,8 @@ const DESCRIPTION_FIELD = 'submission.description' const EVALUATION_CONTENT_FIELD = 'submission.evaluationContent' const CREATOR_FIELD = 'submission.creator' +const TOPICS_CHECKBOX_LIST = 'submission.topics' + export const SubmissionFormPage = { getAddLinkButton() { return cy.get(ADD_A_LINK_BUTTON) @@ -252,5 +254,11 @@ export const SubmissionFormPage = { fillInCreator(creator) { this.getCreatorField().fillInput(creator) }, + getTopicsCheckboxWithText(value) { + return cy.getByNameAndValue(TOPICS_CHECKBOX_LIST, value) + }, + clickTopicsCheckboxWithText(value) { + this.getTopicsCheckboxWithText(value).click() + }, } export default SubmissionFormPage diff --git a/package.json b/package.json index ff8c81ef009e1c7c7f9c0c90fdc21143dbe74a99..ea053e760846531ca3c9d5057b2dc36b3eaac3aa 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,9 @@ "test:firefox:elife:samsung:tablet": "cypress run --env userAgent=tabletSamsung --browser firefox --headless --spec 'cypress/integration/elife/**.js'", "test:firefox:elife:iPhone": "cypress run --env userAgent=phoneSafari --browser firefox --spec 'cypress/integration/elife/**.js'", "test:firefox:elife:iPhone:tablet": "cypress run --env userAgent=tabletSafari --browser firefox --headless --spec 'cypress/integration/elife/**.js'", - "test:firefox:elife:hd:laptop": "cypress run --env userAgent=hdLaptop --browser chrome --spec 'cypress/integration/elife/**.js'" + "test:firefox:elife:hd:laptop": "cypress run --env userAgent=hdLaptop --browser chrome --spec 'cypress/integration/elife/**.js'", + "test:all:chrome:ncrc": "start-test test:server-and-client 4000 test:chrome:ncrc", + "test:chrome:ncrc": "cypress run --browser chrome --headless --spec 'cypress/integration/ncrc/**.js'" }, "husky": { "hooks": {