diff --git a/cypress/fixtures/branding_settings.json b/cypress/fixtures/branding_settings.json index 2804a46f3f93a6d6d5d886ad09270e09332a80f7..4a616536e18a0a587d58057ee68f400714dd6096 100644 --- a/cypress/fixtures/branding_settings.json +++ b/cypress/fixtures/branding_settings.json @@ -9,5 +9,4 @@ "logoPath": "/public/logo-ncrc.jpg", "brandName": "Novel Coronavirus Research Compendium" } - -} \ 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 4c366a597d4c3a43adb024797be0d912798c6565..303c46780f93ae79285e697e78c6ac8281a5967e 100644 --- a/cypress/integration/elife/form_builer_page_spec.js +++ b/cypress/integration/elife/form_builer_page_spec.js @@ -70,6 +70,12 @@ describe('Form builder page tests', () => { FormsPage.getComponentType().should('contain', 'TextField') FormsPage.getFieldValidate().should('not.contain', 'Required') }) + it('check DOI validation has default selected Yes and select No', () => { + FormsPage.clickFormOption(1) + FormsPage.getDoiValidation(0).should('have.prop', 'checked') + FormsPage.clickOptionsDoiVaildation(1) + FormsPage.getDoiValidation(1).should('have.prop', 'checked') + }) }) context('check the Submission form based on form builder', () => { diff --git a/cypress/integration/elife/manuscripts_page_spec.js b/cypress/integration/elife/manuscripts_page_spec.js index 58bc7afbc47070e735ce6c387025a3b17eb775b5..67cf3d6a5924ea0359bc139a543d767e494a426d 100644 --- a/cypress/integration/elife/manuscripts_page_spec.js +++ b/cypress/integration/elife/manuscripts_page_spec.js @@ -226,4 +226,26 @@ describe('Manuscripts page tests', () => { }) }) }) + context('DOI validation', () => { + 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, manuscripts) + }) + ManuscriptsPage.getTableHeader().should('be.visible') + }) + + it('message for DOI invalid is visible ', () => { + ManuscriptsPage.clickSubmit() + NewSubmissionPage.clickSubmitUrlAndVerifyLink() + SubmissionFormPage.fillInArticleUrl("google.com") + SubmissionFormPage.fillInDescription('2') + SubmissionFormPage.getValidationErrorMessage('DOI is invalid') + }) + }) }) + diff --git a/cypress/integration/ncrc/form_builder_page_spec.js b/cypress/integration/ncrc/form_builder_page_spec.js index 539b56d6f94d196429594ec79bdf785849f5a2d7..a61e7a019baa95bbaf5b8ebfc24a7ba50371d5d5 100644 --- a/cypress/integration/ncrc/form_builder_page_spec.js +++ b/cypress/integration/ncrc/form_builder_page_spec.js @@ -77,6 +77,12 @@ describe('form builder tests', () => { FormsPage.getComponentType().should('contain', 'CheckboxGroup') FormsPage.getFieldValidate().should('contain', 'Required') }) + it('check DOI validation has default selected Yes and select No', () => { + FormsPage.clickFormOption(0) + FormsPage.getDoiValidation(0).should('have.prop', 'checked') + FormsPage.clickOptionsDoiVaildation(1) + FormsPage.getDoiValidation(1).should('have.prop', 'checked') + }) }) context('check submission form corresponds to form builder', () => { beforeEach(() => { @@ -201,5 +207,6 @@ describe('form builder tests', () => { } }) }) + }) }) diff --git a/cypress/integration/ncrc/manuscripts_page_spec.js b/cypress/integration/ncrc/manuscripts_page_spec.js index 60288f3044726f74467b0087634f0d01456a4ef1..d27afb46c8d1fccde2d564352bb9885d87ed1ba9 100644 --- a/cypress/integration/ncrc/manuscripts_page_spec.js +++ b/cypress/integration/ncrc/manuscripts_page_spec.js @@ -25,7 +25,7 @@ describe('manuscripts page tests', () => { it('evaluation button should be visible for unsubmitted articles', () => { ManuscriptsPage.clickSubmit() - NewSubmissionPage.clickSubmitUrlAndVerifyLink() + NewSubmissionPage.clickSubmitUrlAndWaitPageLoad() // fill the submit form and submit it // eslint-disable-next-line jest/valid-expect-in-promise cy.fixture('submission_form_data').then(data => { @@ -38,7 +38,7 @@ describe('manuscripts page tests', () => { }) it('label & topics should be visible on manuscripts page', () => { ManuscriptsPage.clickSubmit() - NewSubmissionPage.clickSubmitUrlAndVerifyLink() + NewSubmissionPage.clickSubmitUrlAndWaitPageLoad() // fill the submit form and submit it // eslint-disable-next-line jest/valid-expect-in-promise cy.fixture('submission_form_data').then(data => { @@ -58,7 +58,7 @@ describe('manuscripts page tests', () => { context('unsubmitted article tests', () => { beforeEach(() => { ManuscriptsPage.clickSubmit() - NewSubmissionPage.clickSubmitUrlAndVerifyLink() + NewSubmissionPage.clickSubmitUrlAndWaitPageLoad() }) it('unsubmitted article is evaluated', () => { @@ -106,7 +106,7 @@ describe('manuscripts page tests', () => { context('submitted and evaluated article tests', () => { beforeEach(() => { ManuscriptsPage.clickSubmit() - NewSubmissionPage.clickSubmitUrlAndVerifyLink() + NewSubmissionPage.clickSubmitUrlAndWaitPageLoad() // fill the submit form and submit it // eslint-disable-next-line jest/valid-expect-in-promise cy.fixture('submission_form_data').then(data => { @@ -178,7 +178,7 @@ describe('manuscripts page tests', () => { context('filter and sort articles', () => { beforeEach(() => { ManuscriptsPage.clickSubmit() - NewSubmissionPage.clickSubmitUrlAndVerifyLink() + NewSubmissionPage.clickSubmitUrlAndWaitPageLoad() // eslint-disable-next-line jest/valid-expect-in-promise cy.fixture('form_option').then(data => { SubmissionFormPage.fillInArticleDescription('123') @@ -189,7 +189,7 @@ describe('manuscripts page tests', () => { ) Menu.clickManuscriptsAndAssertPageLoad() ManuscriptsPage.clickSubmit() - NewSubmissionPage.clickSubmitUrlAndVerifyLink() + NewSubmissionPage.clickSubmitUrlAndWaitPageLoad() SubmissionFormPage.fillInArticleDescription('abc') SubmissionFormPage.clickElementFromFormOptionList(9) SubmissionFormPage.selectDropdownOption(1) @@ -201,7 +201,7 @@ describe('manuscripts page tests', () => { ) Menu.clickManuscriptsAndAssertPageLoad() ManuscriptsPage.clickSubmit() - NewSubmissionPage.clickSubmitUrlAndVerifyLink() + NewSubmissionPage.clickSubmitUrlAndWaitPageLoad() SubmissionFormPage.fillInArticleDescription('def') SubmissionFormPage.clickElementFromFormOptionList(9) SubmissionFormPage.selectDropdownOption(0) @@ -257,4 +257,14 @@ describe('manuscripts page tests', () => { ManuscriptsPage.getArticleTitleByRow(2).should('contain', 'def') }) }) + context('DOI validation', () => { + + it('message for DOI invalid is visible ', () => { + ManuscriptsPage.clickSubmit() + NewSubmissionPage.clickSubmitUrlAndWaitPageLoad() + SubmissionFormPage.fillInArticleUrl('google.com') + SubmissionFormPage.fillInArticleDescription('2') + SubmissionFormPage.getValidationErrorMessage('DOI is invalid') + }) + }) }) diff --git a/cypress/page-object/forms-page.js b/cypress/page-object/forms-page.js index 9cdd4ea3e050569a67ea3c83f25f9a77051eb574..a096180e774b41eb9f888b9287a4ffa5d3d34591 100644 --- a/cypress/page-object/forms-page.js +++ b/cypress/page-object/forms-page.js @@ -8,6 +8,8 @@ const FORM_OPTION_LIST = '[class*=FormBuilder__Element] > button:nth-child(1)' const NAME_FIELD = 'name' const COMPONENT_TYPE = '[role=listbox]' const FIELD_VALIDATE = '[class*=react-select__value-container]' +const DOI_VALIDATION = '[class*=RadioBox__RadioGroup]' +const UPDATE_FORM_BUTTON = '[type=submit]' export const FormsPage = { verifyPageLoaded() { @@ -38,6 +40,15 @@ export const FormsPage = { getFieldValidate() { return cy.get(FIELD_VALIDATE) }, + getDoiValidation(nth) { + return cy.get(DOI_VALIDATION).eq(nth).scrollIntoView() + }, + clickOptionsDoiVaildation(nth) { + this.getDoiValidation(nth).click() + }, + clickUpdateForm() { + return cy.get(UPDATE_FORM_BUTTON).click() + } } export default FormsPage diff --git a/cypress/page-object/new-submission-page.js b/cypress/page-object/new-submission-page.js index 14382a20df50125774045b5adf931bd4d0b1486e..9cadbc31d9f716e78a8d0eaf05b746d2186c9443 100644 --- a/cypress/page-object/new-submission-page.js +++ b/cypress/page-object/new-submission-page.js @@ -1,5 +1,6 @@ /// <reference types="Cypress" /> import { submit } from '../support/routes' +import { SubmissionFormPage } from './submission-form-page' /** * Page object representing the available submission options: @@ -22,9 +23,10 @@ export const NewSubmissionPage = { clickSubmitURL() { this.getSubmitURLButton().click() }, - clickSubmitUrlAndVerifyLink() { + clickSubmitUrlAndWaitPageLoad() { this.clickSubmitURL() - cy.url({ timeout: 15000 }).should('contain', submit) + cy.url({ timeout: 10000 }).should('contain', submit) + SubmissionFormPage.getPageTitle().should('be.visible') }, getSubmissionMessage() { return cy.get(SUBMISSION_MESSAGE).invoke('text') diff --git a/cypress/page-object/submission-form-page.js b/cypress/page-object/submission-form-page.js index 0c2408ab7c8d23330a6f3362e8b0fde3265bf4e1..538c5352fce51ba712e075fdcad9269153c5279c 100644 --- a/cypress/page-object/submission-form-page.js +++ b/cypress/page-object/submission-form-page.js @@ -7,6 +7,7 @@ import { ManuscriptsPage } from './manuscripts-page' * It contains various input fields & dropdowns, * listed in the same order they appear on the page. */ +const PAGE_TITLE = '[class*=style__Heading]' const ADD_A_LINK_BUTTON = 'li > button' const ENTER_URL_FIELD = 'submission.links.' const TITLE_FIELD = 'meta.title' @@ -57,6 +58,9 @@ const VALUE_ADDED_FIELD = 'submission.valueAdded' const TOPICS_CHECKBOX_LIST = 'submission.topics' export const SubmissionFormPage = { + getPageTitle() { + return cy.get(PAGE_TITLE, { timeout: 10000 }) + }, getAddLinkButton() { return cy.get(ADD_A_LINK_BUTTON) }, @@ -230,6 +234,9 @@ export const SubmissionFormPage = { getValidationErrorMessage(error) { return cy.getByContainsClass(VALIDATION_ERROR_MESSAGE).contains(error) }, + getValidationErrorMessage2() { + return cy.getByContainsClass(VALIDATION_ERROR_MESSAGE) + }, getFormOptionValue(nth) { return cy.getByContainsClass(FORM_OPTION_VALUE).eq(nth) },