@webship-js/nextjs-steps 0.0.0-stage → 2.0.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/LICENSE +21 -0
- package/README.md +575 -2
- package/package.json +64 -4
- package/tests/features/README.md +28 -0
- package/tests/features/build.feature +24 -0
- package/tests/features/default-app.feature +33 -0
- package/tests/features/development.feature +24 -0
- package/tests/features/errors.feature +38 -0
- package/tests/features/forms.feature +56 -0
- package/tests/features/images.feature +38 -0
- package/tests/features/loading.feature +43 -0
- package/tests/features/navigation.feature +46 -0
- package/tests/features/pages-router.feature +35 -0
- package/tests/features/search-and-pagination.feature +37 -0
- package/tests/features/session.feature +59 -0
- package/tests/step-definitions/README.md +30 -0
- package/tests/step-definitions/nextjs-errors.steps.js +250 -0
- package/tests/step-definitions/nextjs-forms.steps.js +266 -0
- package/tests/step-definitions/nextjs-helpers.js +1036 -0
- package/tests/step-definitions/nextjs-images.steps.js +200 -0
- package/tests/step-definitions/nextjs-loading.steps.js +170 -0
- package/tests/step-definitions/nextjs-navigation.steps.js +194 -0
- package/tests/step-definitions/nextjs-pages.steps.js +204 -0
- package/tests/step-definitions/nextjs-session.steps.js +254 -0
package/package.json
CHANGED
|
@@ -1,6 +1,66 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webship-js/nextjs-steps",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Cucumber step definitions for apps built with Next.js, a plugin for webship-js (Playwright and Cucumber): hydration, client-side navigation and the route announcer, prefetching, streaming and loading states, form actions and their pending states, the not-found and error pages, the image component's lazy and optimized images, static and dynamic pages, the production build and the development error overlay, and a login form with sessions, each step waiting on the framework's own signals, never on a clock.",
|
|
5
|
+
"main": "tests/step-definitions/nextjs-helpers.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"tests/step-definitions/",
|
|
8
|
+
"tests/features/",
|
|
9
|
+
"README.md",
|
|
10
|
+
"LICENSE"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"test": "cucumber-js --config cucumber.js",
|
|
14
|
+
"test:dry": "cucumber-js --config cucumber.js --dry-run",
|
|
15
|
+
"test:examples": "node tests/check-examples.js",
|
|
16
|
+
"test:paths": "node tests/check-paths.js",
|
|
17
|
+
"test:must-fail": "node tests/check-must-fail.js",
|
|
18
|
+
"test:chromium": "BROWSER=chromium cucumber-js --config cucumber.js",
|
|
19
|
+
"test:firefox": "BROWSER=firefox cucumber-js --config cucumber.js",
|
|
20
|
+
"test:webkit": "BROWSER=webkit cucumber-js --config cucumber.js",
|
|
21
|
+
"test:headed": "HEADLESS=false cucumber-js --config cucumber.js",
|
|
22
|
+
"generate-reports": "generate-reports",
|
|
23
|
+
"test:fast": "SLOW_MO=0 cucumber-js --config cucumber.js"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"webship-js",
|
|
27
|
+
"nextjs",
|
|
28
|
+
"next.js",
|
|
29
|
+
"react",
|
|
30
|
+
"hydration",
|
|
31
|
+
"server-actions",
|
|
32
|
+
"cucumber",
|
|
33
|
+
"cucumber-js",
|
|
34
|
+
"playwright",
|
|
35
|
+
"bdd",
|
|
36
|
+
"testing",
|
|
37
|
+
"e2e",
|
|
38
|
+
"gherkin"
|
|
39
|
+
],
|
|
40
|
+
"author": "Webship.co",
|
|
41
|
+
"license": "MIT",
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "git+https://github.com/webship/nextjs-steps.git"
|
|
45
|
+
},
|
|
46
|
+
"bugs": {
|
|
47
|
+
"url": "https://github.com/webship/nextjs-steps/issues"
|
|
48
|
+
},
|
|
49
|
+
"homepage": "https://github.com/webship/nextjs-steps#readme",
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"access": "public"
|
|
52
|
+
},
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">= 20.0"
|
|
55
|
+
},
|
|
56
|
+
"peerDependencies": {
|
|
57
|
+
"webship-js": "^2.0.16"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"tsx": "^4.23.0",
|
|
61
|
+
"webship-js": "^2.0.16"
|
|
62
|
+
},
|
|
63
|
+
"overrides": {
|
|
64
|
+
"@cucumber/cucumber": "^12"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Features
|
|
2
|
+
|
|
3
|
+
Reference features for the apps that `.github/scripts/build-ddev-site.sh`
|
|
4
|
+
builds. Each feature carries the tag of the app it runs on: `@learn` (the
|
|
5
|
+
finished app of the official Learn course with the suite's own test data and
|
|
6
|
+
the two accounts of `cucumber.js`, `administrator` and `editor`),
|
|
7
|
+
`@default-app` (the app `create-next-app` makes with its defaults) and
|
|
8
|
+
`@pages-router` (the official Pages Router example); `@development` runs on the
|
|
9
|
+
development server. Copy a feature into your project and replace the
|
|
10
|
+
addresses, links, labels and texts with those of your app.
|
|
11
|
+
|
|
12
|
+
| Feature | Covers |
|
|
13
|
+
| --- | --- |
|
|
14
|
+
| `session` | A visitor sent to the login form, which keeps the page asked for; each account logging in through the form; a wrong password and an unknown address refused; the login button busy while its answer is held back; a session taken over; logging out. |
|
|
15
|
+
| `navigation` | The side navigation without a full page reload and the route announcer, back and forward, the pages fetched ahead of a click, the route announcer of a first page, a page opened from its address. |
|
|
16
|
+
| `search-and-pagination` | A search put in the address and the list it gives, a search in the address filling in the search box, the pages of the list. |
|
|
17
|
+
| `forms` | The errors of the server next to each field and for the whole form, an error gone once its field is right, an invoice created, listed and deleted, an invoice changed and put back. |
|
|
18
|
+
| `loading` | A loading state on a slow network while a search streams in (`@since-16`), a page whose parts stream in one after the other, the router keeping its page while the answer of a navigation is held back. |
|
|
19
|
+
| `errors` | The app's own not-found page, the default one, the error page of a part that fails without the details of the error, a page that exists. |
|
|
20
|
+
| `build` | A hydrated production build of the app router, prerendered pages and pages rendered for each request. |
|
|
21
|
+
| `images` | Lazy, optimized and sized images, the format the optimizer sends, the picture made for a small screen. |
|
|
22
|
+
| `development` | The development server's tools, and its error overlay with the details of a part that fails. |
|
|
23
|
+
| `default-app` | The start page of a new app: a hydrated, prerendered production build, its preloaded and lazy images, the default not-found page. |
|
|
24
|
+
| `pages-router` | The Pages Router example: a hydrated, prerendered production build, its links without a full page reload and announced, a prefetched page, the default not-found page. |
|
|
25
|
+
|
|
26
|
+
Scenarios that change something change it back in the same scenario: an
|
|
27
|
+
invoice created is deleted, an amount changed is put back. No scenario creates
|
|
28
|
+
or deletes a user.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
@learn
|
|
2
|
+
Feature: The production build
|
|
3
|
+
As the owner of the app
|
|
4
|
+
I want it served as a production build, prerendered where it can be
|
|
5
|
+
So that the visitors get the fast pages and never the development tools
|
|
6
|
+
|
|
7
|
+
@critical
|
|
8
|
+
Scenario: The pages are a hydrated production build of the app router
|
|
9
|
+
Given I am an anonymous user
|
|
10
|
+
When I go to "/"
|
|
11
|
+
Then the site should be served as a production build
|
|
12
|
+
And the page should be served by the app router
|
|
13
|
+
And the page should not run on the release "14"
|
|
14
|
+
And I should see a hydrated page
|
|
15
|
+
And there should be no hydration errors
|
|
16
|
+
And the development tools should not be on the page
|
|
17
|
+
And the development error overlay should not be shown
|
|
18
|
+
|
|
19
|
+
Scenario: Pages with no input of their own are prerendered, the others rendered for each request
|
|
20
|
+
Given I am a logged in user with the "administrator" user
|
|
21
|
+
When I go to "/dashboard"
|
|
22
|
+
Then the page should be prerendered
|
|
23
|
+
When I go to "/dashboard/invoices"
|
|
24
|
+
Then the page should not be prerendered
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
@default-app
|
|
2
|
+
Feature: A new app made with the defaults
|
|
3
|
+
As a developer starting a new app
|
|
4
|
+
I want its first page to be a hydrated production build with images that load the right way
|
|
5
|
+
So that the app starts from what the framework promises
|
|
6
|
+
|
|
7
|
+
Scenario: The start page is a hydrated, prerendered production build of the app router
|
|
8
|
+
Given I am on "/"
|
|
9
|
+
Then the site should be served as a production build
|
|
10
|
+
And the page should be served by the app router
|
|
11
|
+
And I should see a hydrated page
|
|
12
|
+
And there should be no hydration errors
|
|
13
|
+
And the page should be prerendered
|
|
14
|
+
And the page should have a route announcer
|
|
15
|
+
And the development tools should not be on the page
|
|
16
|
+
|
|
17
|
+
Scenario: The logo is preloaded and loads at once; the other image waits until it is near
|
|
18
|
+
Given I am on "/"
|
|
19
|
+
Then the image "logo" should be preloaded
|
|
20
|
+
And the image "logo" should not load lazily
|
|
21
|
+
And the image "logo" should have loaded
|
|
22
|
+
And the image "logo" should not be optimized
|
|
23
|
+
And the image "logo" should be served as "image/svg+xml"
|
|
24
|
+
And the image "logomark" should load lazily
|
|
25
|
+
And the image "logomark" should not be preloaded
|
|
26
|
+
And the image "logomark" should have a width and a height
|
|
27
|
+
|
|
28
|
+
@js-off
|
|
29
|
+
Scenario: An address with no route shows the default not-found page
|
|
30
|
+
When I go to "/no-such-page"
|
|
31
|
+
Then I should be on a 404 page
|
|
32
|
+
And I should be on the default 404 page
|
|
33
|
+
And the response status code should be 404
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
@learn @development
|
|
2
|
+
Feature: The development server
|
|
3
|
+
As a developer of the app
|
|
4
|
+
I want the development server to show its tools, and the details of an error over the page
|
|
5
|
+
So that I see what failed while I work, and never in a production build
|
|
6
|
+
|
|
7
|
+
# These scenarios run against the development server (SERVER_MODE=development of the build script).
|
|
8
|
+
|
|
9
|
+
Scenario: The development server shows its tools and no error on a page that works
|
|
10
|
+
Given I am a logged in user with the "administrator" user
|
|
11
|
+
When I go to "/dashboard/invoices"
|
|
12
|
+
Then the site should not be served as a production build
|
|
13
|
+
And the development tools should be on the page
|
|
14
|
+
And the development error overlay should not be shown
|
|
15
|
+
|
|
16
|
+
@js-off
|
|
17
|
+
Scenario: A part of the page that fails opens the error overlay with the details
|
|
18
|
+
Given I am a logged in user with the "editor" user
|
|
19
|
+
When I go to "/dashboard/invoices/not-an-invoice/edit"
|
|
20
|
+
Then the development error overlay should be shown
|
|
21
|
+
And the development error overlay should show "invalid input syntax for type uuid"
|
|
22
|
+
And the development error overlay should list 2 errors
|
|
23
|
+
And the page should show the details of the error
|
|
24
|
+
And the error page should show "Something went wrong!"
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
@learn
|
|
2
|
+
Feature: Not-found pages and error pages
|
|
3
|
+
As a person who opens an address that is wrong or a record that fails
|
|
4
|
+
I want a page that says so, without the inner details of the server
|
|
5
|
+
So that I can go back to what works
|
|
6
|
+
|
|
7
|
+
# The browser logs "Failed to load resource" for a 404 or a 500: those scenarios carry @js-off.
|
|
8
|
+
|
|
9
|
+
@js-off
|
|
10
|
+
Scenario: An invoice that does not exist shows the app's own not-found page
|
|
11
|
+
Given I am a logged in user with the "administrator" user
|
|
12
|
+
When I go to "/dashboard/invoices/7f3c2a10-0000-4000-8000-000000000404/edit"
|
|
13
|
+
Then I should be on a 404 page
|
|
14
|
+
And I should not be on the default 404 page
|
|
15
|
+
And I should see "Could not find the requested invoice."
|
|
16
|
+
And the response status code should be 404
|
|
17
|
+
|
|
18
|
+
@js-off
|
|
19
|
+
Scenario: An address with no route shows the default not-found page
|
|
20
|
+
Given I am an anonymous user
|
|
21
|
+
When I go to "/no-such-page"
|
|
22
|
+
Then I should be on a 404 page
|
|
23
|
+
And I should be on the default 404 page
|
|
24
|
+
|
|
25
|
+
@js-off
|
|
26
|
+
Scenario: A part of the page that fails shows the error page, without the details of the error
|
|
27
|
+
Given I am a logged in user with the "editor" user
|
|
28
|
+
When I go to "/dashboard/invoices/not-an-invoice/edit"
|
|
29
|
+
Then the error page should show "Something went wrong!"
|
|
30
|
+
And the page should not show the details of the error
|
|
31
|
+
And I should not see "Failed to fetch invoice."
|
|
32
|
+
And the response status code should be 500
|
|
33
|
+
|
|
34
|
+
Scenario: A page that exists is neither a not-found page nor an error page
|
|
35
|
+
Given I am a logged in user with the "editor" user
|
|
36
|
+
When I go to "/dashboard/customers"
|
|
37
|
+
Then I should not be on a 404 page
|
|
38
|
+
And the error page should not show "Something went wrong!"
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
@learn
|
|
2
|
+
Feature: Forms and their actions
|
|
3
|
+
As a person who keeps the invoices
|
|
4
|
+
I want each form to say what is wrong next to the field, and to save without reloading the page
|
|
5
|
+
So that I can correct a form quickly and see the list as it is now
|
|
6
|
+
|
|
7
|
+
# A scenario that creates or changes an invoice takes it back before it ends; the invoices of the
|
|
8
|
+
# suite's own customers ("Ivy Example", "Oak Example") come from the build.
|
|
9
|
+
|
|
10
|
+
Scenario: The errors of the server are shown next to each field and for the whole form
|
|
11
|
+
Given I am a logged in user with the "editor" user
|
|
12
|
+
And I am on "/dashboard/invoices/create"
|
|
13
|
+
When I send the form with "Create Invoice"
|
|
14
|
+
Then the field "Choose customer" should show the error "Please select a customer."
|
|
15
|
+
And the field "Choose an amount" should show the error "Please enter an amount greater than $0."
|
|
16
|
+
And the field "Set the invoice status" should show the error "Please select an invoice status."
|
|
17
|
+
And the form should show the message "Missing Fields. Failed to Create Invoice."
|
|
18
|
+
And the form should have been sent without a full page reload
|
|
19
|
+
|
|
20
|
+
Scenario: A field that is right loses its error when the form is sent again
|
|
21
|
+
Given I am a logged in user with the "editor" user
|
|
22
|
+
And I am on "/dashboard/invoices/create"
|
|
23
|
+
When I send the form with "Create Invoice"
|
|
24
|
+
And I select "Oak Example" from "Choose customer"
|
|
25
|
+
And I send the form with "Create Invoice"
|
|
26
|
+
Then the field "Choose customer" should not show the error "Please select a customer."
|
|
27
|
+
And the field "Choose an amount" should show the error "Please enter an amount greater than $0."
|
|
28
|
+
|
|
29
|
+
Scenario: An invoice is created, listed and deleted
|
|
30
|
+
Given I am a logged in user with the "administrator" user
|
|
31
|
+
And I am on "/dashboard/invoices/create"
|
|
32
|
+
When I select "Ivy Example" from "Choose customer"
|
|
33
|
+
And I fill in "Choose an amount" with "42.17"
|
|
34
|
+
And I choose the radio button "Pending"
|
|
35
|
+
And I send the form with "Create Invoice"
|
|
36
|
+
Then the path should be "/dashboard/invoices"
|
|
37
|
+
And the form should have been sent without a full page reload
|
|
38
|
+
And I should see "$42.17"
|
|
39
|
+
When I send the form with "Delete" in the "$42.17" row
|
|
40
|
+
Then I should not see "$42.17"
|
|
41
|
+
And the form should have been sent without a full page reload
|
|
42
|
+
|
|
43
|
+
Scenario: An invoice is changed, then put back
|
|
44
|
+
Given I am a logged in user with the "editor" user
|
|
45
|
+
And I am on "/dashboard/invoices/7f3c2a10-0000-4000-8000-0000000000a1/edit"
|
|
46
|
+
When I fill in "Choose an amount" with "121.50"
|
|
47
|
+
And I send the form with "Edit Invoice"
|
|
48
|
+
Then the path should be "/dashboard/invoices"
|
|
49
|
+
When I go to "/dashboard/invoices?query=Ivy"
|
|
50
|
+
Then I should see "$121.50"
|
|
51
|
+
When I go to "/dashboard/invoices/7f3c2a10-0000-4000-8000-0000000000a1/edit"
|
|
52
|
+
And I fill in "Choose an amount" with "120"
|
|
53
|
+
And I send the form with "Edit Invoice"
|
|
54
|
+
And I go to "/dashboard/invoices?query=Ivy"
|
|
55
|
+
Then I should see "$120.00"
|
|
56
|
+
And I should not see "$121.50"
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
@learn
|
|
2
|
+
Feature: Images
|
|
3
|
+
As a person on any screen
|
|
4
|
+
I want the images sized for my screen, and loaded only when I come to them
|
|
5
|
+
So that the pages stay fast and do not move while they load
|
|
6
|
+
|
|
7
|
+
Scenario: The picture of the start page is optimized, sized and lazy; the one for small screens is not loaded
|
|
8
|
+
Given I am an anonymous user
|
|
9
|
+
When I go to "/"
|
|
10
|
+
Then the image "Screenshots of the dashboard project showing desktop version" should load lazily
|
|
11
|
+
And the image "Screenshots of the dashboard project showing desktop version" should be optimized
|
|
12
|
+
And the image "Screenshots of the dashboard project showing desktop version" should have a width and a height
|
|
13
|
+
And the image "Screenshots of the dashboard project showing desktop version" should have loaded
|
|
14
|
+
And the image "Screenshots of the dashboard project showing desktop version" should be served as "image/webp"
|
|
15
|
+
And the image "Screenshots of the dashboard project showing desktop version" should not be preloaded
|
|
16
|
+
And the image "Screenshot of the dashboard project showing mobile version" should not have loaded
|
|
17
|
+
|
|
18
|
+
# A lazy image that is hidden (display: none) never loads; an eager one would. The browser also loads a
|
|
19
|
+
# lazy image some way ahead of the window (more than a screen), so the pages of this app are too short
|
|
20
|
+
# to see one wait below the fold: the hidden picture of the other screen size shows it instead.
|
|
21
|
+
Scenario: On a small screen the picture made for it loads, and the wide one does not
|
|
22
|
+
Given I set the viewport to 375 by 667
|
|
23
|
+
And I am an anonymous user
|
|
24
|
+
When I go to "/"
|
|
25
|
+
Then the image "Screenshot of the dashboard project showing mobile version" should load lazily
|
|
26
|
+
When I scroll the image "Screenshot of the dashboard project showing mobile version" into view
|
|
27
|
+
Then the image "Screenshot of the dashboard project showing mobile version" should have loaded
|
|
28
|
+
And the image "Screenshots of the dashboard project showing desktop version" should not have loaded
|
|
29
|
+
|
|
30
|
+
Scenario: The pictures of a list are optimized, sized and lazy
|
|
31
|
+
Given I am a logged in user with the "administrator" user
|
|
32
|
+
When I go to "/dashboard/customers"
|
|
33
|
+
Then the image "Oak Example's profile picture" should load lazily
|
|
34
|
+
And the image "Oak Example's profile picture" should be optimized
|
|
35
|
+
And the image "Oak Example's profile picture" should have a width and a height
|
|
36
|
+
When I scroll the image "Oak Example's profile picture" into view
|
|
37
|
+
Then the image "Oak Example's profile picture" should have loaded
|
|
38
|
+
And the image "Oak Example's profile picture" should be served as "image/webp"
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
@learn
|
|
2
|
+
Feature: Loading states and streaming
|
|
3
|
+
As a person on a slow connection
|
|
4
|
+
I want the page to show what is coming while its parts arrive
|
|
5
|
+
So that I know the app is working, and the tests wait for the app rather than for a clock
|
|
6
|
+
|
|
7
|
+
# The 15.x line keeps the old list while a search streams in, and shows the new one at once: no
|
|
8
|
+
# loading state in between. This scenario runs on 16.x (the 15.x lane leaves out @since-16).
|
|
9
|
+
@since-16
|
|
10
|
+
Scenario: On a slow network the list shows its loading state, then its rows
|
|
11
|
+
Given I am a logged in user with the "administrator" user
|
|
12
|
+
And I am on "/dashboard/invoices"
|
|
13
|
+
And the network is slow
|
|
14
|
+
When I fill in "Search invoices..." with "Oak"
|
|
15
|
+
Then a part of the page should show its loading state
|
|
16
|
+
When I wait for the page to finish loading
|
|
17
|
+
Then no part of the page should show its loading state
|
|
18
|
+
And I should see "Oak Example"
|
|
19
|
+
And the network is no longer slow
|
|
20
|
+
|
|
21
|
+
Scenario: The parts of a page stream in one after the other on a slow network
|
|
22
|
+
Given I am a logged in user with the "editor" user
|
|
23
|
+
And I am on "/dashboard/invoices"
|
|
24
|
+
And the network is slow
|
|
25
|
+
When I start to go to "/dashboard/invoices?query=Example"
|
|
26
|
+
Then a part of the page should show its loading state
|
|
27
|
+
When I wait for the page to finish loading
|
|
28
|
+
Then no part of the page should show its loading state
|
|
29
|
+
And I should see a hydrated page
|
|
30
|
+
And I should see "Ivy Example"
|
|
31
|
+
And the network is no longer slow
|
|
32
|
+
|
|
33
|
+
Scenario: While the answer is on its way, the router keeps the page it shows
|
|
34
|
+
Given I am a logged in user with the "administrator" user
|
|
35
|
+
And I am on "/dashboard/invoices"
|
|
36
|
+
And the server's answers are held back
|
|
37
|
+
When I click "Customers"
|
|
38
|
+
Then the page should be waiting for the server
|
|
39
|
+
And the path should be "/dashboard/invoices"
|
|
40
|
+
When the server's answers come through
|
|
41
|
+
Then the path should be "/dashboard/customers"
|
|
42
|
+
And the page should not be waiting for the server
|
|
43
|
+
And no part of the page should show its loading state
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
@learn
|
|
2
|
+
Feature: Client-side navigation
|
|
3
|
+
As a person who moves around the dashboard
|
|
4
|
+
I want each page to open at once, in the page I already have
|
|
5
|
+
So that the app stays quick and a screen reader still hears where I am
|
|
6
|
+
|
|
7
|
+
Scenario: The side navigation opens each page without a full page reload
|
|
8
|
+
Given I am a logged in user with the "administrator" user
|
|
9
|
+
And I am on "/dashboard"
|
|
10
|
+
When I click the link "Invoices" without a full page reload
|
|
11
|
+
Then the path should be "/dashboard/invoices"
|
|
12
|
+
And the route announcer should announce "Invoices | Acme Dashboard"
|
|
13
|
+
When I click the link "Customers" without a full page reload
|
|
14
|
+
Then the path should be "/dashboard/customers"
|
|
15
|
+
And the route announcer should announce "Customers"
|
|
16
|
+
And I should see "Ivy Example"
|
|
17
|
+
|
|
18
|
+
Scenario: Back and forward keep the page the browser has
|
|
19
|
+
Given I am a logged in user with the "editor" user
|
|
20
|
+
And I am on "/dashboard/invoices"
|
|
21
|
+
When I click the link "Customers" without a full page reload
|
|
22
|
+
And I go back without a full page reload
|
|
23
|
+
Then the path should be "/dashboard/invoices"
|
|
24
|
+
And the route announcer should announce "Invoices"
|
|
25
|
+
When I go forward without a full page reload
|
|
26
|
+
Then the path should be "/dashboard/customers"
|
|
27
|
+
|
|
28
|
+
Scenario: The pages of the side navigation are fetched ahead of a click
|
|
29
|
+
Given I am a logged in user with the "administrator" user
|
|
30
|
+
When I go to "/dashboard"
|
|
31
|
+
Then the page "/dashboard/invoices" should be prefetched
|
|
32
|
+
And the page "/dashboard/customers" should be prefetched
|
|
33
|
+
|
|
34
|
+
Scenario: Every page has a route announcer, which says nothing on the first page of a visit
|
|
35
|
+
Given I am an anonymous user
|
|
36
|
+
When I go to "/"
|
|
37
|
+
Then the page should have a route announcer
|
|
38
|
+
And the route announcer should not announce "Acme Dashboard"
|
|
39
|
+
And I should see a hydrated page
|
|
40
|
+
|
|
41
|
+
Scenario: A page opened from its address stands on its own
|
|
42
|
+
Given I am a logged in user with the "editor" user
|
|
43
|
+
When I go to "/dashboard/invoices?page=3"
|
|
44
|
+
Then I should see a hydrated page
|
|
45
|
+
And current url should have the "page" parameter with the "3" value
|
|
46
|
+
And I should see "Oak Example"
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
@pages-router
|
|
2
|
+
Feature: An app of the pages router
|
|
3
|
+
As a person who uses an app of the pages router
|
|
4
|
+
I want its pages hydrated, its links opening pages in the same document and each new page announced
|
|
5
|
+
So that the older router behaves as the newer one does
|
|
6
|
+
|
|
7
|
+
Scenario: The pages are a hydrated, prerendered production build of the pages router
|
|
8
|
+
Given I am on "/"
|
|
9
|
+
Then the site should be served as a production build
|
|
10
|
+
And the page should be served by the pages router
|
|
11
|
+
And I should see a hydrated page
|
|
12
|
+
And there should be no hydration errors
|
|
13
|
+
And the page should be prerendered
|
|
14
|
+
And the page should have a route announcer
|
|
15
|
+
|
|
16
|
+
Scenario: The links open their pages in the same document, and the router announces each one
|
|
17
|
+
Given I am on "/"
|
|
18
|
+
When I click the link "About" without a full page reload
|
|
19
|
+
Then the path should be "/about"
|
|
20
|
+
And the route announcer should announce "About"
|
|
21
|
+
When I click the link "Users List" without a full page reload
|
|
22
|
+
Then the path should be "/users"
|
|
23
|
+
And the route announcer should announce "Users List"
|
|
24
|
+
When I go back without a full page reload
|
|
25
|
+
Then the path should be "/about"
|
|
26
|
+
|
|
27
|
+
Scenario: The page behind a link is fetched ahead of a click
|
|
28
|
+
Given I am on "/"
|
|
29
|
+
Then the page "/users" should be prefetched
|
|
30
|
+
|
|
31
|
+
@js-off
|
|
32
|
+
Scenario: An address with no page shows the default not-found page
|
|
33
|
+
When I go to "/no-such-page"
|
|
34
|
+
Then I should be on a 404 page
|
|
35
|
+
And I should be on the default 404 page
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
@learn
|
|
2
|
+
Feature: Search and pagination in the address
|
|
3
|
+
As a person who looks for an invoice
|
|
4
|
+
I want the search and the page of the list to be in the address
|
|
5
|
+
So that a link, a reload or the back button gives me the same list
|
|
6
|
+
|
|
7
|
+
# The search box of the app has a label that is not tied to it (its "for" names no field): the
|
|
8
|
+
# scenarios fill it in by its placeholder, and read it back by a selector.
|
|
9
|
+
|
|
10
|
+
Scenario: Searching puts the words in the address and lists what matches
|
|
11
|
+
Given I am a logged in user with the "administrator" user
|
|
12
|
+
And I am on "/dashboard/invoices"
|
|
13
|
+
When I fill in "Search invoices..." with "Example"
|
|
14
|
+
And I wait for the page to be ready
|
|
15
|
+
Then current url should have the "query" parameter with the "Example" value
|
|
16
|
+
And current url should have the "page" parameter with the "1" value
|
|
17
|
+
And I should see "Ivy Example"
|
|
18
|
+
And I should see "Oak Example"
|
|
19
|
+
And I should see "$120.00"
|
|
20
|
+
|
|
21
|
+
Scenario: A search in the address fills in the search box
|
|
22
|
+
Given I am a logged in user with the "editor" user
|
|
23
|
+
When I go to "/dashboard/invoices?query=Oak"
|
|
24
|
+
Then the "input[placeholder='Search invoices...']" field should contain "Oak"
|
|
25
|
+
And I should see "Oak Example"
|
|
26
|
+
And I should not see "Ivy Example"
|
|
27
|
+
|
|
28
|
+
Scenario: The next page of the list is a page of its own
|
|
29
|
+
Given I am a logged in user with the "administrator" user
|
|
30
|
+
And I am on "/dashboard/invoices"
|
|
31
|
+
When I click the link "2" without a full page reload
|
|
32
|
+
Then current url should have the "page" parameter with the "2" value
|
|
33
|
+
When I click the link "3" without a full page reload
|
|
34
|
+
Then current url should have the "page" parameter with the "3" value
|
|
35
|
+
And I should see "Ivy Example"
|
|
36
|
+
When I go back without a full page reload
|
|
37
|
+
Then current url should have the "page" parameter with the "2" value
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
@learn
|
|
2
|
+
Feature: The session
|
|
3
|
+
As a person who works in the dashboard
|
|
4
|
+
I want to log in, to be refused with a wrong password, and to log out
|
|
5
|
+
So that only the people with an account see the invoices
|
|
6
|
+
|
|
7
|
+
# The accounts are configuration (worldParameters.users in cucumber.js); no scenario creates one.
|
|
8
|
+
|
|
9
|
+
@critical
|
|
10
|
+
Scenario: A visitor who asks for a page of the dashboard is sent to the login form
|
|
11
|
+
Given I am an anonymous user
|
|
12
|
+
When I go to "/dashboard/invoices"
|
|
13
|
+
Then I should see the login form
|
|
14
|
+
And the login form should send me back to "/dashboard/invoices"
|
|
15
|
+
And I should not be logged in
|
|
16
|
+
|
|
17
|
+
@critical
|
|
18
|
+
Scenario Outline: The <account> account logs in through the form
|
|
19
|
+
When I log in as "<account>" with the login form
|
|
20
|
+
Then I should be logged in as "<account>"
|
|
21
|
+
And the path should be "/dashboard"
|
|
22
|
+
|
|
23
|
+
Examples:
|
|
24
|
+
| account |
|
|
25
|
+
| administrator |
|
|
26
|
+
| editor |
|
|
27
|
+
|
|
28
|
+
Scenario: A wrong password is refused with the form's own message
|
|
29
|
+
When I log in with the email "administrator@example.com" and the password "wrong-password"
|
|
30
|
+
Then the form should show the message "Invalid credentials."
|
|
31
|
+
And I should see the login form
|
|
32
|
+
And I should not be logged in
|
|
33
|
+
|
|
34
|
+
Scenario: An address the app does not know is refused the same way
|
|
35
|
+
When I log in with the email "nobody@example.com" and the password "wrong-password"
|
|
36
|
+
Then the form should show the message "Invalid credentials."
|
|
37
|
+
And I should not be logged in
|
|
38
|
+
|
|
39
|
+
Scenario: The button of the login form is busy while the login is on its way
|
|
40
|
+
Given I fill in the login form as "editor"
|
|
41
|
+
And the server's answers are held back
|
|
42
|
+
When I press "Log in"
|
|
43
|
+
Then the "Log in" button should be busy
|
|
44
|
+
And the page should be waiting for the server
|
|
45
|
+
When the server's answers come through
|
|
46
|
+
Then I should be logged in as "editor"
|
|
47
|
+
And the page should not be waiting for the server
|
|
48
|
+
|
|
49
|
+
Scenario: A session opened earlier in the run is taken over
|
|
50
|
+
Given I am a logged in user with the "editor" user
|
|
51
|
+
When I go to "/dashboard/customers"
|
|
52
|
+
Then I should be logged in as "editor"
|
|
53
|
+
And I should not see the login form
|
|
54
|
+
|
|
55
|
+
Scenario: Logging out ends the session
|
|
56
|
+
Given I am a logged in user with the "administrator" user
|
|
57
|
+
When I log out
|
|
58
|
+
Then I should not be logged in
|
|
59
|
+
And the path should be "/"
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Step definitions
|
|
2
|
+
|
|
3
|
+
| File | Covers |
|
|
4
|
+
| --- | --- |
|
|
5
|
+
| `nextjs-pages.steps.js` | The wait for the page to be ready; a hydrated page and hydration errors; a production build; the router that serves the page; the release it runs on; prerendered pages. It puts the recorders on every page of the run. |
|
|
6
|
+
| `nextjs-navigation.steps.js` | A link followed and back and forward, each without a full page reload; the route announcer; the pages fetched ahead of a click. |
|
|
7
|
+
| `nextjs-loading.steps.js` | A slow network; a page load that does not wait for its end; a part of the page showing its loading state; the server's answers held back and let through; the page waiting for the server. |
|
|
8
|
+
| `nextjs-forms.steps.js` | A form sent with its button; sent without a full page reload; the error of a field; the message of a form; a busy button. |
|
|
9
|
+
| `nextjs-errors.steps.js` | A 404 page and the default one; the error page of an error boundary; the details of an error; the development error overlay and the development tools. |
|
|
10
|
+
| `nextjs-images.steps.js` | Lazy and preloaded images, the image optimizer and its format, the size of an image, an image loaded or not, an image brought into view. |
|
|
11
|
+
| `nextjs-session.steps.js` | Login by a handle of the users registry, through the form or with an address and a password; the login form filled in; logout; who is signed in; the login form and where it sends a person back to. |
|
|
12
|
+
| `nextjs-helpers.js` | Shared plumbing: the wait on the app's own signals, the requests of the app by kind, the console, friendly failures, the users registry and the session cache, the route announcer, images, the development overlay. It registers no step. |
|
|
13
|
+
|
|
14
|
+
## Rules for a new step
|
|
15
|
+
|
|
16
|
+
- Check `node_modules/webship-js/tests/step-definitions/` first: a step that the
|
|
17
|
+
generic click, fill and see vocabulary already covers is not added here.
|
|
18
|
+
- No step phrase names the framework or its libraries. A name appears only as
|
|
19
|
+
an argument a step asserts.
|
|
20
|
+
- The regular expression starts with the pronoun group `(I |we )*` where a
|
|
21
|
+
person acts, and an assertion takes `should( not)*`, so one definition reads
|
|
22
|
+
both polarities.
|
|
23
|
+
- A JSDoc block above the step holds at least five `Example #N:` lines. Run
|
|
24
|
+
`npm run test:examples`: every example must match its own step and no step of
|
|
25
|
+
webship-js.
|
|
26
|
+
- Find things the way a person does: a name, a label, a role, a text, the
|
|
27
|
+
alternative text of an image. The framework's stable hooks are the fallback.
|
|
28
|
+
- Wait on the app's own signals (see `nextjs-helpers.js`), never on a clock.
|
|
29
|
+
- A failure says what was expected, what was found, and where to look (a
|
|
30
|
+
`Hint:`); add a scenario to `tests/must-fail/` that proves it can fail.
|