Skip to content

Commit

Permalink
Merge pull request #1048 from usagov/stage
Browse files Browse the repository at this point in the history
Sprint 70 HOTFIX release
  • Loading branch information
rayestrada authored Oct 16, 2024
2 parents cd93b0e + 4975b65 commit 8d90156
Show file tree
Hide file tree
Showing 13 changed files with 386 additions and 164 deletions.
56 changes: 56 additions & 0 deletions docs/backend.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,47 @@ This site is built using Drupal and combination of modules and themes.
## Drupal
As of the writing of this document the foundation of the site is built using Drupal + Symphony + Composer. Drupal documentation can be found here: https://www.drupal.org/docs. This site follows Drupal coding standards and best practices.

### Drupal & Module Discovering Available Updates via Composer
Part of managing Drupal is keeping Drupal Core and Modules updated with latest versions to help alleviate potential security issues as well as providing users with the best experience offered.

To perform a simple audit of available updates you can use `composer outdated "drupal/*"` to see what updates are available by referring to the section, "Direct dependencies required in composer.json" located at the top of the output from the issued command. These are modules/pakages which we have specifically required as part of our project. The other listings under the section, "Transitive dependencies not required in composer.json" are dependencies added via our required modules.

If you ever need to track where a "Transitive dependency" is coming from you can issue the command `composer why {project/package}`. From there you will be given the package(s) which require this dependency.

### Updating Drupal via Composer
Drupal projects managed through Composer typically use `drupal/core-recommended`, which ensures that Drupal core and its dependencies are installed with secure and tested versions.

For ongoing updates we use the following command `composer update drupal/core-* -W` which will take care of both updating Drupal core and any dependencies that it may require. This will result in an updated `composer.lock` file which will be committed to the repository once the update has been tested locally.

Once updated, the following drush command should be issued, `drush updatedb && drush cr`. This will check for any pending database updates followed up by a clearing of the cache.

Run `drush cex`, to export and review any related configuration changes that is related to the update. Updates could affect other configurations such as field settings or other aspects of the site, so review carefully, test, and verify that the changes are valid.

Finally, use `git status` and `git diff {file_name}` to reveal and review both file and configuration changes before comitting them to your branch.

## Modules
Modules are located in `/web/modules/` directory. Each module has an module page located on https://www.drupal.org/project/project_module. The modules page include documentation, versions, change details and an issue queue. Also most modules contain additional details in a README file in the module root.

### Installing modules via Composer
To add modules, use the Composer `require` command. For example, to add the **Admin Toolbar** module:

`composer require drupal/admin_toolbar`

This will download the module and ensure it is included in your `composer.json` file, allowing it to be version-controlled and managed by Composer. Additionally this will update your `composer.lock` file which will reflect the details of installed packages and dependencies as it relates to the module being installed. These changes will, again, require you to commit the files to the repository once testing has been done locally.

### Updating modules via Composer
To update a specific module, for example, **Admin Toolbar**:

`composer update drupal/admin_toolbar`

This ensures that both the module and its dependencies are updated according to Drupal's compatibility guidelines.

Once updated, the following drush command should be issued, `drush updatedb && drush cr`. This will check for any pending database updates followed up by a clearing of the cache.

Run `drush cex`, to export and review any related configuration changes that is related to the module. Updates could affect other configurations such as field settings or other aspects of the site, so review carefully, test, and verify that the changes are valid.

Finally, use `git status` and `git diff {config_file.yml}` to reveal and review configuration changes that are located in `config/...` directory before comitting them to your branch.

### Contrib
I've included some of the non-standard Drupal contrib modules and their use below. To see all the modules in the system review the modules dashboard page located at `/admin/modules`. These modules are maintained by the Drupal community and have regular updates for enhancements and security patches.

Expand Down Expand Up @@ -67,18 +105,36 @@ Adds the ability to override a menu link per translation.
### Custom
Below is a list of custom modules created for use on Vote.gov. These modules can be found in the codebase at `/web/modules/custom`. These modules are maintained by project developers and need to be re-evaulated for each Drupal upgrade.

#### Embedded Content - Placeholder
Provides replacement placeholder for Ckeditor5 embedded content.

