@webship-js/odoo-steps 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,30 +2,37 @@
2
2
 
3
3
  [![Test](https://github.com/webship/odoo-steps/actions/workflows/test.yml/badge.svg)](https://github.com/webship/odoo-steps/actions/workflows/test.yml)
4
4
 
5
- Odoo-specific Cucumber step definitions for [webship-js](https://www.npmjs.com/package/webship-js) — a Playwright + Cucumber BDD testing framework. `@webship-js/odoo-steps` adds an `odoo.steps.js` step-pack that understands the markup the Odoo Website builder (and the eCommerce, Blog, Events, Jobs and core login modules bundled with it) render, so you can write readable Gherkin scenarios against the main pages of any Odoo site without hand-rolling CSS selectors.
5
+ Odoo step definitions for [webship-js](https://www.npmjs.com/package/webship-js), the Playwright and Cucumber testing framework. `@webship-js/odoo-steps` gives a tester plain-English steps for an Odoo site: logging in as a named user, opening an app and a menu, searching and grouping records, filling a form by the labels of its fields, saving, following the status bar, moving a kanban card, answering a dialog, reading a notification, writing in the chatter, checking access rights, and the pages of the website.
6
6
 
7
- It is a **plugin for webship-js** — it does not run standalone. It ships one file of step definitions; you drop it into an existing (or new) webship-js test project.
7
+ It is a plugin for webship-js and does not run alone. Add it to a webship-js project.
8
8
 
9
- ## What's covered
9
+ Every step is proven against a real Odoo 17.0 Community site with demo data, built for each run of this repository's suite (see [Running this repository's suite](#running-this-repositorys-suite)).
10
10
 
11
- - Homepage / core Website layout (`#wrapwrap`, top menu, footer)
12
- - Blog index and single post
13
- - Shop index, search, product page, add-to-cart, cart badge
14
- - Events index
15
- - Jobs listing
16
- - `/contactus` form
17
- - `/web/login` login form + authentication (and the invalid-login error path)
18
- - Sessions — log in as a named account from `worldParameters.users`, submit the login form robustly (an in-page submit that an overlay cannot block), and `Given I am not logged in` to end a session and land on the login form; for fast suites, snapshot an authenticated session once with webship-js's own `save the auth state` / `restore the auth state` steps
19
- - 404 page
11
+ ## What is covered
20
12
 
21
- See [tests/step-definitions/odoo.steps.js](tests/step-definitions/odoo.steps.js) for the full list of steps with Gherkin examples.
13
+ | Area | Steps | File |
14
+ | --- | --- | --- |
15
+ | Sessions | the login screen, logging in as a user of the registry, logging out from the user menu, who is logged in, the web client and the portal, the user menu | `odoo-session.steps.js` |
16
+ | Apps and menus | the apps menu, opening an app, a menu path (`Orders > Quotations`), an action by its external ID, the breadcrumb, the view switcher | `odoo-webclient.steps.js` |
17
+ | Search view | search, search in a named field, filters, grouping, facets, clearing the search | `odoo-webclient.steps.js` |
18
+ | List view | records, opening a record, counting, selecting, groups, the pager, the Actions menu | `odoo-webclient.steps.js` |
19
+ | Kanban view | columns, cards, counting, dragging a card to another column | `odoo-webclient.steps.js` |
20
+ | Form view | a new record, fields by label (text, number, date, selection, many2one, tags, checkbox, radio, priority), saving, a refused save, discarding, buttons, the status bar, tabs, lines of a list inside the form | `odoo-record.steps.js` |
21
+ | Dialogs and notifications | a dialog and its title, text and buttons, confirming and closing, the access error, notifications | `odoo-record.steps.js` |
22
+ | Chatter | logging a note, sending a message, reading the thread | `odoo-record.steps.js` |
23
+ | Website | the layout, blog, shop (search, product, cart), events, jobs, the contact form, the 404 page, opening and leaving the website editor | `odoo.steps.js` |
22
24
 
23
- The word "Odoo" is optional in every sentence: `Then I should see the top menu` and `Then I should see the Odoo top menu` are the same step, so a feature written for another webship-js step pack reads the same here. Every assertion takes `not` (`Then I should not see the login form`), waits for the page rather than reading it once, and fails with a message that says what was expected, why it failed and what to check.
25
+ [STEPS.md](STEPS.md) lists every step with what it does. Each step definition carries a comment with what it does, the markup it relies on and five `Example #n:` lines. The feature files in [tests/features/](tests/features/) use every step against the real site and are the best place to see them at work.
26
+
27
+ The steps wait on Odoo's own signals: the data requests of the web client and its "Loading" indicator. No step waits for a fixed time. A step that fails says what it expected, what it found and what to check, and lists what the page offers (the apps of the menu, the labels of the form, the buttons of the dialog).
28
+
29
+ No step phrase names the platform: a step reads `When I open the "CRM" app`, `When I save the record`. Every assertion takes `not`.
24
30
 
25
31
  ## Requirements
26
32
 
27
- - Node.js >= 20
28
- - An existing [webship-js](https://www.npmjs.com/package/webship-js) 2.x test project (or run `npx init-webship-js` to create one)
33
+ - Node.js 20 or later
34
+ - A [webship-js](https://www.npmjs.com/package/webship-js) 2.x project (`npx init-webship-js` creates one)
35
+ - An Odoo site to test. The steps are proven on Odoo 17.0 Community.
29
36
 
30
37
  ## Installation
31
38
 
@@ -33,83 +40,132 @@ The word "Odoo" is optional in every sentence: `Then I should see the top menu`
33
40
  npm install --save-dev webship-js @webship-js/odoo-steps
34
41
  ```
35
42
 
36
- Add both step-definition paths to your project's `cucumber.js`:
43
+ Add the step definitions to the `cucumber.js` of your project, and name your accounts in the users registry:
37
44
 
38
45
  ```javascript
39
46
  module.exports = {
40
47
  default: {
41
48
  require: [
42
- 'node_modules/webship-js/tests/step-definitions/**/*.js', // webship-js core steps
43
- 'node_modules/@webship-js/odoo-steps/tests/step-definitions/**/*.js', // this plugin
44
- 'tests/step-definitions/**/*.js', // your own custom steps, if any
49
+ 'node_modules/webship-js/tests/step-definitions/**/*.js', // webship-js steps
50
+ 'node_modules/@webship-js/odoo-steps/tests/step-definitions/**/*.js', // this pack
51
+ 'tests/step-definitions/**/*.js', // your own steps, if any
45
52
  ],
46
53
  paths: ['tests/features/**/*.feature'],
47
54
  worldParameters: {
48
- launchUrl: process.env.LAUNCH_URL || 'https://your-odoo-site.example',
49
- // Named accounts for `Given I am a logged in user with the "<key>" user`.
50
- // Keeps passwords out of feature files; override per environment.
55
+ launchUrl: process.env.LAUNCH_URL || 'https://your-project.ddev.site',
56
+ // The users registry: a handle a feature can read, mapped to a real account.
51
57
  users: {
52
- admin: {
53
- username: process.env.ODOO_ADMIN_USER || 'admin',
54
- password: process.env.ODOO_ADMIN_PASSWORD || 'admin',
55
- },
58
+ admin: { username: 'admin', password: process.env.ODOO_ADMIN_PASSWORD },
59
+ salesperson: { username: 'sam@example.com', password: process.env.ODOO_SALESPERSON_PASSWORD },
56
60
  },
61
+ // On a server that holds several databases, the one to log in to.
62
+ odoo: { database: process.env.ODOO_DATABASE || '' },
57
63
  // ...
58
64
  },
59
65
  },
60
66
  };
61
67
  ```
62
68
 
63
- This repo's own `tests/features/*.feature` files double as a working reference project.
69
+ Accounts are configuration. Create them once on the site under test, with the groups each one needs, and keep their passwords in the environment. A feature names a handle (`Given I am a logged in user with the "salesperson" user`); it never creates an account and never carries a password.
64
70
 
65
- ## Quick example
71
+ ## Example
66
72
 
67
73
  ```gherkin
68
- Feature: Odoo homepage
69
-
70
- Scenario: Homepage renders the Odoo Website layout
71
- Given I am an anonymous user
72
- And I am on the homepage
73
- Then I should be on an Odoo website page
74
- And the response status code should be 200
75
- And I should see the Odoo top menu
76
- And I should see the Odoo footer
74
+ Feature: Quotations
75
+
76
+ Scenario: A salesperson confirms a quotation
77
+ Given I am a logged in user with the "salesperson" user
78
+ When I open the "Sales" app
79
+ And I open the "Orders > Quotations" menu
80
+ And I create a new record
81
+ And I set the "Customer" field to "Azure Interior"
82
+ And I add a line with "Add a product":
83
+ | Product | Office Chair |
84
+ | Quantity | 3 |
85
+ And I save the record
86
+ And I click the "Confirm" button in the form
87
+ Then the status should be "Sales Order"
88
+ When I log the note "Confirmed by phone"
89
+ Then I should see "Confirmed by phone" in the chatter
90
+
91
+ Scenario: An employee without the Sales group is refused the quotations
92
+ Given I am a logged in user with the "employee" user
93
+ Then I should not see the "Sales" app
94
+ When I open the "sale.action_quotations_with_onboarding" action
95
+ Then I should see an access error
77
96
  ```
78
97
 
79
- More runnable examples: [tests/features/](tests/features/).
98
+ ## How a step finds things
99
+
100
+ - **A field** is named by the label the form shows ("Customer"), by the placeholder of its input ("e.g. Lumber Inc") or by its technical name ("partner_id"). `When I set the "..." field to "..."` fills it the way a user would for its kind: typed for a text, a number or a date, chosen for a selection, picked from the proposals for a many2one, added for tags, "yes" or "no" for a checkbox.
101
+ - **A record** in a list or a kanban view is named by a text it shows: its name or its reference.
102
+ - **A button, a menu, an app, a tab, a column** is named by its whole text, as it reads on screen, case-sensitive.
103
+ - **A dialog on top** takes the steps: while a dialog is open, a field or a button is looked for in the dialog.
104
+ - **Dates and numbers** are written in the format of the user's language, as a user types them.
80
105
 
81
- ## Running this repo's own test suite
106
+ The texts are the ones of the language the user works in. The suite of this repository runs in English.
82
107
 
83
- This repository is itself a working webship-js project — its `tests/features/*.feature` files run by default against a **self-hosted Odoo 17 instance managed by [DDEV](https://ddev.com/)** (`.ddev/`), seeded with Odoo's own demo data for Website, Blog, eCommerce, Events and Jobs. Public Odoo-built sites' bot-detection blocks and rate-limits automated CI traffic, so this repo never targets one.
108
+ ## Running this repository's suite
109
+
110
+ The repository is a working webship-js project. Its suite runs against an Odoo 17.0 Community site that [DDEV](https://ddev.com/) starts from `.ddev/` and `scripts/build-odoo.sh` builds: a database with Odoo's demo data, the apps the features use (Contacts, CRM, Sales, Invoicing, Website with its blog, shop, events and jobs) and the accounts of the users registry. The suite never targets a site outside the machine it runs on.
84
111
 
85
112
  ```bash
86
- ddev start
87
- ddev exec -s odoo -- odoo -d demo --db_host=db --db_user=odoo --db_password=odoo \
88
- --stop-after-init -i website,website_blog,website_sale,website_event,hr_recruitment
89
- docker restart ddev-odoo-steps-odoo # pick up the demo database
113
+ ddev start # Odoo 17.0 and PostgreSQL, at https://odoo-steps.ddev.site
114
+ bash scripts/build-odoo.sh # demo data, apps, accounts
90
115
 
91
116
  npm install
92
117
  npx playwright install --with-deps chromium
93
- npm test # runs against http://localhost:8069
94
- LAUNCH_URL=https://your-site.example npm test # runs against your own site instead
118
+ export NODE_EXTRA_CA_CERTS="$(mkcert -CAROOT)/rootCA.pem" # Node trusts DDEV's certificate
119
+ npm test # runs against https://odoo-steps.ddev.site
95
120
 
96
- ddev delete -Oy odoo-steps # tear down when done
121
+ ddev delete -Oy odoo-steps # remove the site when done
97
122
  ```
98
123
 
99
- Other scripts:
124
+ `LAUNCH_URL=https://another-odoo.example npm test` points the suite at another site; that site needs the same demo data and accounts.
125
+
126
+ The accounts `scripts/build-odoo.sh` creates (the password of each is its login, on this local site only):
127
+
128
+ | Handle | Login | Groups |
129
+ | --- | --- | --- |
130
+ | `admin` | `admin` | Administrator |
131
+ | `salesperson` | `salesperson` | Sales: own documents only |
132
+ | `accountant` | `accountant` | Invoicing: billing |
133
+ | `employee` | `employee` | Internal user, no app-specific group |
134
+ | `portal` | `portal` | Portal |
135
+
136
+ The build also uninstalls the `partner_autocomplete` module, which sends what a user types in a company name to an outside service; a test site should neither depend on such a service nor send data to it.
137
+
138
+ Scripts:
100
139
 
101
140
  | Script | Effect |
102
141
  | --- | --- |
103
- | `npm test` | Full suite, pretty output |
104
- | `npm run test:dry` | `--dry-run` — checks for undefined/ambiguous steps only |
105
- | `npm run test:examples` | No browser: every step's JSDoc carries five `Example #n:` lines that match its own definition and no other, and every feature step resolves to exactly one definition (also runs in CI) |
106
- | `npm run test:headed` | Headed browser |
107
- | `npm run test:chromium` / `test:firefox` / `test:webkit` | Pick a browser |
142
+ | `npm test` | The full suite |
143
+ | `npm run test:dry` | `--dry-run`: no undefined and no ambiguous step |
144
+ | `npm run test:examples` | No browser: every step has five `Example #n:` lines that match its own definition and no other, and every feature step resolves to one definition |
145
+ | `npm run docs:steps` | Writes [STEPS.md](STEPS.md) from the step definitions; `npm run docs:steps:check` fails when it is out of date |
146
+ | `npm run test:headed` | The suite in a visible browser |
147
+ | `npm run test:chromium`, `test:firefox`, `test:webkit` | The suite in one browser |
148
+
149
+ Settings read from the environment:
150
+
151
+ - `FEATURES=tests/features/a.feature,tests/features/b.feature npm test` runs some feature files; `CUCUMBER_TAGS=@critical npm test` runs the scenarios with a tag (the default run leaves `@wip` out).
152
+ - `ODOO_<HANDLE>_USER` and `ODOO_<HANDLE>_PASSWORD` set the login and the password of a registry account, for example `ODOO_ADMIN_PASSWORD`.
153
+ - `ODOO_DATABASE` names the database to log in to on a server that holds several.
154
+ - `WEBSHIP_VIDEO=on-failure` records the browser; `WEBSHIP_JS_ERROR_MODE=fail` fails a scenario on a JavaScript error (`@js-off` silences one scenario).
155
+ - `WEBSHIP_STEP_TIMEOUT=<milliseconds>` changes the step timeout of webship-js (45 seconds); a `timeout` key in `cucumber.js` does not.
156
+
157
+ ## Limits
158
+
159
+ - Proven on Odoo 17.0 Community, in English. Odoo Enterprise shows its apps on a home screen instead of a menu; the app steps look for both, and only the Community menu is proven by this suite.
160
+ - Odoo 18 and later serve the web client under `/odoo` instead of `/web#...`. `When I open the "..." action` builds that address from the version the server reports, but no step is proven on those versions yet.
161
+ - A server with several databases is supported through `worldParameters.odoo.database`; the database selector itself has no step.
162
+ - The website editor steps open the editor, read its building blocks and leave it; dragging a building block into a page has no step yet.
163
+ - `When I send the message "..."` posts to the followers of the record. On a test site, make sure outgoing mail does not reach real addresses.
108
164
 
109
165
  ## Contributing
110
166
 
111
- Issues and pull requests are tracked on GitHub. `2.0.x` is the repository's single active branch.
167
+ Issues and pull requests are tracked on [GitHub](https://github.com/webship/odoo-steps). `2.0.x` is the active branch.
112
168
 
113
169
  ## License
114
170
 
115
- MIT © Webship.co — see [LICENSE](LICENSE).
171
+ MIT © Webship.co. See [LICENSE](LICENSE).
package/STEPS.md ADDED
@@ -0,0 +1,141 @@
1
+ # Steps
2
+
3
+ Every step of `@webship-js/odoo-steps`, written from the step definitions by `npm run docs:steps`. Each step is shown by its first example; the comment above its definition gives four more and names the markup the step relies on. Every assertion takes `not`.
4
+
5
+ ## Sessions
6
+
7
+ `tests/step-definitions/odoo-session.steps.js`, 14 steps.
8
+
9
+ | Step | What it does |
10
+ | --- | --- |
11
+ | `Given I am on the login page` | Navigate to the login screen at `/web/login`. |
12
+ | `Then I should see the login form` | Assert the login form is, or is not, visible. |
13
+ | `When I log in as "admin" with password "secret"` | Fill and submit the login form with the given login and password, for scenarios where the credentials are the subject (a wrong password, a disabled account). |
14
+ | `Given I am a logged in user with the "admin" user` | Log in as a user of the registry in cucumber.js (`worldParameters.users`), so no password appears in a feature file. |
15
+ | `Given I am not logged in` | End any session and land on the login screen as a visitor. |
16
+ | `Then I should see an login error` | Assert the login screen is, or is not, showing an error, optionally with a text. |
17
+ | `When I log out` | Log out the way a user does. |
18
+ | `Then I should be logged in` | Assert the browser holds, or does not hold, a session, as the server reports it (`/web/session/get_session_info`). |
19
+ | `Then I should be logged in as "admin"` | Assert the session belongs, or does not belong, to the given user. |
20
+ | `Then I should be in the web client` | Assert the page is, or is not, the web client. |
21
+ | `Then I should be in the portal` | Assert the page is, or is not, the portal. |
22
+ | `When I open the user menu` | Open the user menu. |
23
+ | `Then I should see "My Profile" in the user menu` | Assert the user menu offers, or does not offer, an entry. |
24
+ | `When I choose "My Profile" in the user menu` | Choose an entry of the user menu, for example "My Profile". |
25
+
26
+ ## Web client: apps, menus, search, list and kanban views
27
+
28
+ `tests/step-definitions/odoo-webclient.steps.js`, 33 steps.
29
+
30
+ | Step | What it does |
31
+ | --- | --- |
32
+ | `When I open the "CRM" app` | Open an app from the apps menu of the navigation bar, by its name, and wait for its first screen. |
33
+ | `Then I should see the "CRM" app` | Assert the apps menu lists, or does not list, an app. |
34
+ | `Then I should be in the "CRM" app` | Assert the app on screen is, or is not, the given one. |
35
+ | `When I open the "Orders > Quotations" menu` | Open a menu of the current app, by its path in the menu bar. |
36
+ | `Then I should see the "Orders" menu` | Assert the menu bar of the current app offers, or does not offer, a menu. |
37
+ | `When I open the "sale.action_quotations_with_onboarding" action` | Open an action by its external ID (`module.xml_id`), for example `sale.action_quotations_with_onboarding`. |
38
+ | `Then I should see "Quotations" in the breadcrumb` | Assert the breadcrumb of the control panel shows, or does not show, a text. |
39
+ | `Then the breadcrumb title should be "Quotations"` | Assert the title of the current screen, the last part of the breadcrumb (`.o_last_breadcrumb_item`), is or is not the given text. |
40
+ | `When I go back to "Quotations" in the breadcrumb` | Go back through the breadcrumb. |
41
+ | `When I switch to the list view` | Switch the view with the view switcher of the control panel (`.o_cp_switch_buttons`). |
42
+ | `Then I should see the list view` | Assert the view on screen is, or is not, of the given type (`.o_list_view`, `.o_kanban_view`, `.o_form_view`, ...). |
43
+ | `When I search the records for "chair"` | Search the records on screen. |
44
+ | `When I filter the records by "Won"` | Turn a filter of the search options on or off, by its name under "Filters". |
45
+ | `When I group the records by "Salesperson"` | Group the records by an entry of "Group By" in the search options. |
46
+ | `Then I should see the "My Pipeline" search facet` | Assert the search view shows, or does not show, a facet with the given text. |
47
+ | `When I remove the "My Pipeline" search facet` | Remove one facet of the search view, by its text, with its "Remove" button. |
48
+ | `When I clear the search` | Clear the search view. |
49
+ | `Then I should see the "Azure Interior" record` | Assert a record is, or is not, on screen. |
50
+ | `When I open the "Azure Interior" record` | Open a record from the list or the kanban view on screen, by a text it shows, and wait for its form view. |
51
+ | `Then I should see 3 records` | Assert the number of records on screen. |
52
+ | `Then I should see no records` | Assert the list or the kanban view shows no record. |
53
+ | `When I select the "S00007" record` | Select or unselect a record of the list view with its checkbox, by a text the row shows. |
54
+ | `When I select all records` | Select every record of the page with the checkbox of the list header. |
55
+ | `Then I should see 1 selected record` | Assert the number of selected records, as the control panel reports it ("3 selected", `.o_list_selection_box`). |
56
+ | `When I choose "Delete" in the Actions menu` | Choose an entry of the "Actions" menu of the control panel (the gear on a form view). |
57
+ | `Then I should see the "Mitchell Admin" group` | Assert the list view shows, or does not show, a group with the given name. |
58
+ | `When I open the "Mitchell Admin" group` | Open or close a group of a grouped list view, by its name, to show or hide its records. |
59
+ | `Then the pager should read "1-15 / 15"` | Assert what the pager of the control panel reads. |
60
+ | `When I go to the next page of records` | Go to the next or the previous page of records (on a form view. |
61
+ | `Then I should see the "New" column` | Assert the kanban view shows, or does not show, a column with the given title (`.o_kanban_group .o_column_title`). |
62
+ | `Then I should see the "Quote for 600 Chairs" card in the "Qualified" column` | Assert a card is, or is not, in a column of the kanban view. |
63
+ | `Then the "New" column should have 2 cards` | Assert the number of cards a column of the kanban view shows. |
64
+ | `When I drag the "Quote for 600 Chairs" card to the "Proposition" column` | Move a card of the kanban view to another column by dragging it, the way a user moves an opportunity to another stage. |
65
+
66
+ ## Records: form view, dialogs, notifications and chatter
67
+
68
+ `tests/step-definitions/odoo-record.steps.js`, 32 steps.
69
+
70
+ | Step | What it does |
71
+ | --- | --- |
72
+ | `When I create a new record` | Start a new record with the "New" button of the control panel (`.o_list_button_add`, `.o-kanban-button-new`, `.o_form_button_create`) and wait for the empty form. |
73
+ | `When I save the record` | Save the record on the form view with the save button of the control panel (`.o_form_button_save`) and wait for the server. |
74
+ | `When I try to save the record` | Click the save button of the form view without expecting the save to succeed, for a scenario whose subject is the refusal. |
75
+ | `When I discard the changes` | Discard the changes of the form view with the discard button of the control panel (`.o_form_button_cancel`). |
76
+ | `Then the record should have unsaved changes` | Assert the form view has, or does not have, unsaved changes. |
77
+ | `When I set the "Customer" field to "Azure Interior"` | Set a field of the form to a value. |
78
+ | `When I set the fields:` | Set several fields of the form from a table. |
79
+ | `When I check the "Can be Sold" field` | Check or uncheck a checkbox field of the form, named like any other field. |
80
+ | `When I remove "Product" from the "Tags" field` | Remove a tag from a tags field of the form, by its text. |
81
+ | `Then the "Customer" field should be "Azure Interior"` | Assert the value a field of the form shows. |
82
+ | `Then the "Can be Sold" field should be checked` | Assert a checkbox field of the form is, or is not, checked. |
83
+ | `Then I should see the "Customer" field` | Assert the form shows, or does not show, a field. |
84
+ | `Then the "Customer" field should be required` | Assert a field of the form is, or is not, required, read-only or marked as invalid, from the classes Odoo puts on the field (`o_required_modifier`, `o_readonly_modifier`, `o_field_invalid`). |
85
+ | `When I click the "Confirm" button in the form` | Click a button of the form by its text. |
86
+ | `Then I should see the "Confirm" button in the form` | Assert the form offers, or does not offer, a button with the given text. |
87
+ | `Then the status should be "Sales Order"` | Assert the status the status bar of the form highlights (`.o_statusbar_status .o_arrow_button_current`). |
88
+ | `When I set the stage to "Proposition"` | Change the stage of the record by clicking a stage of the status bar, the way a user moves an opportunity to "Proposition". |
89
+ | `When I open the "Order Lines" tab` | Open a tab of the form's notebook by its title (`.o_notebook_headers .nav-link`), to reach the fields it holds. |
90
+ | `Then I should see the "Order Lines" tab` | Assert the form offers, or does not offer, a tab with the given title. |
91
+ | `When I add a line with "Add a product":` | Add a line to the list of the open tab (order lines, invoice lines) and fill its cells from a table. |
92
+ | `Then I should see the line "Office Chair"` | Assert a list of the form shows, or does not show, a line with the given text (the product of an order line, the label of an invoice line). |
93
+ | `Then I should see a dialog` | Assert a dialog is, or is not, open, optionally with a title (`.modal[role="dialog"] .modal-title`). |
94
+ | `Then I should see "Are you sure" in the dialog` | Assert the dialog on top shows, or does not show, a text in its body. |
95
+ | `When I click the "Ok" button in the dialog` | Click a button of the dialog on top by its text ("Ok", "Discard", "Save & Close", the action of a wizard) and wait for what it starts. |
96
+ | `When I confirm the dialog` | Confirm the dialog on top with its main button (the primary button of the footer. |
97
+ | `Then I should see an access error` | Assert Odoo shows, or does not show, an access error. |
98
+ | `Then I should see the notification "Invalid fields"` | Assert Odoo shows, or does not show, a notification with the given text. |
99
+ | `When I close the notifications` | Close the notifications on screen with their close button, so that they do not cover a button a later step needs. |
100
+ | `Then I should see the chatter` | Assert the form shows, or does not show, the chatter. |
101
+ | `When I log the note "Called the customer, waiting for the order"` | Log an internal note on the record with the "Log note" button of the chatter, and wait for the note to appear in the thread. |
102
+ | `When I send the message "Your order is confirmed"` | Send a message on the record with the "Send message" button of the chatter, and wait for the message to appear in the thread. |
103
+ | `Then I should see "Called the customer" in the chatter` | Assert the chatter shows, or does not show, a text in one of its messages (`.o-mail-Message`). |
104
+
105
+ ## Website
106
+
107
+ `tests/step-definitions/odoo.steps.js`, 29 steps.
108
+
109
+ | Step | What it does |
110
+ | --- | --- |
111
+ | `Then I should be on a website page` | Assert the current page was, or was not, rendered by the Odoo Website builder. |
112
+ | `Then I should see the top menu` | Assert the Website top menu (main navigation) is, or is not, visible. |
113
+ | `Then I should see the footer` | Assert the Website footer is, or is not, visible. |
114
+ | `Then I should be on the blog page` | Assert the current page is, or is not, the Blog index/listing template. |
115
+ | `Then I should be on an blog post page` | Assert the current page is, or is not, a single blog post template. |
116
+ | `Then I should see the blog post titled "Customer Reviews"` | Assert the blog post on screen has, or does not have, the given title. |
117
+ | `Then I should be on the shop page` | Assert the current page is, or is not, the eCommerce shop/catalog template. |
118
+ | `Then I should be on an product page` | Assert the current page is, or is not, an eCommerce product page. |
119
+ | `When I open the first product in the shop` | Open a product from the shop grid on screen. |
120
+ | `When I search the shop for "mug"` | Submit the shop's search form with the given term. |
121
+ | `Then I should see shop search results for "desk"` | Assert the shop search returned, or did not return, products for the given term. |
122
+ | `Then I should see the "Customizable Desk" product in the shop` | Assert the shop grid lists, or does not list, a product by its name (`#products_grid .o_wsale_products_item_title`). |
123
+ | `When I add the product to the cart` | Add the product on screen to the cart. |
124
+ | `Then I should see "1" item in the cart` | Assert the cart badge shows, or does not show, the given item count. |
125
+ | `Then I should be on the events page` | Assert the current page is, or is not, the Events index/listing template. |
126
+ | `Then I should be on the jobs page` | Assert the current page is, or is not, the Jobs (recruitment) listing template. |
127
+ | `Then I should see job openings` | Assert at least one job opening link is, or none is, visible on the Jobs page. |
128
+ | `Given I am on the contact us page` | Navigate to the "Contact us" page at `/contactus` and check that the site serves it. |
129
+ | `Then I should see the contact us form` | Assert the "Contact us" form is, or is not, visible. |
130
+ | `When I fill in the contact form with:` | Fill the contact form from a table. |
131
+ | `When I submit the contact form` | Submit the contact form with its button (`.s_website_form_send`) and wait for the answer of the site. |
132
+ | `Then I should see the contact form confirmation` | Assert the site confirmed, or did not confirm, the contact form. |
133
+ | `Then I should see a contact form error` | Assert the contact form shows, or does not show, an error after it was submitted. |
134
+ | `Then I should be able to edit the website` | Assert the current user can, or cannot, edit the website. |
135
+ | `When I open the website editor` | Open the website editor on a page. |
136
+ | `Then I should see the website editor` | Assert the website editor is, or is not, open. |
137
+ | `Then I should see the "Text" building block` | Assert the website editor offers, or does not offer, a building block, by its name in the "Blocks" tab of the editor panel (`#oe_snippets .oe_snippet`). |
138
+ | `When I save the website editor` | Leave the website editor with its "Save" or its "Discard" button and wait for the editor to close. |
139
+ | `Then I should be on the 404 page` | Assert the current page is, or is not, the core 404 template, by checking the page heading for "404" (rendered by `addons/http_routing`'s `http_routing.404` template on every Odoo site). |
140
+
141
+ 108 steps.
package/package.json CHANGED
@@ -1,17 +1,20 @@
1
1
  {
2
2
  "name": "@webship-js/odoo-steps",
3
- "version": "2.0.0",
4
- "description": "Odoo-specific Cucumber step definitions plugin for webship-js — BDD testing for the main pages of any Odoo Website site (Playwright + Cucumber).",
3
+ "version": "2.1.0",
4
+ "description": "Odoo step definitions for webship-js (Playwright and Cucumber): sessions and the users registry, apps and menus, the search, list, kanban and form views, dialogs, notifications, the chatter, access rights and the website.",
5
5
  "main": "tests/step-definitions/odoo.steps.js",
6
6
  "files": [
7
- "tests/step-definitions/odoo.steps.js",
7
+ "tests/step-definitions/",
8
8
  "README.md",
9
+ "STEPS.md",
9
10
  "LICENSE"
10
11
  ],
11
12
  "scripts": {
12
13
  "test": "cucumber-js --config cucumber.js",
13
14
  "test:dry": "cucumber-js --config cucumber.js --dry-run",
14
15
  "test:examples": "node tests/check-examples.js",
16
+ "docs:steps": "node tests/list-steps.js",
17
+ "docs:steps:check": "node tests/list-steps.js --check",
15
18
  "test:chromium": "BROWSER=chromium cucumber-js --config cucumber.js",
16
19
  "test:firefox": "BROWSER=firefox cucumber-js --config cucumber.js",
17
20
  "test:webkit": "BROWSER=webkit cucumber-js --config cucumber.js",
@@ -1 +1,11 @@
1
- # Step Definitions
1
+ # Step definitions
2
+
3
+ | File | Steps for |
4
+ | --- | --- |
5
+ | `odoo-session.steps.js` | The login screen, the users registry, logging out, the user menu, the web client and the portal |
6
+ | `odoo-webclient.steps.js` | Apps, menus, actions, the breadcrumb, the view switcher, the search view, the list view and the kanban view |
7
+ | `odoo-record.steps.js` | The form view and its fields, saving, buttons, the status bar, tabs, lines, dialogs, notifications, the chatter and the access error |
8
+ | `odoo.steps.js` | The website: layout, blog, shop, events, jobs, the contact form, the website editor and the 404 page |
9
+ | `odoo-helpers.js` | What the step files share; it defines no step |
10
+
11
+ Each step definition has a comment that says what the step does, names the markup it relies on and gives five `Example #n:` lines. `npm run test:examples` checks the examples against the definitions.