Overview
Grafana 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/grafana-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/grafana-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 observability platform as "admin"
- When I sign in to the observability platform as "admin" with a wrong password
- Given I am signed in to the observability platform as "admin"
- Given I am signed in to the observability platform's API as "admin"
- When I sign out of the observability platform
- Then I should be signed in to the observability platform
- Then the login of the observability platform should say "Invalid username or password"
- When I open the observability platform's dashboard "Webship shop"
- Then the panel "Orders today" should show "42"
- Then the table "Orders by region" should have the row "north 12"
- When I set the time range to "Last 24 hours"
- Then the time range should be "Last 24 hours"
- When I set the variable "region" to "north"
- When I mark the dashboard as a favourite
- Then the dashboard should be a favourite
- When I delete the observability platform's dashboard "Webship test copy"
- Given I make the dashboard "Webship test copy" from this JSON:
- Then the dashboards should list "Webship shop"
- When I add the "TestData" data source named "Webship test data"
- Then the data source "Webship test data" should be working
- When I delete the data source "Webship test data"
- When I run the "CSV Metric Values" query with "7,8,42" in Explore
- Then the query's table should show "42"
- Then the alert rule "Webship test orders" should be firing
- When I delete the alert rule "Webship test orders"
- Then the observability platform's database should be "ok"
- When I make the annotation "Webship test deploy" on the dashboard "webship-shop"
- Then the dashboard "webship-shop" should have the annotation "Webship test deploy"
- Then the dashboard "webship-shop" should be titled "Webship shop"
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/grafana-steps.
Logo
The logo is Simple Icons' Grafana icon (icons/grafana.svg of simple-icons 16.37.0, CC0-1.0), in the colour the set lists for the brand; its path is unmodified. Grafana and its mark are Grafana Labs': the logo names the app the pack tests. It is not covered by this package's licence.