Overview
Drupal Core Steps adds step definitions to Webship-js 2.0.x for the markup the platform itself renders, regardless of theme or distribution, so scenarios read as plain sentences instead of CSS selectors. It is a plugin for Webship-js: it ships one file of step definitions you drop into an existing test project, and it composes with the built-in steps rather than duplicating them.
Install
npm install --save-dev @webship-js/drupal-core-steps
Then add its step file to cucumber.js beside the Webship-js steps:
require: [
'node_modules/webship-js/tests/step-definitions/**/*.js',
'node_modules/@webship-js/drupal-core-steps/tests/step-definitions/*.js',
'tests/step-definitions/**/*.js',
]
Steps
- Then I should be denied access to "/admin/people"
- Then I should be allowed access to "/admin/content"
- Then the page should be access restricted
- Then I should be able to edit the content at "/sample-article"
- Then the page should not have PHP errors
- Then the "Article" content type should exist
- When I save the content
- Then the "Title" field should block submission as required
- Then the content moderation state should be "Draft"
- When I change the moderation state to "Published"
- Given I am on the login page
- Then I should see the login form
- Then the site should be running Drupal
- Then the core JavaScript settings should be initialized
- Then I should be on the front page
- Then I should be on an admin page
- Then I should see the toolbar
- Then I should see the navigation sidebar
- Then I should see the breadcrumb
- Then I should see the local tasks
- Then I should see the page title "Log in"
- Then I should see a status message
- Then I should see a warning message
- Then I should see an error message
- Then I should be on an "article" page
- When I create an "article" content item titled "Release notes"
- Then I should see an empty listing
- When I log in as "admin" with password "admin"
- Then I should be logged in
- When I log out
- When I request a new password for "admin"
- When I search for "webship"
- Then I should see search results
- When I submit the contact form with subject "Question" and message "Hello there"
- Then I should be on the access denied page
- Then the page should be served from the page cache
- Given I am a logged in user with the "admin" user
- Given I am not logged in
- Then the page should return HTTP status 200
- Then I should see the "Edit" operation for the "Sample article" content
- When I open the "Edit" link in the "Sample article" row
- Then "Home" should be in the breadcrumb
- Then the checkbox labeled "Published" should be checked
- Then I should see an image with the "Sample image alt text" alt text
- When I fill in the rich text editor field "Body" with "Hello from the suite"
- When I append the rich text editor field "Body" with "<p>One more paragraph</p>"
- When I click on "Bold" command button in the rich text editor field "Body"
- When I open the "field_media" media library
- When I select the media "Sample image"
- When I insert the selected media
- Given I am adding an "article"
- Then the content item should be published
- When I delete the content item I am viewing
- When I flush all caches
- When I submit by id "edit-submit"
- When I expand the "Menu settings" details
- When I open the "Promotion options" vertical tab
- When I wait for the AJAX throbber to disappear
- When I confirm the deletion
- When I fill in the link URL "https://example.com"
- When I choose the "Sample article" autocomplete suggestion
- Then the rich text editor field "Body" should contain "Hello"
- Then the rich text editor toolbar should have the "Bold" button
- When I view the content item I created
- When I edit the content item I created
- When I delete the content item I created
- When I create a "tags" taxonomy term named "Playwright"
- When I add a menu link titled "Sample" to "/sample-article" in the "main" menu
- When I open the layout of the content item I am viewing
- When I add a "Two column" section at the end of the layout
- When I save the section
- When I save the layout
- Then the layout should have 1 section
- When I revert the layout to the default
- Then the navigation toolbar should list "Content"
- When I click "Content" in the navigation toolbar
- When I open the top bar page actions
- Then the top bar should offer the "Edit" action
- When I choose the "Edit" action in the top bar
- Then the "node" module should be installed
- Then the default theme should be "Olivero"
- Given I am on the default theme settings page
- Then the "Content editor" role should exist
- Then the "Main navigation" menu should contain "Home"
- Then the front page path should be "/node"
- Then the page should have the canonical URL "/sample-article"
- Then the "description" meta tag should contain "Sample"
- Given I add the testing users
- Given I delete the testing users
Every assertion step reads both polarities from one definition: should see and should not see are the same step. Source and issues: github.com/webship/drupal-core-steps.