Skip to content
Snippets Groups Projects
Commit 4f8400f8 authored by sebastianrad's avatar sebastianrad
Browse files

test: add tests for doi validation

parent 877759e1
No related branches found
No related tags found
No related merge requests found
......@@ -9,5 +9,4 @@
"logoPath": "/public/logo-ncrc.jpg",
"brandName": "Novel Coronavirus Research Compendium"
}
}
\ No newline at end of file
}
......@@ -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', () => {
......
......@@ -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')
})
})
})
......@@ -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', () => {
}
})
})
})
})
......@@ -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')
})
})
})
......@@ -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
/// <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')
......
......@@ -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)
},
......
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