From fbbf1d06a35502e4595f69b4ecb5927e24c8eaba Mon Sep 17 00:00:00 2001 From: christian medders Date: Tue, 8 Oct 2024 12:58:53 -0400 Subject: [PATCH 1/4] init work --- .../cypress/e2e/backEndTests/basic-page.cy.js | 34 ++++++++++------ testing/cypress/support/pageObjects.js | 39 +++++++++++++++++-- 2 files changed, 58 insertions(+), 15 deletions(-) diff --git a/testing/cypress/e2e/backEndTests/basic-page.cy.js b/testing/cypress/e2e/backEndTests/basic-page.cy.js index b43668b69..c5dceb3f5 100644 --- a/testing/cypress/e2e/backEndTests/basic-page.cy.js +++ b/testing/cypress/e2e/backEndTests/basic-page.cy.js @@ -1,27 +1,39 @@ /// +import { pageObjects } from '../../support/pageObjects.js' describe('test for basic page', () => { + + beforeEach('visit site', () => { + cy.signin(Cypress.env('roles').site_admin.username, Cypress.env('test_pass')) + cy.visit('/node/add/page') + }) + it('test url alias', () => { - cy.signin(Cypress.env('roles').site_admin.username, Cypress.env('test_pass')) - + // Can set url alias - cy.visit('/node/add/page') - cy.get('[data-drupal-selector="edit-title-0-value"]').type('Test Page') - cy.get('[class="ck-blurred ck ck-content ck-editor__editable ck-rounded-corners ck-editor__editable_inline"]').then(field => { + pageObjects + .pageTitle() + .type('Test Page') + + // pageObjects + pageContent() + .then(field => { cy.get(field[0]).clear().realType('test page') }) - cy.get('[class="claro-details__summary claro-details__summary--accordion-item"]').then(dropdown => { + + // pageObjects + pageDetails().then(dropdown => { cy.get(dropdown[1]).click() - cy.get('[data-drupal-selector="edit-path-0"]').click() - cy.get('[data-drupal-selector="edit-path-0-pathauto"]').click() - cy.get('[data-drupal-selector="edit-path-0-alias"]').type('/cypress-url-alias-test') + urlAlias().click() + urlAuto().click() + setAlias().type('/cypress-url-alias-test') }) - cy.get('[data-drupal-selector="edit-submit"]').click() + submitBtn().click() cy.url().should('contain', 'cypress-url-alias-test') cy.logout() }) -}) \ No newline at end of file +}) diff --git a/testing/cypress/support/pageObjects.js b/testing/cypress/support/pageObjects.js index d76294a35..8e48fe435 100644 --- a/testing/cypress/support/pageObjects.js +++ b/testing/cypress/support/pageObjects.js @@ -1,5 +1,5 @@ class PageObjects { - // frontend test page objects + // frontend test page objects // * accessability tool bar themeSwitcher() { @@ -14,7 +14,7 @@ class PageObjects { return cy.get('[data-test="themeText"]') } - // * email signup + // * email signup emailSignup() { return cy.get('[data-test="emailSignup"]') } @@ -33,7 +33,7 @@ class PageObjects { return cy.get('[data-test="headerButton"]') } - headerBanner() { + headerBanner() { return cy.get('[data-test="headerBanner"]') } @@ -111,6 +111,37 @@ class PageObjects { return cy.get('[data-test="stateList"]') } + // Backend Tests + + // * Basic Page + pageTitle() { + return cy.get('[data-drupal-selector="edit-title-0-value"]') + } + + pageContent() { + return cy.get('[class="ck-blurred ck ck-content ck-editor__editable ck-rounded-corners ck-editor__editable_inline"]') + } + + pageDetails() { + return cy.get('[class="claro-details__summary claro-details__summary--accordion-item"]') + } + + urlAlias() { + return cy.get('[data-drupal-selector="edit-path-0"]') + } + + urlAuto() { + return cy.get('[data-drupal-selector="edit-path-0-pathauto"]') + } + + setAlias() { + return cy.get('[data-drupal-selector="edit-path-0-alias"]') + } + + submitBtn() { + return cy.get('[data-drupal-selector="edit-submit"]') + } + } -export const pageObjects = new PageObjects() \ No newline at end of file +export const pageObjects = new PageObjects() From cc26d8e4fbe1f9da6cf82439634b95f735f3e472 Mon Sep 17 00:00:00 2001 From: christian medders Date: Wed, 9 Oct 2024 09:01:27 -0400 Subject: [PATCH 2/4] saving work - footer menu --- .../cypress/e2e/backEndTests/basic-page.cy.js | 20 +++++++++++-------- .../backEndTests/content-editor-access.cy.js | 8 +++++--- .../backEndTests/content-manager-access.cy.js | 11 ++++++---- .../e2e/backEndTests/footer-menu-editor.cy.js | 12 +++++------ testing/cypress/support/pageObjects.js | 14 +++++++++++++ 5 files changed, 44 insertions(+), 21 deletions(-) diff --git a/testing/cypress/e2e/backEndTests/basic-page.cy.js b/testing/cypress/e2e/backEndTests/basic-page.cy.js index c5dceb3f5..64dfb09f6 100644 --- a/testing/cypress/e2e/backEndTests/basic-page.cy.js +++ b/testing/cypress/e2e/backEndTests/basic-page.cy.js @@ -17,20 +17,24 @@ describe('test for basic page', () => { .pageTitle() .type('Test Page') - // pageObjects - pageContent() + pageObjects + .pageContent() .then(field => { cy.get(field[0]).clear().realType('test page') }) - // pageObjects - pageDetails().then(dropdown => { + pageObjects + .pageDetails().then(dropdown => { cy.get(dropdown[1]).click() - urlAlias().click() - urlAuto().click() - setAlias().type('/cypress-url-alias-test') + pageObjects + .urlAlias().click() + pageObjects + .urlAuto().click() + pageObjects + .setAlias().type('/cypress-url-alias-test') }) - submitBtn().click() + pageObjects + .submitBtn().click() cy.url().should('contain', 'cypress-url-alias-test') cy.logout() diff --git a/testing/cypress/e2e/backEndTests/content-editor-access.cy.js b/testing/cypress/e2e/backEndTests/content-editor-access.cy.js index 2c81649c3..13e609c25 100644 --- a/testing/cypress/e2e/backEndTests/content-editor-access.cy.js +++ b/testing/cypress/e2e/backEndTests/content-editor-access.cy.js @@ -1,4 +1,5 @@ /// +import { pageObjects } from '../../support/pageObjects.js' describe('Test Content Editor Role Access', () => { beforeEach('login as content editor', () => { @@ -8,7 +9,7 @@ describe('Test Content Editor Role Access', () => { after('logout of content editor role', () => { cy.logout() }) - + it('verify access to email signup', () => { cy.request({ url: '/block/4', @@ -102,9 +103,10 @@ describe('Test Content Editor Role Access', () => { it('verify ability to publish', () => { cy.visit('/node/add/page') - cy.get('[data-drupal-selector="edit-moderation-state-0-state"]').find('option').then(option => { + pageObjects + .publishState().find('option').then(option => { cy.wrap(option).should('not.contain', 'Published') }) }) -}) \ No newline at end of file +}) diff --git a/testing/cypress/e2e/backEndTests/content-manager-access.cy.js b/testing/cypress/e2e/backEndTests/content-manager-access.cy.js index 5dcf22a4e..45df5bd26 100644 --- a/testing/cypress/e2e/backEndTests/content-manager-access.cy.js +++ b/testing/cypress/e2e/backEndTests/content-manager-access.cy.js @@ -1,4 +1,6 @@ -// +/// +import { pageObjects } from '../../support/pageObjects.js' + describe('Test Content Manager Role Access', () => { beforeEach('login as content manager', () => { @@ -33,7 +35,7 @@ describe('Test Content Manager Role Access', () => { cy.request('/node/63/edit').then((response) => { expect(response.status).to.eq(200) }) - + cy.request('/node/add/landing').then((response) => { expect(response.status).to.eq(200) }) @@ -78,8 +80,9 @@ describe('Test Content Manager Role Access', () => { it('verify ability to publish', () => { cy.visit('/node/add/page') - cy.get('[data-drupal-selector="edit-moderation-state-0-state"]').find('option').then(option => { + pageObjects + .publishState().find('option').then(option => { cy.wrap(option).should('contain', 'Published') }) }) -}) \ No newline at end of file +}) diff --git a/testing/cypress/e2e/backEndTests/footer-menu-editor.cy.js b/testing/cypress/e2e/backEndTests/footer-menu-editor.cy.js index 66ddae5cc..3847d6092 100644 --- a/testing/cypress/e2e/backEndTests/footer-menu-editor.cy.js +++ b/testing/cypress/e2e/backEndTests/footer-menu-editor.cy.js @@ -1,5 +1,5 @@ -// - +/// +import { pageObjects } from '../../support/pageObjects.js' describe('Footer Menu Function', () => { @@ -9,9 +9,9 @@ describe('Footer Menu Function', () => { cy.signin(Cypress.env('roles').site_admin.username, Cypress.env('test_pass')) cy.visit('/admin/structure/menu/manage/footer/add') - - cy.get('[data-drupal-selector="edit-title-0-value"]').type('Cypress Test Link') - cy.get('[data-drupal-selector="edit-link-0-uri"]').type('https://www.bixal.com/') + pageObjects + .linkTitle().type('Cypress Test Link') + .linkUrl().type('https://www.bixal.com/') cy.get('[data-drupal-selector="edit-menu-link-display-settings"]').click().get('[data-drupal-selector="edit-weight-0-value"]').clear().type('-99') @@ -32,7 +32,7 @@ describe('Footer Menu Function', () => { cy.get('[class="edit dropbutton__item dropbutton-action"]').then(dropDown => { cy.get(dropDown[0]).click() cy.get('[data-drupal-selector="edit-delete"]').click() - + cy.get('[class="ui-dialog-buttonset form-actions"]').find('button').then(btn => { cy.get(btn[0]).click() }) diff --git a/testing/cypress/support/pageObjects.js b/testing/cypress/support/pageObjects.js index 8e48fe435..467beede4 100644 --- a/testing/cypress/support/pageObjects.js +++ b/testing/cypress/support/pageObjects.js @@ -142,6 +142,20 @@ class PageObjects { return cy.get('[data-drupal-selector="edit-submit"]') } + // Content Editor, Manager Access + publishState() { + return cy.get('[data-drupal-selector="edit-moderation-state-0-state"]') + } + + // Footer Menu + linkTitle() { + return cy.get('[data-drupal-selector="edit-title-0-value"]') + } + + linkUrl() { + return cy.get('[data-drupal-selector="edit-link-0-uri"]') + } + } export const pageObjects = new PageObjects() From 42e4003acfa9f9823ddfe2682a686d218b4a773f Mon Sep 17 00:00:00 2001 From: christian medders Date: Thu, 10 Oct 2024 14:14:12 -0400 Subject: [PATCH 3/4] adding data-test attribute to twig file --- .../votegov/templates/navigation/menu-local-task.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/themes/custom/votegov/templates/navigation/menu-local-task.html.twig b/web/themes/custom/votegov/templates/navigation/menu-local-task.html.twig index e22b684f9..6e991f086 100644 --- a/web/themes/custom/votegov/templates/navigation/menu-local-task.html.twig +++ b/web/themes/custom/votegov/templates/navigation/menu-local-task.html.twig @@ -15,6 +15,6 @@ * @see template_preprocess_menu_local_task() */ #} - + {{ link['#title'] }} From dfed1dac221c371527f8d9f0c885bb3846445f8e Mon Sep 17 00:00:00 2001 From: christian medders Date: Thu, 10 Oct 2024 14:14:37 -0400 Subject: [PATCH 4/4] update to cypress tests --- .../e2e/backEndTests/footer-menu-editor.cy.js | 26 +- .../e2e/backEndTests/site-admin-access.cy.js | 15 +- .../backEndTests/user-content-access.cy.js | 256 +++++++++++------- testing/cypress/support/pageObjects.js | 76 ++++-- 4 files changed, 234 insertions(+), 139 deletions(-) diff --git a/testing/cypress/e2e/backEndTests/footer-menu-editor.cy.js b/testing/cypress/e2e/backEndTests/footer-menu-editor.cy.js index 3847d6092..485c1ad09 100644 --- a/testing/cypress/e2e/backEndTests/footer-menu-editor.cy.js +++ b/testing/cypress/e2e/backEndTests/footer-menu-editor.cy.js @@ -11,16 +11,23 @@ describe('Footer Menu Function', () => { cy.visit('/admin/structure/menu/manage/footer/add') pageObjects .linkTitle().type('Cypress Test Link') + pageObjects .linkUrl().type('https://www.bixal.com/') - cy.get('[data-drupal-selector="edit-menu-link-display-settings"]').click().get('[data-drupal-selector="edit-weight-0-value"]').clear().type('-99') - + pageObjects + .displaySettings().click() + pageObjects + .linkWeight().clear().type('-99') - cy.get('[data-drupal-selector="edit-submit"]').click() + pageObjects + .submitBtn().click() // check that the link is working as expected cy.visit('/') - cy.get('[data-test="footer"]').find('[data-test="footerLinks"]').then(link => { + pageObjects + .footer() + pageObjects + .footerLinks().then(link => { cy.get(link[0]).find('a').should('contain', 'Cypress Test Link') .should('have.attr', 'href').and('contain', 'bixal.com') }) @@ -29,11 +36,16 @@ describe('Footer Menu Function', () => { cy.visit('/admin/structure/menu/manage/footer') - cy.get('[class="edit dropbutton__item dropbutton-action"]').then(dropDown => { + pageObjects + .editDropdown() + .then(dropDown => { cy.get(dropDown[0]).click() - cy.get('[data-drupal-selector="edit-delete"]').click() + pageObjects + .deleteBtn().click() - cy.get('[class="ui-dialog-buttonset form-actions"]').find('button').then(btn => { + pageObjects + .confirmDelete() + .find('button').then(btn => { cy.get(btn[0]).click() }) }) diff --git a/testing/cypress/e2e/backEndTests/site-admin-access.cy.js b/testing/cypress/e2e/backEndTests/site-admin-access.cy.js index dc9652a36..495885989 100644 --- a/testing/cypress/e2e/backEndTests/site-admin-access.cy.js +++ b/testing/cypress/e2e/backEndTests/site-admin-access.cy.js @@ -1,5 +1,7 @@ // +import { pageObjects } from "../../support/pageObjects" + describe('Test Site Admin Role access', () => { beforeEach('login as site admin', () => { cy.signin(Cypress.env('roles').site_admin.username, Cypress.env('test_pass')) @@ -19,7 +21,7 @@ describe('Test Site Admin Role access', () => { cy.request('/block/1').then((response) => { expect(response.status).to.eq(200) }) - + // only site admin should be able to create banner cy.request('//block/add/government_banner').then((response) => { expect(response.status).to.eq(200) @@ -30,7 +32,7 @@ describe('Test Site Admin Role access', () => { cy.request('/node/63/edit').then((response) => { expect(response.status).to.eq(200) }) - + cy.request('/node/add/landing').then((response) => { expect(response.status).to.eq(200) }) @@ -59,8 +61,8 @@ describe('Test Site Admin Role access', () => { cy.request('/media/add').then((response) => { expect(response.status).to.eq(200) }) - - // admin cole should be able to delete + + // admin cole should be able to delete cy.request('/media/6/delete?').then((response) => { expect(response.status).to.eq(200) }) @@ -74,9 +76,10 @@ describe('Test Site Admin Role access', () => { it('verify ability to publish', () => { cy.visit('/node/add/page') - cy.get('[data-drupal-selector="edit-moderation-state-0-state"]').find('option').then(option => { + pageObjects + .publishState().find('option').then(option => { cy.wrap(option).should('contain', 'Published') }) }) -}) \ No newline at end of file +}) diff --git a/testing/cypress/e2e/backEndTests/user-content-access.cy.js b/testing/cypress/e2e/backEndTests/user-content-access.cy.js index 517313121..c990b3708 100644 --- a/testing/cypress/e2e/backEndTests/user-content-access.cy.js +++ b/testing/cypress/e2e/backEndTests/user-content-access.cy.js @@ -1,4 +1,6 @@ /// +import { pageObjects } from "../../support/pageObjects" + describe('Test User Role Access to Content Moderation', () => { @@ -7,70 +9,91 @@ describe('Test User Role Access to Content Moderation', () => { // Can create a draft cy.visit('/node/add/page') - cy.get('[data-drupal-selector="edit-title-0-value"]').type('Test Page') - - cy.get('[class="ck-blurred ck ck-content ck-editor__editable ck-rounded-corners ck-editor__editable_inline"]').then(field => { - cy.get(field[0]).clear().realType('test page') - }) - cy.get('[class="claro-details__summary claro-details__summary--accordion-item"]').then(dropdown => { - cy.get(dropdown[1]).click() - cy.get('[data-drupal-selector="edit-path-0"]').click() - cy.get('[data-drupal-selector="edit-path-0-pathauto"]').click() - cy.get('[data-drupal-selector="edit-path-0-alias"]').type('/cypress-content-moderation-test') - }) - cy.get('[data-drupal-selector="edit-submit"]').click() + pageObjects + .pageTitle().type('Test Page') + + pageObjects + .pageContent().then(field => { + cy.get(field[0]).clear().realType('test page') + }) + + pageObjects + .pageDetails().then(dropdown => { + cy.get(dropdown[1]).click() + pageObjects + .urlAlias().click() + pageObjects + .urlAuto().click() + pageObjects + .setAlias().type('/cypress-content-moderation-test') + }) + pageObjects + .submitBtn().click() cy.url().should('contain', 'cypress-content-moderation-test') - // Can view draft content + // Can view draft content cy.request('/cypress-content-moderation-test').then((response) => { - expect(response.status).to.eq(200)}) - + expect(response.status).to.eq(200) + }) + // Can modify draft content cy.visit('/cypress-content-moderation-test') - cy.get('[class="usa-button-group__item"]').then(btn => { - cy.get(btn[1]).click() - }) + pageObjects + .editBar().then(btn => { + cy.get(btn[1]).click() + }) cy.url().should('contain', 'edit') // Can publish content cy.visit('/cypress-content-moderation-test') - cy.get('[data-drupal-selector="edit-new-state"]').select('Published') - cy.get('[data-drupal-selector="edit-submit"]').click() + pageObjects + .publishOpt().select('Published') + pageObjects + .submitBtn().click() cy.get('[class="usa-alert__body"]').should('contain', 'The moderation state has been updated.') - // Can move content to archived status + // Can move content to archived status cy.visit('/cypress-content-moderation-test') - cy.get('[class="usa-button-group__item"]').then(btn => { - cy.get(btn[1]).click() - }) - cy.get('[data-drupal-selector="edit-moderation-state-0-state"]').select('Archived') - cy.get('[data-drupal-selector="edit-submit"]').click() + pageObjects + .editBar().then(btn => { + cy.get(btn[1]).click() + }) + pageObjects + .publishState().select('Archived') + pageObjects + .submitBtn().click() cy.get('[id="edit-current"]').should('contain', 'Archived') // Can move archived content to draft cy.visit('/cypress-content-moderation-test') - cy.get('[data-drupal-selector="edit-new-state"]').select('Draft') - cy.get('[data-drupal-selector="edit-submit"]').click() + pageObjects + .publishOpt().select('Draft') + pageObjects + .submitBtn().click() cy.get('[id="edit-current"]').should('contain', 'Draft') // Can delete content cy.visit('/cypress-content-moderation-test') - cy.get('[class="usa-button-group__item"]').then(btn => { - cy.get(btn[2]).click() - }) + pageObjects + .editBar().then(btn => { + cy.get(btn[2]).click() + }) cy.get('[class="page-title"]').should('contain', 'delete') // Can create and delete media cy.request('/admin/structure/media/add').then((response) => { - expect(response.status).to.eq(200)}) + expect(response.status).to.eq(200) + }) cy.visit('/admin/content/media') - cy.get('[class="edit dropbutton__item dropbutton-action"]').should('contain', 'Edit') + pageObjects + .editDropdown().should('contain', 'Edit') - // Can update the content moderation settings - cy.request('/admin/config/workflow/workflows/manage/publishing_content').then((response) => { - expect(response.status).to.eq(200)}) + // Can update the content moderation settings + cy.request('/admin/config/workflow/workflows/manage/publishing_content').then((response) => { + expect(response.status).to.eq(200) + }) - cy.logout() + cy.logout() }) it('Test Content Manager', () => { @@ -78,60 +101,75 @@ describe('Test User Role Access to Content Moderation', () => { // Can create a draft cy.visit('/node/add/page') - cy.get('[data-drupal-selector="edit-title-0-value"]').type('Test Page') + pageObjects + .pageTitle().type('Test Page') - cy.get('[class="ck-blurred ck ck-content ck-editor__editable ck-rounded-corners ck-editor__editable_inline"]').then(field => { - cy.get(field[0]).clear().realType('test page') - }) + pageObjects + .pageContent().then(field => { + cy.get(field[0]).clear().realType('test page') + }) - cy.get('[data-drupal-selector="edit-submit"]').click() + pageObjects + .submitBtn().click() cy.url().should('contain', 'test-page') - // Can view draft content + // Can view draft content cy.request('/test-page').then((response) => { - expect(response.status).to.eq(200)}) - + expect(response.status).to.eq(200) + }) + // Can modify draft content cy.visit('/test-page') - cy.get('[class="usa-button-group__item"]').then(btn => { - cy.get(btn[1]).click() - }) + pageObjects + .editBar().then(btn => { + cy.get(btn[1]).click() + }) cy.url().should('contain', 'edit') // Can publish content cy.visit('/test-page') - cy.get('[data-drupal-selector="edit-new-state"]').select('Published') - cy.get('[data-drupal-selector="edit-submit"]').click() + pageObjects + .publishOpt().select('Published') + pageObjects + .submitBtn().click() cy.get('[class="usa-alert__body"]').should('contain', 'The moderation state has been updated.') - // Can move content to archived status + // Can move content to archived status cy.visit('/test-page') - cy.get('[class="usa-button-group__item"]').then(btn => { - cy.get(btn[1]).click() - }) - cy.get('[data-drupal-selector="edit-moderation-state-0-state"]').select('Archived') - cy.get('[data-drupal-selector="edit-submit"]').click() + pageObjects + .editBar().then(btn => { + cy.get(btn[1]).click() + }) + pageObjects + .publishState().select('Archived') + pageObjects + .submitBtn().click() cy.get('[id="edit-current"]').should('contain', 'Archived') // Can move archived content to draft cy.visit('/test-page') - cy.get('[data-drupal-selector="edit-new-state"]').select('Draft') - cy.get('[data-drupal-selector="edit-submit"]').click() + pageObjects + .publishOpt().select('Draft') + pageObjects + .submitBtn().click() cy.get('[id="edit-current"]').should('contain', 'Draft') // Can delete content cy.visit('/test-page') - cy.get('[class="usa-button-group__item"]').then(btn => { - cy.get(btn[2]).click() - }) + pageObjects + .editBar().then(btn => { + cy.get(btn[2]).click() + }) cy.get('[class="page-title"]').should('contain', 'delete') // Can create and delete media cy.request('/media/add').then((response) => { - expect(response.status).to.eq(200)}) + expect(response.status).to.eq(200) + }) cy.visit('/admin/content/media') - cy.get('[class="edit dropbutton__item dropbutton-action"]').should('contain', 'Edit') + pageObjects + .editDropdown().should('contain', 'Edit') // should not be able to update the content moderation settings cy.request({ @@ -149,56 +187,70 @@ describe('Test User Role Access to Content Moderation', () => { // Can create a draft cy.visit('/node/add/page') - cy.get('[data-drupal-selector="edit-title-0-value"]').type('Test Page') - - cy.get('[class="ck-blurred ck ck-content ck-editor__editable ck-rounded-corners ck-editor__editable_inline"]').then(field => { - cy.get(field[0]).clear().realType('test page') - }) - cy.get('[data-drupal-selector="edit-submit"]').click() + pageObjects + .pageTitle().type('Test Page') + + pageObjects + .pageContent().then(field => { + cy.get(field[0]).clear().realType('test page') + }) + pageObjects + .submitBtn().click() cy.url().should('contain', 'test') - // Can view own draft content + // Can view own draft content cy.request('/test-page').then((response) => { - expect(response.status).to.eq(200)}) + expect(response.status).to.eq(200) + }) // can view other draft content cy.request('/cypress-content-moderation-test').then((response) => { - expect(response.status).to.eq(200)}) - - // Can modify draft content - cy.visit('/test-page-0') - cy.get('[class="usa-button-group__item"]').then(btn => { - cy.get(btn[1]).click() + expect(response.status).to.eq(200) }) + + // Can modify draft content + cy.visit('/test-page-0') + pageObjects + .editBar().then(btn => { + cy.get(btn[1]).click() + }) cy.url().should('contain', 'edit') - + // Can not publish content cy.visit('/test-page-0') - cy.get('[data-drupal-selector="edit-submit"]').should('not.exist') + pageObjects + .submitBtn().should('not.exist') // can view archived content cy.request('/admin/content/moderated').then((response) => { - expect(response.status).to.eq(200)}) + expect(response.status).to.eq(200) + }) // Can move archived content to draft cy.visit('/cypress-content-moderation-test') - cy.get('[class="usa-button-group__item"]').then(btn => { - cy.get(btn[1]).click() - }) - cy.get('[data-drupal-selector="edit-submit"]').click() + pageObjects + .editBar().then(btn => { + cy.get(btn[1]).click() + }) + pageObjects + .submitBtn().click() // Can not delete content cy.visit('/admin/content') - cy.get('[class="dropbutton__toggle"]').then(btn => { - cy.get(btn[0]).click() - }) - cy.get('[class="translate dropbutton__item dropbutton-action secondary-action"]').should('not.contain', 'delete') + pageObjects + .editDropDown().then(btn => { + cy.get(btn[0]).click() + }) + pageObjects + .editOpt().should('not.contain', 'delete') // Can create media but not delete media cy.request('/media/add').then((response) => { - expect(response.status).to.eq(200)}) + expect(response.status).to.eq(200) + }) cy.visit('/admin/content/media') - cy.get('[class="translate dropbutton__item dropbutton-action"]').should('not.contain', 'edit') + pageObjects + .editOpt().should('not.contain', 'edit') // should not be able to update the content moderation settings cy.request({ @@ -211,28 +263,28 @@ describe('Test User Role Access to Content Moderation', () => { cy.logout() }) - // ! commenting out this test for the time being until content is published. it('test anonymous user access', () => { - // Can view published content - cy.request('/').then((response) => { - expect(response.status).to.eq(200)}) + // Can view published content + cy.request('/').then((response) => { + expect(response.status).to.eq(200) + }) - // Can not view draft content + // Can not view draft content cy.request({ url: '/cypress-content-moderation-test', - failOnStatusCode:false, - }).then((resp) => { + failOnStatusCode: false, + }).then((resp) => { expect(resp.status).to.eq(403) - }) + }) - // can not view archived content + // can not view archived content cy.request({ url: '/admin/content/moderated', - failOnStatusCode:false, - }).then((resp) => { + failOnStatusCode: false, + }).then((resp) => { expect(resp.status).to.eq(403) - }) + }) }) }) diff --git a/testing/cypress/support/pageObjects.js b/testing/cypress/support/pageObjects.js index 467beede4..cccec506b 100644 --- a/testing/cypress/support/pageObjects.js +++ b/testing/cypress/support/pageObjects.js @@ -1,7 +1,13 @@ class PageObjects { // frontend test page objects + footer() { + return cy.get('[data-test="footer"]') + } + + footerLinks() { + return cy.get('[data-test="footerLinks"]') + } - // * accessability tool bar themeSwitcher() { return cy.get('[data-test="themeSwitcher"]') } @@ -11,20 +17,17 @@ class PageObjects { } themeText() { - return cy.get('[data-test="themeText"]') + return cy.get('[data-test="themeText"]') } - // * email signup emailSignup() { return cy.get('[data-test="emailSignup"]') } - // * footer contact footerContact() { return cy.get('[data-test="footerContact"]') } - // * govt banner headerLogo() { return cy.get('[data-test="headerLogo"]') } @@ -37,7 +40,6 @@ class PageObjects { return cy.get('[data-test="headerBanner"]') } - // * language selector languageButton() { return cy.get('[data-test="languageButton"]') } @@ -50,7 +52,6 @@ class PageObjects { return cy.get('[ data-test="langItem"]') } - // * main menu mainNav() { return cy.get('[data-test="mainNav"]') } @@ -79,12 +80,10 @@ class PageObjects { return cy.get('[data-test="mainCloseBtn"]') } - // * nvrf download nvrfDownload() { return cy.get('[data-test="nvrfDownload"]') } - // * search bar searchBox() { return cy.get('[data-test="searchBox"]') } @@ -93,7 +92,6 @@ class PageObjects { return cy.get('[data-test="searchBtn"]') } - // * state pages registrationInfo() { return cy.get('[data-test="registrationInfo"]') } @@ -102,7 +100,6 @@ class PageObjects { return cy.get('[data-test="nvrfForm"]') } - // * state registration stateInput() { return cy.get('[data-test="stateInput"]') } @@ -112,8 +109,6 @@ class PageObjects { } // Backend Tests - - // * Basic Page pageTitle() { return cy.get('[data-drupal-selector="edit-title-0-value"]') } @@ -142,20 +137,53 @@ class PageObjects { return cy.get('[data-drupal-selector="edit-submit"]') } - // Content Editor, Manager Access - publishState() { - return cy.get('[data-drupal-selector="edit-moderation-state-0-state"]') - } + publishState() { + return cy.get('[data-drupal-selector="edit-moderation-state-0-state"]') + } - // Footer Menu - linkTitle() { - return cy.get('[data-drupal-selector="edit-title-0-value"]') - } + linkTitle() { + return cy.get('[data-drupal-selector="edit-title-0-value"]') + } - linkUrl() { - return cy.get('[data-drupal-selector="edit-link-0-uri"]') - } + linkUrl() { + return cy.get('[data-drupal-selector="edit-link-0-uri"]') + } + + displaySettings() { + return cy.get('[data-drupal-selector="edit-menu-link-display-settings"]') + } + linkWeight() { + return cy.get('[data-drupal-selector="edit-weight-0-value"]') + } + + editDropdown() { + return cy.get('[class="edit dropbutton__item dropbutton-action"]') + } + + deleteBtn() { + return cy.get('[data-drupal-selector="edit-delete"]') + } + + confirmDelete() { + return cy.get('[class="ui-dialog-buttonset form-actions"]') + } + + editBar() { + return cy.get('[data-test="editMenu"]') + } + + publishOpt() { + return cy.get('[data-drupal-selector="edit-new-state"]') + } + + editDropDown() { + return cy.get('[class="dropbutton__toggle"]') + } + + editOpt() { + return cy.get('[class="translate dropbutton__item dropbutton-action"]') + } } export const pageObjects = new PageObjects()