#### Embedded Content - Touchpoints survey
A CKEditor5 Embedded Content plugin that provides a means for embedding a Touchpoints survey in the wysiwyg.

#### Embedded Content - USWDS
Provides USWDS components for Ckeditor5 embedded content.

#### USAgov login
Adds the ability to disable the default Drupal login form and replace with a button to log in via SSO.

#### Vote Fields
Adds custom field types to use across content types and/or block types.

#### Vote NVRF
Provides custom functionality and handlers as it relates to the NVRF app.

#### Vote Users
Provides custom functionality regarding user accounts. Currently this simply enables or blocks users who have the Site Builder role when installed or uninstalled, respectively.

#### Vote utility
Provides custom token for use in pathauto settings. Adds the ability to limit the storage of block content revisions. Stores the source po files for importing string translations in the system.

## Module Patches
Review the details in composer.json file under `extra.patches` additionally look at the `/patches/` directory at the root. These patches need to be re-evaluated when the original module gets updated to determine if the work has been included in the latest release or if the patch needs to be rerolled.

## Repositories
In addition to Module Patches, it is worth reviewing the `repositories` section of the composer.json file. Here we can choose/define where a package is installed from (its source code). This can be used to reference another source which could serve as an alternative to the project's public main repository. So three may be instances where this section will need to be updated to add or remove a repository source for a given module or package.

## Database - Mysql
The site utilizes Mysql for its database.

Expand Down
38 changes: 27 additions & 11 deletions testing/cypress/e2e/backEndTests/basic-page.cy.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,43 @@
/// <reference types="cypress" />
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')
pageObjects
.urlAlias().click()
pageObjects
.urlAuto().click()
pageObjects
.setAlias().type('/cypress-url-alias-test')
})
cy.get('[data-drupal-selector="edit-submit"]').click()
pageObjects
.submitBtn().click()
cy.url().should('contain', 'cypress-url-alias-test')

cy.logout()

})
})
})
8 changes: 5 additions & 3 deletions testing/cypress/e2e/backEndTests/content-editor-access.cy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/// <reference types="cypress" />
import { pageObjects } from '../../support/pageObjects.js'

describe('Test Content Editor Role Access', () => {
beforeEach('login as content editor', () => {
Expand All @@ -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',
Expand Down Expand Up @@ -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')
})
})

})
})
11 changes: 7 additions & 4 deletions testing/cypress/e2e/backEndTests/content-manager-access.cy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// <reference types="cypress" />
/// <reference types="cypress" />
import { pageObjects } from '../../support/pageObjects.js'


describe('Test Content Manager Role Access', () => {
beforeEach('login as content manager', () => {
Expand Down Expand Up @@ -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)
})
Expand Down Expand Up @@ -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')
})
})
})
})
40 changes: 26 additions & 14 deletions testing/cypress/e2e/backEndTests/footer-menu-editor.cy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// <reference types="cypress" />

/// <reference types="cypress" />
import { pageObjects } from '../../support/pageObjects.js'

describe('Footer Menu Function', () => {

Expand All @@ -9,18 +9,25 @@ 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/')
cy.get('[data-drupal-selector="edit-menu-link-display-settings"]').click().get('[data-drupal-selector="edit-weight-0-value"]').clear().type('-99')


cy.get('[data-drupal-selector="edit-submit"]').click()
pageObjects
.linkTitle().type('Cypress Test Link')
pageObjects
.linkUrl().type('https://www.bixal.com/')
pageObjects
.displaySettings().click()
pageObjects
.linkWeight().clear().type('-99')

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')
})
Expand All @@ -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()

cy.get('[class="ui-dialog-buttonset form-actions"]').find('button').then(btn => {
pageObjects
.deleteBtn().click()

pageObjects
.confirmDelete()
.find('button').then(btn => {
cy.get(btn[0]).click()
})
})
Expand Down
15 changes: 9 additions & 6 deletions testing/cypress/e2e/backEndTests/site-admin-access.cy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// <reference types="cypress" />

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'))
Expand All @@ -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)
Expand All @@ -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)
})
Expand Down Expand Up @@ -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)
})
Expand All @@ -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')
})
})

})
})
Loading

0 comments on commit 8d90156

Please sign in to comment.