diff --git a/core/modules/node/content_types.js b/core/modules/node/content_types.js index eed93f0..4ec34aa 100644 --- a/core/modules/node/content_types.js +++ b/core/modules/node/content_types.js @@ -26,7 +26,7 @@ }); $context.find('#edit-workflow').drupalSetSummary(function (context) { var vals = []; - $(context).find('input[name^="options"]:checked').parent().each(function () { + $(context).find('input[name^="options"]:checked').next('label').each(function () { vals.push(Drupal.checkPlain($(this).text())); }); if (!$(context).find('#edit-options-status').is(':checked')) { diff --git a/core/modules/node/tests/src/FunctionalJavascript/TestSettingSummariesContentType.php b/core/modules/node/tests/src/FunctionalJavascript/TestSettingSummariesContentType.php new file mode 100644 index 0000000..210df1c --- /dev/null +++ b/core/modules/node/tests/src/FunctionalJavascript/TestSettingSummariesContentType.php @@ -0,0 +1,97 @@ +drupalCreateUser(['administer content types']); + $this->drupalLogin($admin_user); + $this->drupalCreateContentType(['type' => 'test']); + } + + /** + * Tests updating summaries. + */ + public function testSummariesUpdate() { + $this->drupalGet('admin/structure/types/manage/test'); + + $session = $this->getSession(); + $page = $session->getPage(); + + // Testing "Submission form settings" zone. + $id = '#edit-submission'; + $selector = '[href=\\' . $id . '] .vertical-tabs__menu-item-summary'; + $title = 'Test Title'; + $page->findField('edit-title-label')->setValue($title); + $is_change = $this->waitSummaryUpdateAfterChanges($page, [$title], $selector); + $this->assertTrue($is_change, 'Submission summary update.'); + $text = $page->findAll('css', $selector)[0]->getText(); + $this->assertNotContains(' , ', $text); + + // Testing "Workflow" zone. + $this->checkZone($page, 'workflow'); + + // Testing "Language settings" zone. + $this->checkZone($page, 'language'); + + // Testing "Display settings" zone. + $this->checkZone($page, 'display'); + } + + private function checkZone($page, $zone) { + $id = '#edit-' . $zone; + $selector = '[href=\\' . $id . '] .vertical-tabs__menu-item-summary'; + $labels = $this->checkedAllCheckboxes($page, $id); + $is_change = $this->waitSummaryUpdateAfterChanges($page, $labels, $selector); + $this->assertTrue($is_change, ucfirst($zone) . ' summary update.'); + $text = $page->findAll('css', $selector)[0]->getText(); + $this->assertNotContains(' , ', $text); + } + + private function checkedAllCheckboxes($page, $selector) { + $selector = $selector . ' .form-type-checkbox [type=checkbox]'; + $checkboxes = $page->findAll('css', $selector); + foreach ($checkboxes as $checkbox) { + $checkbox->check(); + } + + $labels = []; + $items = $page->findAll('css', $selector . ' + label'); + foreach ($items as $item) { + $labels[] = $item->getText(); + } + + return $labels; + } + + private function waitSummaryUpdateAfterChanges($page, $items, $selector) { + return $page->waitFor(10, function () use ($page, $items, $selector) { + $summary = $page->findAll('css', $selector)[0]->getText(); + foreach ($items as $item) { + if (!preg_match('/\b' . $item . '\b/', $summary)) { + return FALSE; + } + } + return TRUE; + }); + } + +}