From 5ce4db32bfb9d3f1bd51d7b3b9a15c5f1d8bc9d7 Mon Sep 17 00:00:00 2001 From: Nate Douglas Date: Wed, 20 Apr 2022 15:39:29 -0400 Subject: [PATCH 1/7] VACMS-8519: Adds test coverage for file upload. (#8824) --- .../integration/common/i_create_a_node.js | 28 +++++++++++++++++++ .../integration/common/i_should_see.js | 9 ++++++ .../cypress/integration/file_upload.feature | 11 ++++++++ 3 files changed, 48 insertions(+) create mode 100644 tests/behavioral/cypress/integration/file_upload.feature diff --git a/tests/behavioral/cypress/integration/common/i_create_a_node.js b/tests/behavioral/cypress/integration/common/i_create_a_node.js index 59e90f257b5..23d3f8995e9 100644 --- a/tests/behavioral/cypress/integration/common/i_create_a_node.js +++ b/tests/behavioral/cypress/integration/common/i_create_a_node.js @@ -11,6 +11,34 @@ const creators = { cy.findAllByLabelText('Parent link').select('-- CMS Knowledge Base (disabled)', { force: true }); return cy.get('form.node-form').find('input#edit-submit').click(); }, + event: () => { + cy.visit('/node/add/event'); + cy.scrollTo('top'); + cy.findAllByLabelText('Name').type('[Test Data] ' + faker.lorem.sentence(), { force: true }); + cy.get('#edit-field-datetime-range-timezone-0-value-date').type('2023-12-05', { force: true }); + cy.get('#edit-field-datetime-range-timezone-0-value-time').type('12:00', { force: true }); + cy.findAllByLabelText('Where should the event be listed?').select('VA Alaska health care: Events', { force: true }); + cy.findAllByLabelText('Street address').type(faker.address.streetAddress(), { force: true }); + cy.findAllByLabelText('City').type(faker.address.city(), { force: true }); + cy.findAllByLabelText('State').select('Alabama', { force: true }); + cy.findAllByLabelText('Section').select('VACO', { force: true }); + cy.scrollToSelector('#edit-field-media-open-button'); + cy.get('#edit-field-media-open-button').click({ force: true }); + cy.get('.dropzone', { + timeout: 10000, + }); + cy.get('.dropzone').attachFile('images/polygon_image.png', { + subjectType: 'drag-n-drop', + }); + cy.wait(1000); + cy.findAllByLabelText('Alternative text').type(faker.lorem.sentence(), { force: true }); + cy.get('[data-drupal-selector="edit-media-0-fields-field-owner"]').select('VACO', { force: true }); + cy.get('button').contains('Save and insert').click({ force: true }); + cy.get('div.media-library-item[data-drupal-selector="edit-field-media-selection-0"]', { + timeout: 15000, + }); + return cy.get('form.node-form').find('input#edit-submit').click(); + }, health_care_region_detail_page: () => { cy.visit('/node/add/health_care_region_detail_page'); cy.scrollTo('top'); diff --git a/tests/behavioral/cypress/integration/common/i_should_see.js b/tests/behavioral/cypress/integration/common/i_should_see.js index 22bd3acfa50..2952689c89a 100644 --- a/tests/behavioral/cypress/integration/common/i_should_see.js +++ b/tests/behavioral/cypress/integration/common/i_should_see.js @@ -12,3 +12,12 @@ Then('I should not see an element with the xpath {string}', (expression) => cy.x Then('I should see xpath {string}', (expression) => cy.xpath(expression).should('exist')); Then('I should not see xpath {string}', (expression) => cy.xpath(expression).should('not.exist')); + +Then('I should see an image with the selector {string}', (selector) => { + cy.get(selector) + .should('be.visible') + .and(($img) => { + expect($img[0].naturalWidth).to.be.greaterThan(0); + expect($img[0].naturalHeight).to.be.greaterThan(0); + }); +}); diff --git a/tests/behavioral/cypress/integration/file_upload.feature b/tests/behavioral/cypress/integration/file_upload.feature new file mode 100644 index 00000000000..d39de0eea3a --- /dev/null +++ b/tests/behavioral/cypress/integration/file_upload.feature @@ -0,0 +1,11 @@ +@file_upload +Feature: Files can be uploaded and attached to nodes successfully + In order to reliably and predictably create content + As anybody involved in the project + I need to be able to upload and attach files to nodes. + + Scenario: We should be able to attach files to event nodes. + Given I am logged in as a user with the "content_admin" role + When I create a "event" node + Then I should see "polygon_image.png" + And I should see an image with the selector 'div.field--name-image a img' From 190613730666e8c80aa28b510411c5eeb6daef2a Mon Sep 17 00:00:00 2001 From: Wang Date: Wed, 20 Apr 2022 19:24:34 -0400 Subject: [PATCH 2/7] DR-901: change gitignore, change htacciess, change settings.php. --- .gitignore | 4 ++++ docroot/.htaccess | 14 +++++++++----- docroot/sites/default/settings.php | 18 +++++++++++++++++- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 94b97bb37a6..2ef06235aa4 100644 --- a/.gitignore +++ b/.gitignore @@ -99,3 +99,7 @@ datadog-setup.php # Key files *.key + +*.sql +*.sql.gz + diff --git a/docroot/.htaccess b/docroot/.htaccess index 5f2d1f8fdbc..2a4cc6988ee 100644 --- a/docroot/.htaccess +++ b/docroot/.htaccess @@ -13,15 +13,19 @@ Require all denied +#### Gung: not working on Ubuntu Apache. #### # If requested file or directory exists, skip the next rule. -RewriteCond %{DOCUMENT_ROOT}/$1 -f [OR] -RewriteCond %{DOCUMENT_ROOT}/$1 -d -RewriteRule (.*) - [S=1] +# RewriteCond %{DOCUMENT_ROOT}/$1 -f [OR] +# RewriteCond %{DOCUMENT_ROOT}/$1 -d +# RewriteRule (.*) - [S=1] + +#### Gung: not working on Ubuntu Apache. #### # If requested file exists in /static, rewrite to /static # Using only files here ensures the paths still resolve to Drupal and not to the index.html files. -RewriteCond %{DOCUMENT_ROOT}/static/$1 -f -RewriteRule (.*) /static/$1 [L] +# RewriteCond %{DOCUMENT_ROOT}/static/$1 -f +# RewriteRule (.*) /static/$1 [L] + # Protect files and directories from prying eyes. diff --git a/docroot/sites/default/settings.php b/docroot/sites/default/settings.php index b33662c69f3..ced8c703483 100755 --- a/docroot/sites/default/settings.php +++ b/docroot/sites/default/settings.php @@ -19,7 +19,7 @@ 'password' => getenv('CMS_MARIADB_PASSWORD') ?: 'drupal8', 'prefix' => '', // 'database' is the default DB container for Lando (local). - 'host' => getenv('CMS_MARIADB_HOST') ?: 'database', + 'host' => getenv('CMS_MARIADB_HOST') ?: 'localhost', 'port' => 3306, 'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql', ); @@ -248,3 +248,19 @@ $settings['container_yamls'][] = $app_root . '/' . $site_path . '/../default/services/services.memcache.yml'; $settings['memcache']['persistent'] = 'drupal'; } + +$settings['trusted_host_patterns'] = [ + '^loalhost$', + '^drupal-react\.test$', +]; + +ini_set('memory_limit', '512M'); + +/* + _core: + default_config_hash: yXadRE77Va-G6dxhd2kPYapAvbnSvTF6hO4oXiOEynI +langcode: en +uuid: 45814d2f-3e31-4878-aa12-733ea60ff326 + + + */ From bcdf3f4563ec79a128492c56f378591e15793691 Mon Sep 17 00:00:00 2001 From: Wang Date: Wed, 20 Apr 2022 20:13:01 -0400 Subject: [PATCH 3/7] DR-901: change settings.php. --- docroot/sites/default/settings.php | 9 --------- 1 file changed, 9 deletions(-) diff --git a/docroot/sites/default/settings.php b/docroot/sites/default/settings.php index ced8c703483..44fe53206f4 100755 --- a/docroot/sites/default/settings.php +++ b/docroot/sites/default/settings.php @@ -255,12 +255,3 @@ ]; ini_set('memory_limit', '512M'); - -/* - _core: - default_config_hash: yXadRE77Va-G6dxhd2kPYapAvbnSvTF6hO4oXiOEynI -langcode: en -uuid: 45814d2f-3e31-4878-aa12-733ea60ff326 - - - */ From eb888453e4e422d8f7be2041f26e56dc86f8c610 Mon Sep 17 00:00:00 2001 From: Wang Date: Wed, 20 Apr 2022 21:15:49 -0400 Subject: [PATCH 4/7] DR-901: Fix config import errors, non-existent services about va_gov*. --- docroot/modules/custom/va_gov_backend/va_gov_backend.module | 5 +++++ .../va_gov_build_trigger/va_gov_build_trigger.services.yml | 6 +++--- .../custom/va_gov_workflow/va_gov_workflow.services.yml | 6 +++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/docroot/modules/custom/va_gov_backend/va_gov_backend.module b/docroot/modules/custom/va_gov_backend/va_gov_backend.module index 99844a77ef0..6d69d87dff6 100644 --- a/docroot/modules/custom/va_gov_backend/va_gov_backend.module +++ b/docroot/modules/custom/va_gov_backend/va_gov_backend.module @@ -1517,6 +1517,11 @@ function _va_gov_backend_gtm_settings() { if ($uid > 0) { $sections['userId'] = Crypt::hashBase64((string) $uid); $section_scheme = \Drupal::entityTypeManager()->getStorage('access_scheme')->load('section'); + + // Gung: fix the fatal error of TypeError: getUserSections(). + if (!$section_scheme instanceof AccessSchemeInterface) { + return $sections; + } $user_sections = \Drupal::service('workbench_access.user_section_storage')->getUserSections($section_scheme, $user); if (in_array('administration', $user_sections)) { $sections['userSections'] = 'all'; diff --git a/docroot/modules/custom/va_gov_build_trigger/va_gov_build_trigger.services.yml b/docroot/modules/custom/va_gov_build_trigger/va_gov_build_trigger.services.yml index 3d0d242751b..aae635b1da2 100644 --- a/docroot/modules/custom/va_gov_build_trigger/va_gov_build_trigger.services.yml +++ b/docroot/modules/custom/va_gov_build_trigger/va_gov_build_trigger.services.yml @@ -21,6 +21,9 @@ services: class: GuzzleHttp\HandlerStack factory: ['Drupal\va_gov_build_trigger\Service\MiddlewareFactory', 'createHandlerStack'] arguments: ['@logger.channel.va_gov_build_trigger'] + va_gov.build_trigger.environment_discovery: + class: Drupal\va_gov_build_trigger\Environment\EnvironmentDiscovery + arguments: [ '@plugin.manager.va_gov.environment' ] va_gov_build_trigger.build_frontend: class: Drupal\va_gov_build_trigger\Service\BuildFrontend arguments: ['@messenger', '@logger.factory', '@va_gov.build_trigger.web_build_status', '@va_gov.build_trigger.environment_discovery', '@current_user'] @@ -35,9 +38,6 @@ services: arguments: ['@state'] va_gov.build_trigger.web_build_link_checker: class: Drupal\va_gov_build_trigger\WebBuildBrokenLinkChecker - va_gov.build_trigger.environment_discovery: - class: Drupal\va_gov_build_trigger\Environment\EnvironmentDiscovery - arguments: [ '@plugin.manager.va_gov.environment' ] plugin.manager.va_gov.environment: class: Drupal\va_gov_build_trigger\Environment\EnvironmentManager parent: default_plugin_manager diff --git a/docroot/modules/custom/va_gov_workflow/va_gov_workflow.services.yml b/docroot/modules/custom/va_gov_workflow/va_gov_workflow.services.yml index 35c452bb496..61f6c0865ad 100644 --- a/docroot/modules/custom/va_gov_workflow/va_gov_workflow.services.yml +++ b/docroot/modules/custom/va_gov_workflow/va_gov_workflow.services.yml @@ -1,12 +1,12 @@ services: + va_gov_workflow.flagger: + class: Drupal\va_gov_workflow\Service\Flagger + arguments: ['@flag', '@entity_type.manager'] va_gov_workflow.entity_event_subscriber: class: Drupal\va_gov_workflow\EventSubscriber\EntityEventSubscriber arguments: [ '@va_gov_user.user_perms', '@va_gov_workflow.workflow_content_control', '@va_gov_workflow.flagger'] tags: - { name: event_subscriber } - va_gov_workflow.flagger: - class: Drupal\va_gov_workflow\Service\Flagger - arguments: ['@flag', '@entity_type.manager'] va_gov_workflow.workflow_content_control: class: Drupal\va_gov_workflow\Service\WorkflowContentControl arguments: ['@va_gov_user.user_perms'] From a56fbc57ebbaf92c927aaa63725171bc23c60012 Mon Sep 17 00:00:00 2001 From: Wang Date: Wed, 20 Apr 2022 21:17:01 -0400 Subject: [PATCH 5/7] DR-901: Fix the fatal error, TypeError: getUserSections() in va_gov_backend.module. --- docroot/modules/custom/va_gov_backend/va_gov_backend.module | 1 + 1 file changed, 1 insertion(+) diff --git a/docroot/modules/custom/va_gov_backend/va_gov_backend.module b/docroot/modules/custom/va_gov_backend/va_gov_backend.module index 6d69d87dff6..2d0d3fec766 100644 --- a/docroot/modules/custom/va_gov_backend/va_gov_backend.module +++ b/docroot/modules/custom/va_gov_backend/va_gov_backend.module @@ -1522,6 +1522,7 @@ function _va_gov_backend_gtm_settings() { if (!$section_scheme instanceof AccessSchemeInterface) { return $sections; } + $user_sections = \Drupal::service('workbench_access.user_section_storage')->getUserSections($section_scheme, $user); if (in_array('administration', $user_sections)) { $sections['userSections'] = 'all'; From b11d5fea1983bde9132fee13ea8aa699230f5d7e Mon Sep 17 00:00:00 2001 From: Wang Date: Wed, 20 Apr 2022 21:24:58 -0400 Subject: [PATCH 6/7] DR-901: Fix the fatal error, Argument 1 passed to __construct() must be an instance of Drupal\migrate\Plugin\MigrationInterface. --- .../custom/va_gov_migrate/va_gov_migrate.install | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/docroot/modules/custom/va_gov_migrate/va_gov_migrate.install b/docroot/modules/custom/va_gov_migrate/va_gov_migrate.install index bacee4bc195..9145a4a8fa0 100644 --- a/docroot/modules/custom/va_gov_migrate/va_gov_migrate.install +++ b/docroot/modules/custom/va_gov_migrate/va_gov_migrate.install @@ -141,10 +141,14 @@ function _va_gov_migrate_add_nodes_to_migrate_map(string $migration_name, array // Table does not exist yet so make it. $migration = \Drupal::getContainer()->get('plugin.manager.migration')->createInstance($migration_name); // Migrate just 1 item so the migrate map gets built. - $executable = new MigrateExecutable($migration, new MigrateMessage(), ['limit' => 1]); - $executable->import(); - // Roll it back so it does not exist. - $executable->rollback(); + + if($migration instanceof MigrationInterface) { + + $executable = new MigrateExecutable($migration, new MigrateMessage(), ['limit' => 1]); + $executable->import(); + // Roll it back so it does not exist. + $executable->rollback(); + } } foreach ($nodes_to_be_migratized as $values) { From 8d1612809eda4d8c1ed3baa6a811742f16280b1f Mon Sep 17 00:00:00 2001 From: Wang Date: Wed, 20 Apr 2022 21:28:31 -0400 Subject: [PATCH 7/7] DR-900: comment out the crulr cms-prod-files-latest.tgz as it is too big 25GB. --- .tugboat/config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.tugboat/config.yml b/.tugboat/config.yml index e1774544436..794dd839195 100644 --- a/.tugboat/config.yml +++ b/.tugboat/config.yml @@ -129,9 +129,9 @@ services: - composer va:theme:compile - composer va:web:install - - curl --remote-name https://dsva-vagov-prod-cms-backup-sanitized.s3-us-gov-west-1.amazonaws.com/files/cms-prod-files-latest.tgz - - tar --extract --gunzip --file cms-prod-files-latest.tgz --directory "${DOCROOT}/sites/default/files/" - - rm cms-prod-files-latest.tgz + # - curl --remote-name https://dsva-vagov-prod-cms-backup-sanitized.s3-us-gov-west-1.amazonaws.com/files/cms-prod-files-latest.tgz + # - tar --extract --gunzip --file cms-prod-files-latest.tgz --directory "${DOCROOT}/sites/default/files/" + # - rm cms-prod-files-latest.tgz # Set file permissions such that Drupal will not complain - chgrp -R www-data "${DOCROOT}/sites/default/files"