Overview
Home Assistant 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/home-assistant-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/home-assistant-steps/tests/step-definitions/*.js',
'tests/step-definitions/**/*.js',
]
Test users
The steps that log in use accounts that already exist on the site, by the handle a feature names (Given I am a logged in user with the "admin" user). The site build creates them; a feature never creates or deletes an account. They are listed in cucumber.js under worldParameters. These are the test accounts of the pack's own test site: put the accounts of your site in your project, and keep real passwords in environment variables.
{
"worldParameters": {
"users": {
"admin": {
"username": "admin"
}
}
}
}
Steps
- When I sign in to the smart home as "admin"
- When I sign in to the smart home as "admin" with a wrong password
- Given I am signed in to the smart home as "admin"
- Given I am signed in to the smart home's API as "admin"
- When I sign out of the smart home
- Then I should be signed in to the smart home
- Then the sign-in form should say "Invalid username or password"
- When I turn "Bed Light" on
- Then "Bed Light" should be on
- When I open the device "Bed Light"
- When I close the device's details
- Then the device "Bed Light" should show "Off"
- When I open the "Lights" summary
- Then the tile of "Bed Light" should say "Off"
- When I toggle the tile of "Bed Light"
- When I create the toggle helper "Webship test switch"
- When I delete the helper "Webship test switch"
- Then the helpers should list "Webship test switch"
- When I create the automation "Webship test lights" with this YAML:
- Then the automations should list "Webship test lights"
- Then the automation "Webship test lights" should have run
- When I delete the automation "Webship test lights"
- Then the smart home's notifications should show "Webship test notice"
- When I dismiss the smart home's notification "Login attempt failed"
- Then the activity should show "Bed Light" changed to "On"
- When I call the service "light.turn_on" on "light.bed_light"
- Then the entity "light.bed_light" should be "on"
- When I make the notification "Webship test notice"
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/home-assistant-steps.
Logo
The logo is Simple Icons' Home Assistant icon (icons/homeassistant.svg of simple-icons 16.37.0, CC0-1.0), in the colour the set lists for the brand; its path is unmodified. Home Assistant and its mark are the Open Home Foundation's: the logo names the app the pack tests. It is not covered by this package's licence.