Skip to content

Commit

Permalink
Remove bulk moderation modals in Cypress tests (#3769)
Browse files Browse the repository at this point in the history
* Try cypress unbind
* Accept modal confirm on submit
  • Loading branch information
dafeder committed Mar 21, 2022
1 parent 3f28b46 commit 9c88a5c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
3 changes: 3 additions & 0 deletions cypress/integration/07_admin_dataset_json_form.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ context('Admin dataset json form', () => {
cy.get('#edit-preview').should('not.exist')
})
cy.get('#edit-submit').click({ force:true })
cy.get('.button').contains('Yes').click({ force:true });
cy.get('.messages--status').should('contain','has been created')
// Confirm the default dkan admin view is filtered to show only datasets.
cy.visit(baseurl + "/admin/dkan/datasets")
Expand Down Expand Up @@ -75,13 +76,15 @@ context('Admin dataset json form', () => {
cy.get('#edit-preview').should('not.exist')
})
cy.get('#edit-submit').click({ force:true })
cy.get('.button').contains('Yes').click({ force:true });
cy.get('.messages--status').should('contain','has been updated')
// Delete dataset.
cy.visit(baseurl + "/admin/dkan/datasets")
cy.wait(2000)
cy.get('#edit-action').select('Delete content',{ force: true }).should('have.value', 'node_delete_action')
cy.get('#edit-node-bulk-form-0').check({ force:true })
cy.get('#edit-submit--2').click({ force:true })
cy.get('.button').contains('Yes').click({ force:true });
cy.get('input[value="Delete"]').click({ force:true })
cy.get('.messages').should('contain','Deleted 1 content item.')
})
Expand Down
7 changes: 5 additions & 2 deletions cypress/integration/08_admin_views.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,29 +56,32 @@ context('Admin content and dataset views', () => {
// Fill select2 field for publisher.
cy.get('#edit-field-json-metadata-0-value-publisher-publisher-name + .select2')
.find('.select2-selection')
.click({ force:true });
.click({ force:true })
cy.get('input[aria-controls="select2-edit-field-json-metadata-0-value-publisher-publisher-name-results"]').type('DKANTEST Publisher{enter}')
// End filling up publisher.
cy.get('#edit-field-json-metadata-0-value-contactpoint-contactpoint-fn').type('DKANTEST Contact Name', { force:true } )
cy.get('#edit-field-json-metadata-0-value-contactpoint-contactpoint-hasemail').type('dkantest@test.com', { force:true } )
// Fill select2 field for keyword.
cy.get('#edit-field-json-metadata-0-value-keyword-keyword-0 + .select2')
.find('.select2-selection')
.click({ force: true });
.click({ force: true })
cy.get('input[aria-controls="select2-edit-field-json-metadata-0-value-keyword-keyword-0-results"]').type('open data{enter}')
// End filling up keyword.
cy.get('#edit-submit').click({ force:true })
cy.get('.button').contains('Yes').click({ force:true })
cy.get('.messages--status').should('contain','has been created')
cy.visit(baseurl + "/admin/dkan/datasets")
cy.wait(2000)
cy.get('tbody > :nth-child(1) > .views-field-status').should('contain', 'Published')
cy.get('#edit-node-bulk-form-0').click({force:true})
cy.get('#edit-action').select('Archive current revision',{ force: true }).should('have.value', 'archive_current')
cy.get('#edit-submit--2').click({ force:true })
cy.get('.button').contains('Yes').click({ force:true });
cy.get('tbody > :nth-child(1) > .views-field-status').should('contain', 'Unpublished')
cy.get('#edit-node-bulk-form-0').click({force:true})
cy.get('#edit-action').select('Publish latest revision',{ force: true }).should('have.value', 'publish_latest')
cy.get('#edit-submit--2').click({ force:true })
cy.get('.button').contains('Yes').click({ force:true })
cy.get('tbody > :nth-child(1) > .views-field-status').should('contain', 'Published')
cy.get('tbody > :nth-child(1) > .views-field-nothing > a').invoke('attr', 'href').should('contain', '/edit')
cy.get('tbody > :nth-child(1) > .views-field-nothing > a').click({ force: true })
Expand Down
1 change: 1 addition & 0 deletions cypress/integration/10_workflow_transitions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ context('Draft datasets', () => {
cy.get('h1.page-title').should('contain', dataset_title)
cy.get('#edit-moderation-state-0-state').select('published')
cy.get('#edit-submit').click()
cy.get('.button').contains('Yes').click({ force:true })
cy.get('.messages--status').should('contain', 'has been updated')

// Ensure dataset is visible via public API with correct title
Expand Down
4 changes: 4 additions & 0 deletions cypress/integration/11_admin_dataset_file_upload.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ context('Admin dataset file upload', () => {
.type(fileUrl, { force:true })
cy.get('#edit-submit')
.click({ force:true })
cy.get('.button').contains('Yes')
.click({ force:true })
cy.get('.messages--status')
.should('contain','has been created')
})
Expand Down Expand Up @@ -117,6 +119,8 @@ context('Admin dataset file upload', () => {
.should('be.visible')
cy.get('#edit-submit')
.click({ force:true })
cy.get('.button').contains('Yes')
.click({ force:true })
cy.get('.messages--status')
.should('contain','has been created')
})
Expand Down
5 changes: 5 additions & 0 deletions cypress/support/helpers/dkan.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,11 @@ export function createDatasetWithModerationState(dataset_title, moderation_state
// End filling up keyword.
cy.get('#edit-submit')
.click({ force:true })
// Dialog will only show if we're using published, click yes.
if (moderation_state == 'published') {
cy.get('.button').contains('Yes')
.click({ force:true })
}
cy.get('.messages--status')
.should('contain','has been created')
cy.get('.messages--status a').click()
Expand Down

0 comments on commit 9c88a5c

Please sign in to comment.