From 72d5904f05932034abf615ede3f9eee7f6bff59a Mon Sep 17 00:00:00 2001 From: ekes Date: Thu, 25 Jul 2024 15:15:18 +0200 Subject: [PATCH 1/6] Remove content_moderation from defaults. Workflow isn't configured within services so an empty config doesn't hepl (and breaks workspaces as such). It should be added with localgov_workflows. --- ...form_display.node.localgov_services_landing.default.yml | 7 ------- ...view_display.node.localgov_services_landing.default.yml | 1 - ...display.node.localgov_services_landing.search_index.yml | 1 - ...isplay.node.localgov_services_landing.search_result.yml | 1 - ..._view_display.node.localgov_services_landing.teaser.yml | 1 - ...ty_form_display.node.localgov_services_page.default.yml | 7 ------- ...ty_view_display.node.localgov_services_page.default.yml | 1 - ...ew_display.node.localgov_services_page.search_index.yml | 1 - ...w_display.node.localgov_services_page.search_result.yml | 1 - ...ity_view_display.node.localgov_services_page.teaser.yml | 1 - .../localgov_services_page/localgov_services_page.info.yml | 1 - ..._form_display.node.localgov_services_status.default.yml | 7 ------- ..._view_display.node.localgov_services_status.default.yml | 1 - ..._view_display.node.localgov_services_status.message.yml | 1 - ..._display.node.localgov_services_status.search_index.yml | 1 - ...display.node.localgov_services_status.search_result.yml | 1 - ...m_display.node.localgov_services_sublanding.default.yml | 7 ------- ...w_display.node.localgov_services_sublanding.default.yml | 1 - ...play.node.localgov_services_sublanding.search_index.yml | 1 - ...lay.node.localgov_services_sublanding.search_result.yml | 1 - ...ew_display.node.localgov_services_sublanding.teaser.yml | 1 - .../localgov_services_sublanding.info.yml | 1 - 22 files changed, 46 deletions(-) diff --git a/modules/localgov_services_landing/config/install/core.entity_form_display.node.localgov_services_landing.default.yml b/modules/localgov_services_landing/config/install/core.entity_form_display.node.localgov_services_landing.default.yml index 2f9701e..976d0d0 100644 --- a/modules/localgov_services_landing/config/install/core.entity_form_display.node.localgov_services_landing.default.yml +++ b/modules/localgov_services_landing/config/install/core.entity_form_display.node.localgov_services_landing.default.yml @@ -19,7 +19,6 @@ dependencies: - field.field.node.localgov_services_landing.localgov_twitter - node.type.localgov_services_landing module: - - content_moderation - field_group - link - localgov_services @@ -295,12 +294,6 @@ content: size: 60 placeholder: '' third_party_settings: { } - moderation_state: - type: moderation_state_default - weight: 9 - region: content - settings: { } - third_party_settings: { } path: type: path weight: 7 diff --git a/modules/localgov_services_landing/config/install/core.entity_view_display.node.localgov_services_landing.default.yml b/modules/localgov_services_landing/config/install/core.entity_view_display.node.localgov_services_landing.default.yml index 86a0c0b..f6a80d4 100644 --- a/modules/localgov_services_landing/config/install/core.entity_view_display.node.localgov_services_landing.default.yml +++ b/modules/localgov_services_landing/config/install/core.entity_view_display.node.localgov_services_landing.default.yml @@ -127,7 +127,6 @@ content: link_to_entity: false third_party_settings: { } hidden: - content_moderation_control: true localgov_common_tasks: true localgov_contact_us_online: true localgov_other_team_contacts: true diff --git a/modules/localgov_services_landing/config/install/core.entity_view_display.node.localgov_services_landing.search_index.yml b/modules/localgov_services_landing/config/install/core.entity_view_display.node.localgov_services_landing.search_index.yml index adc8b4b..2619905 100644 --- a/modules/localgov_services_landing/config/install/core.entity_view_display.node.localgov_services_landing.search_index.yml +++ b/modules/localgov_services_landing/config/install/core.entity_view_display.node.localgov_services_landing.search_index.yml @@ -156,6 +156,5 @@ content: link_to_entity: false third_party_settings: { } hidden: - content_moderation_control: true links: true search_api_excerpt: true diff --git a/modules/localgov_services_landing/config/install/core.entity_view_display.node.localgov_services_landing.search_result.yml b/modules/localgov_services_landing/config/install/core.entity_view_display.node.localgov_services_landing.search_result.yml index 83418a7..2bdaea2 100644 --- a/modules/localgov_services_landing/config/install/core.entity_view_display.node.localgov_services_landing.search_result.yml +++ b/modules/localgov_services_landing/config/install/core.entity_view_display.node.localgov_services_landing.search_result.yml @@ -32,7 +32,6 @@ content: region: content hidden: body: true - content_moderation_control: true links: true localgov_address: true localgov_address_first_line: true diff --git a/modules/localgov_services_landing/config/install/core.entity_view_display.node.localgov_services_landing.teaser.yml b/modules/localgov_services_landing/config/install/core.entity_view_display.node.localgov_services_landing.teaser.yml index 5213884..e7806ff 100644 --- a/modules/localgov_services_landing/config/install/core.entity_view_display.node.localgov_services_landing.teaser.yml +++ b/modules/localgov_services_landing/config/install/core.entity_view_display.node.localgov_services_landing.teaser.yml @@ -34,7 +34,6 @@ content: third_party_settings: { } region: content hidden: - content_moderation_control: true localgov_address: true localgov_address_first_line: true localgov_common_tasks: true diff --git a/modules/localgov_services_page/config/install/core.entity_form_display.node.localgov_services_page.default.yml b/modules/localgov_services_page/config/install/core.entity_form_display.node.localgov_services_page.default.yml index 3d48db7..8214731 100644 --- a/modules/localgov_services_page/config/install/core.entity_form_display.node.localgov_services_page.default.yml +++ b/modules/localgov_services_page/config/install/core.entity_form_display.node.localgov_services_page.default.yml @@ -13,7 +13,6 @@ dependencies: - field.field.node.localgov_services_page.localgov_topic_classified - node.type.localgov_services_page module: - - content_moderation - entity_browser - field_group - link_attributes @@ -177,12 +176,6 @@ content: size: 60 placeholder: '' third_party_settings: { } - moderation_state: - type: moderation_state_default - weight: 3 - region: content - settings: { } - third_party_settings: { } path: type: path weight: 8 diff --git a/modules/localgov_services_page/config/install/core.entity_view_display.node.localgov_services_page.default.yml b/modules/localgov_services_page/config/install/core.entity_view_display.node.localgov_services_page.default.yml index 71a5f15..d897eca 100644 --- a/modules/localgov_services_page/config/install/core.entity_view_display.node.localgov_services_page.default.yml +++ b/modules/localgov_services_page/config/install/core.entity_view_display.node.localgov_services_page.default.yml @@ -37,7 +37,6 @@ content: type: entity_reference_entity_view region: content hidden: - content_moderation_control: true localgov_common_tasks: true localgov_download_links: true localgov_hide_related_topics: true diff --git a/modules/localgov_services_page/config/install/core.entity_view_display.node.localgov_services_page.search_index.yml b/modules/localgov_services_page/config/install/core.entity_view_display.node.localgov_services_page.search_index.yml index 1c29b7f..a5f9b91 100644 --- a/modules/localgov_services_page/config/install/core.entity_view_display.node.localgov_services_page.search_index.yml +++ b/modules/localgov_services_page/config/install/core.entity_view_display.node.localgov_services_page.search_index.yml @@ -91,7 +91,6 @@ content: link: false third_party_settings: { } hidden: - content_moderation_control: true links: true localgov_hide_related_topics: true localgov_override_related_links: true diff --git a/modules/localgov_services_page/config/install/core.entity_view_display.node.localgov_services_page.search_result.yml b/modules/localgov_services_page/config/install/core.entity_view_display.node.localgov_services_page.search_result.yml index 39694ef..80e425b 100644 --- a/modules/localgov_services_page/config/install/core.entity_view_display.node.localgov_services_page.search_result.yml +++ b/modules/localgov_services_page/config/install/core.entity_view_display.node.localgov_services_page.search_result.yml @@ -28,7 +28,6 @@ content: region: content hidden: body: true - content_moderation_control: true links: true localgov_common_tasks: true localgov_download_links: true diff --git a/modules/localgov_services_page/config/install/core.entity_view_display.node.localgov_services_page.teaser.yml b/modules/localgov_services_page/config/install/core.entity_view_display.node.localgov_services_page.teaser.yml index fa6a431..7c556d2 100644 --- a/modules/localgov_services_page/config/install/core.entity_view_display.node.localgov_services_page.teaser.yml +++ b/modules/localgov_services_page/config/install/core.entity_view_display.node.localgov_services_page.teaser.yml @@ -30,7 +30,6 @@ content: third_party_settings: { } region: content hidden: - content_moderation_control: true localgov_common_tasks: true localgov_download_links: true localgov_hide_related_topics: true diff --git a/modules/localgov_services_page/localgov_services_page.info.yml b/modules/localgov_services_page/localgov_services_page.info.yml index afba5f9..02b447d 100644 --- a/modules/localgov_services_page/localgov_services_page.info.yml +++ b/modules/localgov_services_page/localgov_services_page.info.yml @@ -5,7 +5,6 @@ type: module package: LocalGov Drupal dependencies: - - drupal:content_moderation - drupal:field - drupal:link - drupal:menu_ui diff --git a/modules/localgov_services_status/config/install/core.entity_form_display.node.localgov_services_status.default.yml b/modules/localgov_services_status/config/install/core.entity_form_display.node.localgov_services_status.default.yml index 31ff612..d50ccdb 100644 --- a/modules/localgov_services_status/config/install/core.entity_form_display.node.localgov_services_status.default.yml +++ b/modules/localgov_services_status/config/install/core.entity_form_display.node.localgov_services_status.default.yml @@ -11,7 +11,6 @@ dependencies: - node.type.localgov_services_status module: - condition_field - - content_moderation - path - text id: node.localgov_services_status.default @@ -71,12 +70,6 @@ content: size: 60 placeholder: '' third_party_settings: { } - moderation_state: - type: moderation_state_default - weight: 9 - region: content - settings: { } - third_party_settings: { } path: type: path weight: 14 diff --git a/modules/localgov_services_status/config/install/core.entity_view_display.node.localgov_services_status.default.yml b/modules/localgov_services_status/config/install/core.entity_view_display.node.localgov_services_status.default.yml index 236edf3..c764d80 100644 --- a/modules/localgov_services_status/config/install/core.entity_view_display.node.localgov_services_status.default.yml +++ b/modules/localgov_services_status/config/install/core.entity_view_display.node.localgov_services_status.default.yml @@ -25,7 +25,6 @@ content: third_party_settings: { } region: content hidden: - content_moderation_control: true localgov_service_status_visibile: true links: true localgov_service_status: true diff --git a/modules/localgov_services_status/config/install/core.entity_view_display.node.localgov_services_status.message.yml b/modules/localgov_services_status/config/install/core.entity_view_display.node.localgov_services_status.message.yml index e5522b5..203902c 100644 --- a/modules/localgov_services_status/config/install/core.entity_view_display.node.localgov_services_status.message.yml +++ b/modules/localgov_services_status/config/install/core.entity_view_display.node.localgov_services_status.message.yml @@ -26,7 +26,6 @@ content: third_party_settings: { } region: content hidden: - content_moderation_control: true links: true localgov_service_status: true localgov_service_status_on_landi: true diff --git a/modules/localgov_services_status/config/install/core.entity_view_display.node.localgov_services_status.search_index.yml b/modules/localgov_services_status/config/install/core.entity_view_display.node.localgov_services_status.search_index.yml index 39fe2da..7a1f8f6 100644 --- a/modules/localgov_services_status/config/install/core.entity_view_display.node.localgov_services_status.search_index.yml +++ b/modules/localgov_services_status/config/install/core.entity_view_display.node.localgov_services_status.search_index.yml @@ -41,7 +41,6 @@ content: link: true third_party_settings: { } hidden: - content_moderation_control: true links: true localgov_service_status_on_landi: true localgov_service_status_on_list: true diff --git a/modules/localgov_services_status/config/install/core.entity_view_display.node.localgov_services_status.search_result.yml b/modules/localgov_services_status/config/install/core.entity_view_display.node.localgov_services_status.search_result.yml index 7624a6c..4f94479 100644 --- a/modules/localgov_services_status/config/install/core.entity_view_display.node.localgov_services_status.search_result.yml +++ b/modules/localgov_services_status/config/install/core.entity_view_display.node.localgov_services_status.search_result.yml @@ -24,7 +24,6 @@ content: region: content hidden: body: true - content_moderation_control: true links: true localgov_service_status: true localgov_service_status_on_landi: true diff --git a/modules/localgov_services_sublanding/config/install/core.entity_form_display.node.localgov_services_sublanding.default.yml b/modules/localgov_services_sublanding/config/install/core.entity_form_display.node.localgov_services_sublanding.default.yml index f80edb8..7863f91 100644 --- a/modules/localgov_services_sublanding/config/install/core.entity_form_display.node.localgov_services_sublanding.default.yml +++ b/modules/localgov_services_sublanding/config/install/core.entity_form_display.node.localgov_services_sublanding.default.yml @@ -7,7 +7,6 @@ dependencies: - field.field.node.localgov_services_sublanding.localgov_topics - node.type.localgov_services_sublanding module: - - content_moderation - field_group - paragraphs - path @@ -106,12 +105,6 @@ content: form_display_mode: default default_paragraph_type: '' third_party_settings: { } - moderation_state: - type: moderation_state_default - weight: 4 - region: content - settings: { } - third_party_settings: { } path: type: path weight: 10 diff --git a/modules/localgov_services_sublanding/config/install/core.entity_view_display.node.localgov_services_sublanding.default.yml b/modules/localgov_services_sublanding/config/install/core.entity_view_display.node.localgov_services_sublanding.default.yml index 2429242..a9ac13a 100644 --- a/modules/localgov_services_sublanding/config/install/core.entity_view_display.node.localgov_services_sublanding.default.yml +++ b/modules/localgov_services_sublanding/config/install/core.entity_view_display.node.localgov_services_sublanding.default.yml @@ -25,6 +25,5 @@ content: region: content hidden: body: true - content_moderation_control: true links: true localgov_services_parent: true diff --git a/modules/localgov_services_sublanding/config/install/core.entity_view_display.node.localgov_services_sublanding.search_index.yml b/modules/localgov_services_sublanding/config/install/core.entity_view_display.node.localgov_services_sublanding.search_index.yml index 11046ac..1a4db1d 100644 --- a/modules/localgov_services_sublanding/config/install/core.entity_view_display.node.localgov_services_sublanding.search_index.yml +++ b/modules/localgov_services_sublanding/config/install/core.entity_view_display.node.localgov_services_sublanding.search_index.yml @@ -41,6 +41,5 @@ content: third_party_settings: { } region: content hidden: - content_moderation_control: true links: true search_api_excerpt: true diff --git a/modules/localgov_services_sublanding/config/install/core.entity_view_display.node.localgov_services_sublanding.search_result.yml b/modules/localgov_services_sublanding/config/install/core.entity_view_display.node.localgov_services_sublanding.search_result.yml index 2b39b0a..a3701c7 100644 --- a/modules/localgov_services_sublanding/config/install/core.entity_view_display.node.localgov_services_sublanding.search_result.yml +++ b/modules/localgov_services_sublanding/config/install/core.entity_view_display.node.localgov_services_sublanding.search_result.yml @@ -22,7 +22,6 @@ content: region: content hidden: body: true - content_moderation_control: true links: true localgov_services_parent: true localgov_topics: true diff --git a/modules/localgov_services_sublanding/config/install/core.entity_view_display.node.localgov_services_sublanding.teaser.yml b/modules/localgov_services_sublanding/config/install/core.entity_view_display.node.localgov_services_sublanding.teaser.yml index d83a9bc..072069f 100644 --- a/modules/localgov_services_sublanding/config/install/core.entity_view_display.node.localgov_services_sublanding.teaser.yml +++ b/modules/localgov_services_sublanding/config/install/core.entity_view_display.node.localgov_services_sublanding.teaser.yml @@ -24,7 +24,6 @@ content: third_party_settings: { } region: content hidden: - content_moderation_control: true localgov_topics: true links: true localgov_services_parent: true diff --git a/modules/localgov_services_sublanding/localgov_services_sublanding.info.yml b/modules/localgov_services_sublanding/localgov_services_sublanding.info.yml index c675c6b..855c428 100644 --- a/modules/localgov_services_sublanding/localgov_services_sublanding.info.yml +++ b/modules/localgov_services_sublanding/localgov_services_sublanding.info.yml @@ -5,7 +5,6 @@ type: module package: LocalGov Drupal dependencies: - - drupal:content_moderation - drupal:field - drupal:menu_ui - drupal:node From f79f1ae273f41c9daca6c370ac81c7b84dcbd6ba Mon Sep 17 00:00:00 2001 From: ekes Date: Fri, 26 Jul 2024 16:39:54 +0200 Subject: [PATCH 2/6] Fix previously broken tests by changing theme to one that has class on tabs. The JS drag tests were failing as the tab with the field to drag to was not being selected. The class being looked for is supplied by claro. --- .../tests/src/FunctionalJavascript/LandingPageChildrenTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/localgov_services_navigation/tests/src/FunctionalJavascript/LandingPageChildrenTest.php b/modules/localgov_services_navigation/tests/src/FunctionalJavascript/LandingPageChildrenTest.php index b9d4f02..b000845 100644 --- a/modules/localgov_services_navigation/tests/src/FunctionalJavascript/LandingPageChildrenTest.php +++ b/modules/localgov_services_navigation/tests/src/FunctionalJavascript/LandingPageChildrenTest.php @@ -20,7 +20,7 @@ class LandingPageChildrenTest extends WebDriverTestBase { /** * {@inheritdoc} */ - protected $defaultTheme = 'stark'; + protected $defaultTheme = 'claro'; /** * A user to edit landing pages. From 31e4fbbe2615e6cf9ccc9c84387b11b1827aea70 Mon Sep 17 00:00:00 2001 From: ekes Date: Sat, 27 Jul 2024 14:17:38 +0200 Subject: [PATCH 3/6] Add basic Workflow integration test to ensure form fields. Rest of integration test, access etc. included in LocalGov Workflows. --- composer.json | 5 +- .../Functional/WorkflowsIntegrationTest.php | 148 ++++++++++++++++++ 2 files changed, 152 insertions(+), 1 deletion(-) create mode 100644 tests/src/Functional/WorkflowsIntegrationTest.php diff --git a/composer.json b/composer.json index c4dfe27..32bdb87 100644 --- a/composer.json +++ b/composer.json @@ -16,11 +16,14 @@ "localgovdrupal/localgov_paragraphs": "^2.3", "localgovdrupal/localgov_topics": "^1.0" }, + "require-dev": { + "localgovdrupal/localgov_workflows": "^1.3" + }, "extra": { "enable-patching": true, "patches": { "drupal/core": { - "node_access filters out accessible nodes when node is left joined (1349080)" : "https://git.drupalcode.org/project/drupal/-/commit/c271adb.diff" + "node_access filters out accessible nodes when node is left joined (1349080)": "https://git.drupalcode.org/project/drupal/-/commit/c271adb.diff" } } } diff --git a/tests/src/Functional/WorkflowsIntegrationTest.php b/tests/src/Functional/WorkflowsIntegrationTest.php new file mode 100644 index 0000000..7436e9b --- /dev/null +++ b/tests/src/Functional/WorkflowsIntegrationTest.php @@ -0,0 +1,148 @@ +drupalPlaceBlock('system_breadcrumb_block'); + // LocalGov Workflows includes access and other checks. + $this->adminUser = $this->drupalCreateUser([ + 'bypass node access', + 'administer nodes', + 'use localgov_editorial transition approve', + 'use localgov_editorial transition archive', + 'use localgov_editorial transition archived_draft', + 'use localgov_editorial transition archived_published', + 'use localgov_editorial transition create_new_draft', + 'use localgov_editorial transition publish', + 'use localgov_editorial transition reject', + 'use localgov_editorial transition submit_for_review', + 'view all scheduled transitions', + 'view any unpublished content', + 'view latest version', + ]); + $this->nodeStorage = $this->container->get('entity_type.manager')->getStorage('node'); + } + + /** + * Post and link test, change workflow status. + * + * Post a service landing page. + * Post a service sub landing page, and link to landing page. + * Link landing page to sublanding page. + * Post a page, put it in the landing and sublanding services. + * Link page from sublanding page. + */ + public function testPostLink() { + $this->drupalLogin($this->adminUser); + $this->drupalGet('node/add/localgov_services_landing'); + $form = $this->getSession()->getPage(); + $form->fillField('edit-title-0-value', 'Service 1'); + $form->fillField('edit-body-0-summary', 'Service 1 summary'); + $form->fillField('edit-body-0-value', 'Service 1 description'); + $form->pressButton('edit-submit'); + // Should default to Draft. + + $this->drupalGet('node/add/localgov_services_sublanding'); + $form = $this->getSession()->getPage(); + $form->fillField('edit-title-0-value', 'Sub Service 1'); + $form->fillField('edit-body-0-summary', 'Sub Service 1 summary'); + $form->fillField('edit-body-0-value', 'Sub Service 1 description'); + $form->fillField('edit-localgov-services-parent-0-target-id', 'Service 1 (1)'); + $form->pressButton('edit-submit'); + // Also Draft. + + $this->drupalGet('node/1/edit'); + $form = $this->getSession()->getPage(); + // Check is in Draft. + $state = $form->findField('edit-moderation-state-0-state'); + $this->assertEquals('draft', $state->getValue()); + // Change to Published. + $state->setValue('published'); + $form->fillField('edit-localgov-destinations-0-target-id', 'Sub landing 1 (2)'); + $form->pressButton('edit-submit'); + + $this->drupalGet('node/add/localgov_services_page'); + $assert = $this->assertSession(); + $form = $this->getSession()->getPage(); + $form->fillField('edit-title-0-value', 'Service 1 Page 1'); + $form->fillField('edit-body-0-summary', 'Service 1 summary 1 '); + $form->fillField('edit-body-0-value', 'Service 1 description 1'); + $form->fillField('edit-localgov-services-parent-0-target-id', 'Service 1 » Sub landing 1 (2)'); + $form->pressButton('edit-submit'); + + $this->drupalGet('node/2/edit'); + $form = $this->getSession()->getPage(); + $state = $form->findField('edit-moderation-state-0-state'); + $this->assertEquals('draft', $state->getValue()); + // Change to Published. + $state->setValue('published'); + $form->fillField('edit-localgov-topics-0-subform-topic-list-links-0-uri', '/node/3'); + $form->pressButton('edit-submit'); + + $assert = $this->assertSession(); + $assert->pageTextContains('Service 1 Page 1'); + + $this->drupalLogout(); + $this->drupalGet('node/2'); + $assert->pageTextNotContains('Service 1 Page 1'); + $this->drupalGet('node/3'); + $this->assertSession()->statusCodeEquals(403); + } + +} From dd54a29bbe72cff2e610d9b8e8b3a8736ed09dc3 Mon Sep 17 00:00:00 2001 From: ekes Date: Sat, 27 Jul 2024 14:35:46 +0200 Subject: [PATCH 4/6] Coding standards fixes. --- tests/src/Functional/WorkflowsIntegrationTest.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/src/Functional/WorkflowsIntegrationTest.php b/tests/src/Functional/WorkflowsIntegrationTest.php index 7436e9b..0fbf550 100644 --- a/tests/src/Functional/WorkflowsIntegrationTest.php +++ b/tests/src/Functional/WorkflowsIntegrationTest.php @@ -2,11 +2,7 @@ namespace Drupal\Tests\localgov_services\Functional; -use Drupal\node\NodeInterface; use Drupal\Tests\BrowserTestBase; -use Drupal\Tests\node\Traits\NodeCreationTrait; -use Drupal\Tests\system\Functional\Menu\AssertBreadcrumbTrait; -use Drupal\Tests\Traits\Core\CronRunTrait; /** * Tests localgov services pages working with LocalGov Workflows. @@ -97,7 +93,6 @@ public function testPostLink() { $form->fillField('edit-body-0-value', 'Service 1 description'); $form->pressButton('edit-submit'); // Should default to Draft. - $this->drupalGet('node/add/localgov_services_sublanding'); $form = $this->getSession()->getPage(); $form->fillField('edit-title-0-value', 'Sub Service 1'); @@ -106,7 +101,6 @@ public function testPostLink() { $form->fillField('edit-localgov-services-parent-0-target-id', 'Service 1 (1)'); $form->pressButton('edit-submit'); // Also Draft. - $this->drupalGet('node/1/edit'); $form = $this->getSession()->getPage(); // Check is in Draft. From ddd6886de8f92656c05d964d540330a637dbc439 Mon Sep 17 00:00:00 2001 From: ekes Date: Sat, 27 Jul 2024 17:30:18 +0200 Subject: [PATCH 5/6] Initial publish in space, edit, publish live test. Has URL aliases, does not yet test. --- .../Functional/WorkspacesIntegrationTest.php | 157 ++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100644 tests/src/Functional/WorkspacesIntegrationTest.php diff --git a/tests/src/Functional/WorkspacesIntegrationTest.php b/tests/src/Functional/WorkspacesIntegrationTest.php new file mode 100644 index 0000000..8797e2b --- /dev/null +++ b/tests/src/Functional/WorkspacesIntegrationTest.php @@ -0,0 +1,157 @@ +drupalPlaceBlock('system_breadcrumb_block'); + $this->adminUser = $this->drupalCreateUser([ + 'access administration pages', + 'bypass node access', + 'administer nodes', + 'administer workspaces', + ]); + $this->nodeStorage = $this->container->get('entity_type.manager')->getStorage('node'); + $this->setupWorkspaceSwitcherBlock(); + } + + /** + * Post and link test. + * + * Post a service landing page. + * Post a service sub landing page, and link to landing page. + * Link landing page to sublanding page. + * Post a page, put it in the landing and sublanding services. + * Link page from sublanding page. + */ + public function testPostLink() { + $assert = $this->assertSession(); + $this->drupalLogin($this->adminUser); + + $test_1 = $this->createWorkspaceThroughUi('Test 1', 'test_1'); + $this->switchToWorkspace($test_1); + + $this->drupalGet('node/add/localgov_services_landing'); + $form = $this->getSession()->getPage(); + $form->fillField('edit-title-0-value', 'Service 1'); + $form->fillField('edit-body-0-summary', 'Service 1 summary'); + $form->fillField('edit-body-0-value', 'Service 1 description'); + $form->checkField('edit-status-value'); + $form->pressButton('edit-submit'); + $service_landing = $this->drupalGetNodeByTitle('Service 1'); + + $this->drupalGet('node/add/localgov_services_sublanding'); + $form = $this->getSession()->getPage(); + $form->fillField('edit-title-0-value', 'Sub Service 1'); + $form->fillField('edit-body-0-summary', 'Sub Service 1 summary'); + $form->fillField('edit-body-0-value', 'Sub Service 1 description'); + $form->fillField('edit-localgov-services-parent-0-target-id', 'Service 1 (1)'); + $form->checkField('edit-status-value'); + $form->pressButton('edit-submit'); + $service_sublanding = $this->drupalGetNodeByTitle('Sub Service 1'); + + $this->drupalGet($service_landing->toUrl('edit-form')->toString()); + $form = $this->getSession()->getPage(); + $form->fillField('edit-localgov-destinations-0-target-id', 'Sub landing 1 (2)'); + $form->pressButton('edit-submit'); + + $this->drupalGet('node/add/localgov_services_page'); + $form = $this->getSession()->getPage(); + $form->fillField('edit-title-0-value', 'Service 1 Page 1'); + $form->fillField('edit-body-0-summary', 'Service 1 summary 1 '); + $form->fillField('edit-body-0-value', 'Service 1 description 1'); + $form->fillField('edit-localgov-services-parent-0-target-id', 'Service 1 » Sub landing 1 (2)'); + $form->checkField('edit-status-value'); + $form->pressButton('edit-submit'); + $service_page = $this->drupalGetNodeByTitle('Service 1 Page 1'); + + $this->drupalGet($service_sublanding->toUrl('edit-form')->toString()); + $form = $this->getSession()->getPage(); + $form->fillField('edit-localgov-topics-0-subform-topic-list-links-0-uri', '/node/3'); + $form->pressButton('edit-submit'); + $assert->pageTextContains('Service 1 Page 1'); + + $this->drupalLogout(); + + $this->drupalGet($service_landing->toUrl()->toString()); + $assert->statusCodeEquals(403); + $this->drupalGet($service_sublanding->toUrl()->toString()); + $assert->statusCodeEquals(403); + $this->drupalGet($service_page->toUrl()->toString()); + $assert->statusCodeEquals(403); + + $this->drupalLogin($this->adminUser); + $this->drupalGet($test_1->toUrl()->toString()); + $assert->pageTextContains('3 content items'); + $assert->pageTextContains('3 URL aliases'); + $assert->pageTextContains('1 Paragraph'); + $this->drupalGet($test_1->toUrl()->toString() . '/publish'); + $this->getSession()->getPage()->pressButton('Publish 7 items to Live'); + $this->assertSession()->pageTextContains('Successful publication.'); + + $this->drupalLogout(); + + $this->drupalGet($service_landing->toUrl()->toString()); + $assert->statusCodeEquals(200); + $this->drupalGet($service_sublanding->toUrl()->toString()); + $assert->statusCodeEquals(200); + $this->drupalGet($service_page->toUrl()->toString()); + $assert->statusCodeEquals(200); + } + +} From 5291659e787d2f9cb62ad7a745ff94f995f676ac Mon Sep 17 00:00:00 2001 From: ekes Date: Mon, 29 Jul 2024 12:18:07 +0200 Subject: [PATCH 6/6] Initial workspaces check. - Without workflows, - Might need https://www.drupal.org/project/pathauto/issues/3283769#comment-15541961 appiled to pathauto. --- .../Functional/WorkspacesIntegrationTest.php | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/tests/src/Functional/WorkspacesIntegrationTest.php b/tests/src/Functional/WorkspacesIntegrationTest.php index 8797e2b..647c0c2 100644 --- a/tests/src/Functional/WorkspacesIntegrationTest.php +++ b/tests/src/Functional/WorkspacesIntegrationTest.php @@ -2,7 +2,9 @@ namespace Drupal\Tests\localgov_services\Functional; +use Drupal\node\NodeInterface; use Drupal\Tests\BrowserTestBase; +use Drupal\Tests\system\Functional\Menu\AssertBreadcrumbTrait; use Drupal\Tests\workspaces\Functional\WorkspaceTestUtilities; /** @@ -12,6 +14,7 @@ */ class WorkspacesIntegrationTest extends BrowserTestBase { + use AssertBreadcrumbTrait; use WorkspaceTestUtilities; /** @@ -51,6 +54,8 @@ class WorkspacesIntegrationTest extends BrowserTestBase { 'localgov_services_sublanding', 'localgov_services_page', 'localgov_services_navigation', + 'path', + 'pathauto', 'workspaces', ]; @@ -65,6 +70,7 @@ protected function setUp(): void { 'bypass node access', 'administer nodes', 'administer workspaces', + 'create url aliases', ]); $this->nodeStorage = $this->container->get('entity_type.manager')->getStorage('node'); $this->setupWorkspaceSwitcherBlock(); @@ -144,6 +150,9 @@ public function testPostLink() { $this->getSession()->getPage()->pressButton('Publish 7 items to Live'); $this->assertSession()->pageTextContains('Successful publication.'); + $this->drupalGet($service_landing->toUrl()->toString()); + $this->drupalGet($service_landing->toUrl('edit-form')->toString()); + $this->drupalLogout(); $this->drupalGet($service_landing->toUrl()->toString()); @@ -154,4 +163,67 @@ public function testPostLink() { $assert->statusCodeEquals(200); } + /** + * Path test. + */ + public function testServicePaths() { + $assert = $this->assertSession(); + // @todo same as original test without admin privs? + $this->drupalLogin($this->adminUser); + $test_1 = $this->createWorkspaceThroughUi('Test 1', 'test_1'); + $this->switchToWorkspace($test_1); + + $node = $this->createNode([ + 'title' => 'Landing Page 1', + 'type' => 'localgov_services_landing', + 'status' => NodeInterface::PUBLISHED, + ]); + $node = $this->createNode([ + 'title' => 'Sublanding 1', + 'type' => 'localgov_services_sublanding', + 'status' => NodeInterface::PUBLISHED, + 'localgov_services_parent' => ['target_id' => $node->id()], + ]); + $this->createNode([ + 'title' => 'Service Page 1', + 'type' => 'localgov_services_page', + 'status' => NodeInterface::PUBLISHED, + 'localgov_services_parent' => ['target_id' => $node->id()], + ]); + + $this->drupalGet('landing-page-1'); + $assert->pageTextContains('Landing Page 1'); + $trail = ['' => 'Home']; + $this->assertBreadcrumb(NULL, $trail); + $this->drupalGet('landing-page-1/sublanding-1'); + $assert->pageTextContains('Sublanding 1'); + $trail += ['landing-page-1' => 'Landing Page 1']; + $this->assertBreadcrumb(NULL, $trail); + $this->drupalGet('landing-page-1/sublanding-1/service-page-1'); + $assert->pageTextContains('Service Page 1'); + $trail += ['landing-page-1/sublanding-1' => 'Sublanding 1']; + $this->assertBreadcrumb(NULL, $trail); + + $this->drupalGet($test_1->toUrl()->toString()); + $assert->pageTextContains('3 content items'); + $assert->pageTextContains('3 URL aliases'); + $this->drupalGet($test_1->toUrl()->toString() . '/publish'); + $this->getSession()->getPage()->pressButton('Publish 6 items to Live'); + $this->assertSession()->pageTextContains('Successful publication.'); + $this->drupalLogout(); + + $this->drupalGet('landing-page-1'); + $assert->pageTextContains('Landing Page 1'); + $trail = ['' => 'Home']; + $this->assertBreadcrumb(NULL, $trail); + $this->drupalGet('landing-page-1/sublanding-1'); + $assert->pageTextContains('Sublanding 1'); + $trail += ['landing-page-1' => 'Landing Page 1']; + $this->assertBreadcrumb(NULL, $trail); + $this->drupalGet('landing-page-1/sublanding-1/service-page-1'); + $assert->pageTextContains('Service Page 1'); + $trail += ['landing-page-1/sublanding-1' => 'Sublanding 1']; + $this->assertBreadcrumb(NULL, $trail); + } + }