diff --git a/MIGRATION.md b/MIGRATION.md index ac69eb8..00fcf2d 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -4,6 +4,15 @@ A migration map of the step definitions available in v2 to v3. | V2 | V3 | |------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| **[`ContentTrait`](src/ContentTrait.php) ([example](tests/behat/features/content.feature))** | | +| `Given no :type content type` | `Given the content type :content_type does not exist` | +| `Given no ([a-zA-z0-9_-]+) content:$/` | `Given the following :content_type content does not exist:` | +| `When I visit :type :title` | `When I visit the :content_type content page with the title :title` | +| `When I edit :type :title` | `When I visit the :content_type content edit page with the title :title` | +| `When I delete :type :title` | `When I visit the :content_type content delete page with the title :title` | +| `When the moderation state of :type :title changes from :old_state to :new_state` | `When I change the moderation state of the :content_type content with the title :title to the :new_state` | +| `When I visit :type :title scheduled transitions` | `When I visit the scheduled transitions page of the :content_type content with the title :title` | +|   | | | **[`DraggableviewsTrait`](src/DraggableviewsTrait.php) ([example](tests/behat/features/draggableviews.feature))** | | | `Then I save draggable views :view_id view :views_display_id display :bundle items in the following order:` | `When I save the draggable views items of the view :view_id and the display :views_display_id for the :bundle content in the following order:` | |   | | diff --git a/README.md b/README.md index c0e5309..e0a6ece 100644 --- a/README.md +++ b/README.md @@ -122,66 +122,74 @@ For example, to skip `beforeScenario` hook from `JsTrait`, add #### Delete content type ```gherkin -@Given no :type content type +@Given the content type :content_type does not exist ``` Example: ```gherkin -Given no "article" content type +Given the content type "article" does not exist ``` #### Remove content defined by provided properties ```gherkin -@Given /^no ([a-zA-z0-9_-]+) content:$/ +@Given the following :content_type content does not exist: ``` Example: ```gherkin -Given no "article" content: +Given the following "article" content does not exist: | title | | Test article | | Another test article | ``` -#### Navigate to page with specified type and title +#### Visit a page of a type with a specified title ```gherkin -@When I visit :type :title +@When I visit the :content_type content page with the title :title ``` Example: ```gherkin -When I visit "article" "Test article" +When I visit the "article" content page with the title "Test article" ``` -#### Navigate to edit page with specified type and title +#### Visit an edit page of a type with a specified title ```gherkin -@When I edit :type :title +@When I visit the :content_type content edit page with the title :title ``` Example: ```gherkin -When I edit "article" "Test article" +When I visit the "article" content edit page with the title "Test article" ``` -#### Navigate to delete page with specified type and title +#### Visit a delete page of a type with a specified title ```gherkin -@When I delete :type :title +@When I visit the :content_type content delete page with the title :title +``` +Example: +```gherkin +When I visit the "article" content delete page with the title "Test article" ``` -#### Change moderation state of a content with specified title +#### Visit a scheduled transitions page of a type with a specified title ```gherkin -@When the moderation state of :type :title changes from :old_state to :new_state +@When I visit the :content_type content scheduled transitions page with the title :title ``` Example: ```gherkin -When the moderation state of "article" "Test article" changes from "draft" to "published" +When I visit the "article" content scheduled transitions page with the title "Test article" ``` -#### Visit scheduled-transition page for node with title +#### Change moderation state of a content with the specified title ```gherkin -@When I visit :type :title scheduled transitions +@When I change the moderation state of the :content_type content with the title :title to the :new_state state +``` +Example: +```gherkin +When I change the moderation state of the "article" content with the title "Test article" to the "published" state ``` ### CookieTrait diff --git a/docs.php b/docs.php index 32525ac..0a6e041 100644 --- a/docs.php +++ b/docs.php @@ -275,17 +275,21 @@ function print_report(array $info): void { $method['description'] = is_string($method['description']) ? $method['description'] : ''; $method['example'] = is_string($method['example']) ? $method['example'] : ''; - $step = $method['steps'][0]; + $step = (string) $method['steps'][0]; - if (str_starts_with((string) $step, '@When') && !str_contains((string) $method['steps'][0], 'I ')) { + if (str_starts_with($step, '@Given') && str_ends_with($step, ':') && !str_contains($step, 'following')) { + printf(' %s::%s - %s' . PHP_EOL, $trait, $method['name'], 'Missing "following" in the step'); + } + + if (str_starts_with($step, '@When') && !str_contains($step, 'I ')) { printf(' %s::%s - %s' . PHP_EOL, $trait, $method['name'], 'Missing "I " in the step'); } - if (str_starts_with((string) $step, '@Then') && !str_contains((string) $method['steps'][0], 'should')) { + if (str_starts_with($step, '@Then') && !str_contains($step, 'should')) { printf(' %s::%s - %s' . PHP_EOL, $trait, $method['name'], 'Missing "should" in the step'); } - if (str_starts_with((string) $step, '@Then') && !str_contains((string) $method['steps'][0], 'the')) { + if (str_starts_with($step, '@Then') && !str_contains($step, 'the')) { printf(' %s::%s - %s' . PHP_EOL, $trait, $method['name'], 'Missing "the" in the step'); } diff --git a/src/ContentTrait.php b/src/ContentTrait.php index f26082c..b655dd0 100644 --- a/src/ContentTrait.php +++ b/src/ContentTrait.php @@ -5,6 +5,9 @@ namespace DrevOps\BehatSteps; use Behat\Gherkin\Node\TableNode; +use Drupal\node\Entity\Node; +use Drupal\node\NodeInterface; +use Drupal\workflows\Entity\Workflow; /** * Trait ContentTrait. @@ -19,160 +22,176 @@ trait ContentTrait { * Delete content type. * * @code - * Given no "article" content type + * Given the content type "article" does not exist * @endcode * - * @Given no :type content type + * @Given the content type :content_type does not exist */ - public function contentRemoveContentType(string $type): void { - $content_type_entity = \Drupal::entityTypeManager()->getStorage('node_type')->load($type); + public function contentRemoveContentType(string $content_type): void { + $content_type_entity = \Drupal::entityTypeManager()->getStorage('node_type')->load($content_type); + if ($content_type_entity) { $content_type_entity->delete(); } } /** - * Navigate to page with specified type and title. + * Remove content defined by provided properties. * * @code - * When I visit "article" "Test article" + * Given the following "article" content does not exist: + * | title | + * | Test article | + * | Another test article | * @endcode * - * @When I visit :type :title + * @Given the following :content_type content does not exist: */ - public function contentVisitPageWithTitle(string $type, string $title): void { - $nids = $this->contentLoadMultiple($type, [ - 'title' => $title, - ]); + public function contentDelete(string $type, TableNode $nodesTable): void { + foreach ($nodesTable->getHash() as $nodeHash) { + $nids = $this->contentLoadMultiple($type, $nodeHash); - if (empty($nids)) { - throw new \RuntimeException(sprintf('Unable to find %s page "%s"', $type, $title)); + $controller = \Drupal::entityTypeManager()->getStorage('node'); + $entities = $controller->loadMultiple($nids); + $controller->delete($entities); } - - ksort($nids); - - $nid = end($nids); - $path = $this->locatePath('/node/' . $nid); - print $path; - $this->getSession()->visit($path); } /** - * Navigate to edit page with specified type and title. + * Visit a page of a type with a specified title. * * @code - * When I edit "article" "Test article" + * When I visit the "article" content page with the title "Test article" * @endcode * - * @When I edit :type :title + * @When I visit the :content_type content page with the title :title */ - public function contentEditPageWithTitle(string $type, string $title): void { - $nids = $this->contentLoadMultiple($type, [ - 'title' => $title, - ]); - - if (empty($nids)) { - throw new \RuntimeException(sprintf('Unable to find %s page "%s"', $type, $title)); - } - - $nid = current($nids); - $path = $this->locatePath('/node/' . $nid) . '/edit'; - print $path; - $this->getSession()->visit($path); + public function contentVisitViewWithTitle(string $content_type, string $title): void { + $this->contentVisitActionPageWithTitle($content_type, $title); } /** - * Navigate to delete page with specified type and title. + * Visit an edit page of a type with a specified title. * - * @When I delete :type :title + * @code + * When I visit the "article" content edit page with the title "Test article" + * @endcode + * + * @When I visit the :content_type content edit page with the title :title */ - public function contentDeletePageWithTitle(string $type, string $title): void { - $nids = $this->contentLoadMultiple($type, [ - 'title' => $title, - ]); - - if (empty($nids)) { - throw new \RuntimeException(sprintf('Unable to find %s page "%s"', $type, $title)); - } - - $nid = current($nids); - $path = $this->locatePath('/node/' . $nid) . '/delete'; - print $path; - $this->getSession()->visit($path); + public function contentVisitEditPageWithTitle(string $content_type, string $title): void { + $this->contentVisitActionPageWithTitle($content_type, $title, '/edit'); } /** - * Remove content defined by provided properties. + * Visit a delete page of a type with a specified title. * * @code - * Given no "article" content: - * | title | - * | Test article | - * | Another test article | + * When I visit the "article" content delete page with the title "Test article" * @endcode * - * @Given /^no ([a-zA-z0-9_-]+) content:$/ + * @When I visit the :content_type content delete page with the title :title */ - public function contentDelete(string $type, TableNode $nodesTable): void { - foreach ($nodesTable->getHash() as $nodeHash) { - $nids = $this->contentLoadMultiple($type, $nodeHash); - - $controller = \Drupal::entityTypeManager()->getStorage('node'); - $entities = $controller->loadMultiple($nids); - $controller->delete($entities); - } + public function contentVisitDeletePageWithTitle(string $content_type, string $title): void { + $this->contentVisitActionPageWithTitle($content_type, $title, '/delete'); } /** - * Change moderation state of a content with specified title. + * Visit a scheduled transitions page of a type with a specified title. * * @code - * When the moderation state of "article" "Test article" changes from "draft" to "published" + * When I visit the "article" content scheduled transitions page with the title "Test article" * @endcode * - * @When the moderation state of :type :title changes from :old_state to :new_state + * @When I visit the :content_type content scheduled transitions page with the title :title */ - public function contentModeratePageWithTitle(string $type, string $title, string $old_state, string $new_state): void { - $nodes = \Drupal::entityTypeManager() - ->getStorage('node') - ->loadByProperties([ - 'title' => $title, - 'type' => $type, - ]); - - if (empty($nodes)) { - throw new \Exception(sprintf('Unable to find %s page "%s"', $type, $title)); + public function contentVisitScheduledTransitionsPageWithTitle(string $content_type, string $title): void { + $this->contentVisitActionPageWithTitle($content_type, $title, '/scheduled-transitions'); + } + + /** + * Visit the action page of the content with a specified title. + * + * @param string $content_type + * The content type. + * @param string $title + * The title of the content. + * @param string $action_subpath + * The operation to perform. + */ + protected function contentVisitActionPageWithTitle(string $content_type, string $title, string $action_subpath = ''): void { + $content_type_entity = \Drupal::entityTypeManager()->getStorage('node_type')->load($content_type); + + if (!$content_type_entity) { + throw new \RuntimeException(sprintf('Content type "%s" does not exist.', $content_type)); } - /** @var \Drupal\node\Entity\Node $node */ - $node = current($nodes); - $current_old_state = $node->get('moderation_state')->first()->getString(); - if ($current_old_state != $old_state) { - throw new \Exception(sprintf('The current state "%s" is different from "%s"', $current_old_state, $old_state)); + $nids = $this->contentLoadMultiple($content_type, [ + 'title' => $title, + ]); + + if (empty($nids)) { + throw new \RuntimeException(sprintf('Unable to find "%s" content with title "%s".', $content_type, $title)); } - $node->set('moderation_state', $new_state); - $node->save(); + ksort($nids); + + $nid = end($nids); + $path = $this->locatePath('/node/' . $nid . $action_subpath); + + $this->getSession()->visit($path); } /** - * Visit scheduled-transition page for node with title. + * Change moderation state of a content with the specified title. + * + * @code + * When I change the moderation state of the "article" content with the title "Test article" to the "published" state + * @endcode * - * @When I visit :type :title scheduled transitions + * @When I change the moderation state of the :content_type content with the title :title to the :new_state state */ - public function contentVisitScheduledTransitionsPageWithTitle(string $type, string $title): void { - $nids = $this->contentLoadMultiple($type, [ + public function contentChangeModerationStateWithTitle(string $content_type, string $title, string $new_state): void { + $content_type_entity = \Drupal::entityTypeManager()->getStorage('node_type')->load($content_type); + + if (!$content_type_entity) { + throw new \RuntimeException(sprintf('Content type "%s" does not exist.', $content_type)); + } + + $nids = $this->contentLoadMultiple($content_type, [ 'title' => $title, ]); if (empty($nids)) { - throw new \RuntimeException(sprintf('Unable to find %s page "%s"', $type, $title)); + throw new \RuntimeException(sprintf('Unable to find "%s" content with title "%s".', $content_type, $title)); } - $nid = current($nids); - $path = $this->locatePath('/node/' . $nid) . '/scheduled-transitions'; - print $path; - $this->getSession()->visit($path); + ksort($nids); + + $nid = end($nids); + /** @var \Drupal\node\Entity\Node $node */ + $node = Node::load($nid); + + if (!$node instanceof NodeInterface) { + throw new \RuntimeException(sprintf('Unable to find "%s" content with title "%s".', $content_type, $title)); + } + + $state_is_valid = FALSE; + $workflows = Workflow::loadMultiple(); + foreach ($workflows as $workflow) { + $workflow_type_settings = $workflow->get('type_settings'); + if (in_array($content_type, $workflow_type_settings['entity_types']['node']) && isset($workflow_type_settings['states'][$new_state])) { + $state_is_valid = TRUE; + break; + } + } + + if (!$state_is_valid) { + throw new \RuntimeException(sprintf('State "%s" is not defined in the workflow for "%s" content type.', $new_state, $content_type)); + } + + $node->set('moderation_state', $new_state); + $node->save(); } /** diff --git a/tests/behat/features/content.feature b/tests/behat/features/content.feature index cb9a3a1..91363fc 100644 --- a/tests/behat/features/content.feature +++ b/tests/behat/features/content.feature @@ -1,163 +1,246 @@ Feature: Check that ContentTrait works @api - Scenario: Assert visiting a page with title of specified content type + Scenario: Assert "@Given the content type :content_type does not exist" works as expected. + Given I am logged in as a user with the "administrator" role + When I visit "/admin/structure/types/add" + And I fill in "Name" with "test_content_type" + And I fill in "Machine-readable name" with "test_content_type" + And I press "Save" + And I visit "/admin/structure/types" + Then I should see "test_content_type" + Given the content type "test_content_type" does not exist + When I visit "/admin/structure/types" + Then I should not see "test_content_type" + + @api + Scenario: Assert "@Given the content type :content_type does not exist" works as expected on non-existing content type. + Given the content type "test_content_type" does not exist + And I am logged in as a user with the "administrator" role + When I visit "/admin/structure/types" + Then I should not see "test_content_type" + + @api + Scenario: Assert "@Given the following :content_type content does not exist:" works as expected. + Given page content: + | title | + | [TEST] Page title1 | + | [TEST] Page title2 | + And I am logged in as a user with the "administrator" role + When I go to "content/test-page-title1" + Then I should get a 200 HTTP response + When I go to "content/test-page-title2" + Then I should get a 200 HTTP response + Given the following "page" content does not exist: + | title | + | [TEST] Page title1 | + | [TEST] Page title2 | + When I go to "content/test-page-title1" + Then I should get a 404 HTTP response + When I go to "content/test-page-title2" + Then I should get a 404 HTTP response + + @api + Scenario: Assert "When I visit the :content_type content page with the title :title" works as expected. Given page content: | title | | [TEST] Page title | - When I am logged in as a user with the "administrator" role - And I visit "page" "[TEST] Page title" + And I am logged in as a user with the "administrator" role + When I visit the "page" content page with the title "[TEST] Page title" Then I should see "[TEST] Page title" @trait:ContentTrait - Scenario: Assert visiting page with non-existing node throws an exception + Scenario: Assert negative "When I visit the :content_type content page with the title :title" works as expected for non-existing content type. Given some behat configuration And scenario steps: """ Given I am logged in as a user with the "administrator" role - Then I visit "page" "[TEST] Non-Existing Page title" + When I visit the "non_existing" content page with the title "[TEST] Page title" """ When I run "behat --no-colors" Then it should fail with an exception: """ - Unable to find page page "[TEST] Non-Existing Page title" + Content type "non_existing" does not exist. + """ + + @trait:ContentTrait + Scenario: Assert negative "When I visit the :content_type content page with the title :title" works as expected for non-existing content. + Given some behat configuration + And scenario steps: + """ + Given I am logged in as a user with the "administrator" role + When I visit the "page" content page with the title "[TEST] Non-existing" + """ + When I run "behat --no-colors" + Then it should fail with an exception: + """ + Unable to find "page" content with title "[TEST] Non-existing". """ @api - Scenario: Assert visiting edit page with title of specified content type + Scenario: Assert "When I visit the :content_type content edit page with the title :title" works as expected. Given page content: | title | | [TEST] Page title | - When I am logged in as a user with the "administrator" role - And I edit "page" "[TEST] Page title" + And I am logged in as a user with the "administrator" role + When I visit the "page" content edit page with the title "[TEST] Page title" Then I should see "[TEST] Page title" @trait:ContentTrait - Scenario: Assert visiting edit page with non-existing node throws an exception + Scenario: Assert negative "When I visit the :content_type content edit page with the title :title" works as expected for non-existing content type. + Given some behat configuration + And scenario steps: + """ + Given I am logged in as a user with the "administrator" role + When I visit the "non_existing" content edit page with the title "[TEST] Page title" + """ + When I run "behat --no-colors" + Then it should fail with an exception: + """ + Content type "non_existing" does not exist. + """ + + @trait:ContentTrait + Scenario: Assert negative "When I visit the :content_type content edit page with the title :title" works as expected for non-existing content. Given some behat configuration And scenario steps: """ Given I am logged in as a user with the "administrator" role - Then I edit "page" "[TEST] Non-Existing Page title" + When I visit the "page" content edit page with the title "[TEST] Non-existing" """ When I run "behat --no-colors" Then it should fail with an exception: """ - Unable to find page page "[TEST] Non-Existing Page title" + Unable to find "page" content with title "[TEST] Non-existing". """ @api - Scenario: Assert visiting delete page with title of specified content type + Scenario: Assert "When I visit the :content_type content delete page with the title :title" works as expected. Given page content: | title | | [TEST] Page title | - When I am logged in as a user with the "administrator" role - And I delete "page" "[TEST] Page title" + And I am logged in as a user with the "administrator" role + When I visit the "page" content delete page with the title "[TEST] Page title" Then I should see "[TEST] Page title" @trait:ContentTrait - Scenario: Assert delete page with non-existing node throws an exception + Scenario: Assert negative "When I visit the :content_type content delete page with the title :title" works as expected for non-existing content type. Given some behat configuration And scenario steps: """ Given I am logged in as a user with the "administrator" role - Then I delete "page" "[TEST] Non-Existing Page title" + When I visit the "non_existing" content delete page with the title "[TEST] Page title" """ When I run "behat --no-colors" Then it should fail with an exception: """ - Unable to find page page "[TEST] Non-Existing Page title" + Content type "non_existing" does not exist. """ - @api - Scenario: Assert removing page with title and specified type - Given page content: - | title | - | [TEST] Page title | - When I am logged in as a user with the "administrator" role - And I go to "content/test-page-title" - Then I should get a 200 HTTP response - When no page content: - | title | - | [TEST] Page title | - And I go to "content/test-page-title" - Then I should get a 404 HTTP response + @trait:ContentTrait + Scenario: Assert negative "When I visit the :content_type content delete page with the title :title" works as expected for non-existing content. + Given some behat configuration + And scenario steps: + """ + Given I am logged in as a user with the "administrator" role + When I visit the "page" content delete page with the title "[TEST] Non-existing" + """ + When I run "behat --no-colors" + Then it should fail with an exception: + """ + Unable to find "page" content with title "[TEST] Non-existing". + """ @api - Scenario: Assert visiting scheduled transition page with title of specified content type + Scenario: Assert "When I visit the :content_type content scheduled transitions page with the title :title" works as expected. Given page content: | title | | [TEST] Page title | And I am logged in as a user with the "administrator" role - When I visit "page" "[TEST] Page title" scheduled transitions + When I visit the "page" content scheduled transitions page with the title "[TEST] Page title" Then I should see "[TEST] Page title" - And save screenshot @trait:ContentTrait - Scenario: Assert visiting scheduled transition page with non-existing node throws an exception + Scenario: Assert negative "When I visit the :content_type content scheduled transitions page with the title :title" works as expected for non-existing content type. + Given some behat configuration + And scenario steps: + """ + Given I am logged in as a user with the "administrator" role + When I visit the "non_existing" content scheduled transitions page with the title "[TEST] Page title" + """ + When I run "behat --no-colors" + Then it should fail with an exception: + """ + Content type "non_existing" does not exist. + """ + + @trait:ContentTrait + Scenario: Assert negative "When I visit the :content_type content scheduled transitions page with the title :title" works as expected for non-existing content. Given some behat configuration And scenario steps: """ Given I am logged in as a user with the "administrator" role - When I visit "page" "[TEST] Non-Existing Page title" scheduled transitions + When I visit the "page" content scheduled transitions page with the title "[TEST] Non-existing" """ When I run "behat --no-colors" Then it should fail with an exception: """ - Unable to find page page "[TEST] Non-Existing Page title" + Unable to find "page" content with title "[TEST] Non-existing". """ @api - Scenario: Assert change moderation state of a content with specified title + Scenario: Assert "When I change the moderation state of the :content_type content with the title :title to the :new_state state" works as expected. Given page content: - | title | moderation_state | - | [TEST] Page title | draft | - And I am logged in as a user with the "administrator" role - Then I edit "page" "[TEST] Page title" - Then I should see "Draft" in the "#edit-moderation-state-0-current" element - When the moderation state of "page" "[TEST] Page title" changes from "draft" to "published" - And I edit "page" "[TEST] Page title" - Then I should see "Published" in the "#edit-moderation-state-0-current" element + | title |moderation_state| + | [TEST] Page title |draft | + And I am an anonymous user + When I visit the "page" content page with the title "[TEST] Page title" + Then the response status code should be 403 + When I change the moderation state of the "page" content with the title "[TEST] Page title" to the "published" state + And I visit the "page" content page with the title "[TEST] Page title" + Then the response status code should be 200 @trait:ContentTrait - Scenario: Assert change moderation state of a content with non-existing node throws an exception + Scenario: Assert negative "When I change the moderation state of the :content_type content with the title :title to the :new_state state" works as expected for non-existing content type. Given some behat configuration And scenario steps: """ Given I am logged in as a user with the "administrator" role - When the moderation state of "page" "[TEST] Non-Existing Page title" changes from "draft" to "published" + When I change the moderation state of the "non_existing" content with the title "[TEST] Page title" to the "published" state """ When I run "behat --no-colors" - Then it should fail with an error: + Then it should fail with an exception: """ - Unable to find page page "[TEST] Non-Existing Page title" + Content type "non_existing" does not exist. """ @trait:ContentTrait - Scenario: Assert change moderation state of a content with a different current state throws an exception + Scenario: Assert negative "When I change the moderation state of the :content_type content with the title :title to the :new_state state" works as expected for non-existing content. Given some behat configuration And scenario steps: """ - Given page content: - | title | moderation_state | - | [TEST] Page title | draft | - When the moderation state of "page" "[TEST] Page title" changes from "review" to "published" + Given I am logged in as a user with the "administrator" role + When I change the moderation state of the "page" content with the title "[TEST] Non-existing" to the "published" state """ When I run "behat --no-colors" - Then it should fail with an error: + Then it should fail with an exception: """ - The current state "draft" is different from "review" + Unable to find "page" content with title "[TEST] Non-existing". """ - @api - Scenario: Assert Delete content type - When I am logged in as a user with the "administrator" role - Then I visit "/admin/structure/types/add" - Then I fill in "Name" with "test_content_type" - And I fill in "Machine-readable name" with "test_content_type" - Then I press "Save" - Then I visit "/admin/structure/types" - Then I should see "test_content_type" - Given no "test_content_type" content type - Then I visit "/admin/structure/types" - Then I should not see "test_content_type" + @trait:ContentTrait + Scenario: Assert negative "When I change the moderation state of the :content_type content with the title :title to the :new_state state" works as expected for a node without moderation state enabled. + Given some behat configuration + And scenario steps: + """ + Given landing_page content: + | title | + | [TEST] Page title | + Given I am logged in as a user with the "administrator" role + When I change the moderation state of the "landing_page" content with the title "[TEST] Page title" to the "published" state + """ + When I run "behat --no-colors" + Then it should fail with an exception: + """ + State "published" is not defined in the workflow for "landing_page" content type. + """ diff --git a/tests/behat/features/date.feature b/tests/behat/features/date.feature index 119f607..49bc976 100644 --- a/tests/behat/features/date.feature +++ b/tests/behat/features/date.feature @@ -15,7 +15,7 @@ Feature: Check that DateTrait works Given "article" content: | title | created | status | moderation_state | | [TEST] Article 1 | [relative:-10 years] | 1 | published | - When I visit article "[TEST] Article 1" + When I visit the "article" content page with the title "[TEST] Article 1" Then the response status code should be 200 And I should see the text "201" diff --git a/tests/behat/features/file_download.feature b/tests/behat/features/file_download.feature index dee27ab..c50d553 100644 --- a/tests/behat/features/file_download.feature +++ b/tests/behat/features/file_download.feature @@ -24,7 +24,7 @@ Feature: Check that FileDownloadTrait works @api Scenario: Assert "Then I download file from link :link" - When I visit article "[TEST] document page" + When I visit the "article" content page with the title "[TEST] document page" Then I see download "example_text.txt" link "present" Then I download file from link "example_text.txt" And downloaded file contains: @@ -34,7 +34,7 @@ Feature: Check that FileDownloadTrait works @api Scenario: Assert "Given downloaded file is zip archive that contains files:" - When I visit article "[TEST] zip page" + When I visit the "article" content page with the title "[TEST] zip page" Then I see download "example_files.zip" link "present" Then I download file from link "example_files.zip" And downloaded file name is "example_files.zip" diff --git a/tests/behat/features/paragraphs.feature b/tests/behat/features/paragraphs.feature index 8ea8f26..98c2e10 100644 --- a/tests/behat/features/paragraphs.feature +++ b/tests/behat/features/paragraphs.feature @@ -3,7 +3,7 @@ Feature: Check that ParagraphsTrait works Background: Given I am logged in as a user with the "administrator" role - Given no landing_page content: + And the following "landing_page" content does not exist: | title | | [TEST] Landing page 1 | And landing_page content: @@ -15,7 +15,7 @@ Feature: Check that ParagraphsTrait works | field_paragraph_title | My paragraph title | | field_paragraph_body:value | My paragraph message | | field_paragraph_body:format | full_html | - And I visit landing_page "[TEST] Landing page 1" + When I visit the "landing_page" content page with the title "[TEST] Landing page 1" Then I should see the text "My paragraph title" And I should see the text "My paragraph message" diff --git a/tests/behat/features/wysiwyg.feature b/tests/behat/features/wysiwyg.feature index 6b5d3bd..9b4704c 100644 --- a/tests/behat/features/wysiwyg.feature +++ b/tests/behat/features/wysiwyg.feature @@ -6,7 +6,7 @@ Feature: Check that WysiywgTrait works. | title | | [TEST] Page title | And I am logged in as a user with the "administrator" role - And I edit "page" "[TEST] Page title" + And I visit the "page" content edit page with the title "[TEST] Page title" When I fill in WYSIWYG "Body" with "[TEST] value" And save screenshot And I press "Save" @@ -18,7 +18,7 @@ Feature: Check that WysiywgTrait works. | title | | [TEST-JS-Driver] Page title | And I am logged in as a user with the "administrator" role - And I edit "page" "[TEST-JS-Driver] Page title" + And I visit the "page" content edit page with the title "[TEST-JS-Driver] Page title" When I fill in WYSIWYG "Body" with "[TEST-JS-Driver] value" And save screenshot And I press "Save"