@webship.co/workspace-learnpress 0.0.0-stage → 1.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.
@@ -0,0 +1,97 @@
1
+ ---
2
+ description: Test a site of courses of the Webship Workspace with webship-js and the LearnPress step pack — set the testing stack up when it is missing, match every step, run the suite (or one feature, or one tag) in the site's container, and report what failed and why.
3
+ argument-hint: '<site> [tests/features/<name>.feature | @tag]'
4
+ ---
5
+
6
+ # /learnpress-test
7
+
8
+ Test the site of courses named in: `$ARGUMENTS`
9
+
10
+ `$ARGUMENTS` stands for what was typed after the command. An AI CLI that does not fill it in
11
+ reads the same from the request: the name of the site, then, if anything, one feature path or one
12
+ tag.
13
+
14
+ The first word is the site (its folder name in a sites folder of the workspace). What follows, if
15
+ anything, narrows the run: a path that starts with `tests/features/` is one feature (or one
16
+ folder of features), a word that starts with `@` is a tag expression. With nothing after the site,
17
+ the whole suite runs. With no site at all, stop and ask for one: list the candidates with
18
+ `ls -d ~/workspace/*/*/wp-content/plugins/learnpress`.
19
+
20
+ The workspace is container-based (DDEV by default) and everything below runs in the site's
21
+ container through the workspace's own command. Never run `npx cucumber-js`, `npx playwright`,
22
+ `php` or `wp` on the host for a site.
23
+
24
+ ## 1. Find the site
25
+
26
+ ```bash
27
+ ls -d ~/workspace/*/<site>/wp-content/plugins/learnpress
28
+ ```
29
+
30
+ The folder above `<site>` is the sites folder it is in (`dev`, `test`, `sandboxes`, `demos`). If the
31
+ project has no `wp-content/plugins/learnpress`, stop: this command is for a site built with
32
+ `cmd-learnpress-project.sh`. If the sites folder has no `cmd-tools-testing.sh`, stop and say that the
33
+ folder is not a sites folder of this workspace.
34
+
35
+ ## 2. Make sure the testing stack is there
36
+
37
+ ```bash
38
+ cd ~/workspace/<folder>
39
+ grep -c "@webship-js/learnpress-steps" <site>/cucumber.js
40
+ ```
41
+
42
+ If `cucumber.js` is missing or does not name the step pack, set the stack up (it adds what is
43
+ missing and keeps what was changed):
44
+
45
+ ```bash
46
+ bash cmd-tools-testing.sh <site>
47
+ ```
48
+
49
+ ## 3. Match every step, without a browser
50
+
51
+ ```bash
52
+ bash cmd-tools-testing.sh <site> --dry-run # the whole suite
53
+ bash cmd-tools-testing.sh <site> --dry-run --path tests/features/<name>.feature # one feature
54
+ bash cmd-tools-testing.sh <site> --dry-run --tags "@critical" # one tag
55
+ ```
56
+
57
+ Use the form that matches what was asked. An `Undefined` or `Ambiguous` step is a finding: name
58
+ the feature, the line and the phrase, show the closest phrase the packs define
59
+ (`grep -hE "^(Given|When|Then)\(" <site>/node_modules/@webship-js/learnpress-steps/tests/step-definitions/*.steps.js`),
60
+ and stop before the real run.
61
+
62
+ ## 4. Run
63
+
64
+ ```bash
65
+ bash cmd-tools-testing.sh <site> --run # the whole suite
66
+ bash cmd-tools-testing.sh <site> --run --path tests/features/<name>.feature # one feature
67
+ bash cmd-tools-testing.sh <site> --run --tags "@critical" # one tag
68
+ ```
69
+
70
+ Run it once. Do not add `--retry`, do not tag a scenario `@wip` and do not change a feature to
71
+ make the run pass.
72
+
73
+ ## 5. Report
74
+
75
+ Say, in this order:
76
+
77
+ 1. The site, its address (`https://<site>.ddev.site/courses/`) and what was run (suite, feature or tag).
78
+ 2. The totals the run printed: scenarios and steps, passed and failed, and the time.
79
+ 3. For each failed scenario: the feature and line, the step that failed, the message, and what
80
+ it means for the site — a defect of the courses, a scenario that asserts something the site never
81
+ did, or the environment (the site was stopped; an account is missing:
82
+ `bash cmd-tools-add-users.sh <site> learnpress` writes the default ones again; the sample courses are
83
+ missing: `bash cmd-tools-learnpress-courses.sh <site> --sample-course` adds them; a stopped run left
84
+ enrolments, orders, progress or a "Webship test …" course behind:
85
+ `bash cmd-tools-learnpress-courses.sh <site> --tidy` takes them away).
86
+ 4. Where the report is: `~/workspace/<folder>/<site>/tests/reports/`.
87
+
88
+ A failing suite is a result: report it as it is. Never create an account for a scenario, never
89
+ write a password into a feature file, and never write a platform name into a step phrase. For
90
+ writing or fixing scenarios, use the `learnpress-scenarios` skill or hand over to the
91
+ `learnpress-tester` agent; for changing the site, to `learnpress-site-builder`.
92
+
93
+ Before you write or change a scenario, or read a failed run, read the book *Automated Functional
94
+ Testing Recipes* (its `README.md`, then the matching chapter):
95
+ `.claude/automated-functional-testing-recipes/` in the project,
96
+ `~/.claude/automated-functional-testing-recipes/`, or
97
+ https://github.com/webship/webship-js-ai-agent/tree/2.0.x/automated-functional-testing-recipes
@@ -0,0 +1,25 @@
1
+ Build a site of courses with LearnPress in a sites folder and prove it with its first webship-js features.
2
+
3
+ The launch command below is for Claude Code, the default; the text between the triple quotes can be given to another AI CLI as it is.
4
+
5
+ ```
6
+ claude --permission-mode bypassPermissions """
7
+ Build the site of courses named <name> in this sites folder and test it with webship-js
8
+ # ~/workspace/<dev|test|sandboxes|demos> · https://<name>.ddev.site/courses/ · container-based (DDEV by default)
9
+ # the builder deletes a project of the same name first: stop if <name> is a site somebody still needs
10
+ # nothing on the host: no php, wp or composer outside the site's container; nothing paid, no add-on, no account anywhere
11
+ # a feature to write or a run to read: the book Automated Functional Testing Recipes first (its README.md, then the matching chapter), from .claude/automated-functional-testing-recipes/ in the project, ~/.claude/automated-functional-testing-recipes/ or https://github.com/webship/webship-js-ai-agent/tree/2.0.x/automated-functional-testing-recipes
12
+
13
+ 1. bash cmd-learnpress-project.sh <name> --install --add-users --sample-course
14
+ 2. bash cmd-tools-learnpress-courses.sh <name>
15
+ tell me the versions, the address, the courses and the accounts with their places in the courses
16
+ 3. bash cmd-tools-testing.sh <name>
17
+ webship-js, the courses' step pack with the WordPress one, the users registry, tests/features/courses.feature
18
+ 4. bash cmd-tools-testing.sh <name> --dry-run --path tests/features/courses.feature
19
+ 5. bash cmd-tools-testing.sh <name> --run --path tests/features/courses.feature
20
+
21
+ If a command fails, show the line that failed and stop. Do not retry with other flags.
22
+ When the feature is green: the address, the versions, how many scenarios and steps passed.
23
+ Then ask me whether to keep the site or remove it with: bash cmd-tools-remove.sh <name>
24
+ """
25
+ ```
@@ -0,0 +1,32 @@
1
+ Write and run the webship-js scenario of a round of a quiz on a site of courses with LearnPress.
2
+
3
+ The launch command below is for Claude Code, the default; the text between the triple quotes can be given to another AI CLI as it is.
4
+
5
+ ```
6
+ claude --permission-mode bypassPermissions """
7
+ Write the scenario of a round of a quiz on the courses of this site, and run it
8
+ # ~/workspace/<folder>/<site> · https://<site>.ddev.site/courses/ · container-based (DDEV by default)
9
+ # the phrases are in the learnpress-scenarios skill; the learnpress-tester agent is the one to hand this work over to
10
+ # look at the quiz first: in the Playwright MCP browser, in a tab of your own, do the round by hand once before writing its scenario
11
+ # a feature to write or a run to read: the book Automated Functional Testing Recipes first (its README.md, then the matching chapter), from .claude/automated-functional-testing-recipes/ in the project, ~/.claude/automated-functional-testing-recipes/ or https://github.com/webship/webship-js-ai-agent/tree/2.0.x/automated-functional-testing-recipes
12
+
13
+ The round: the student starts the quiz "Basics quiz" of the course "Webship Testing Basics", answers <all right|one wrong|one only>,
14
+ finishes it, reads the result (passed or failed, the points, the questions right, wrong and skipped),
15
+ <reviews the answers|retakes the quiz>, and the profile's quizzes tab shows it.
16
+
17
+ Read the installed steps first:
18
+ grep -hE '^(Given|When|Then)\(' node_modules/@webship-js/learnpress-steps/tests/step-definitions/*.steps.js
19
+
20
+ Write one feature in tests/features/<name>.feature, from phrases that exist.
21
+ Log in by the handle of the users registry (admin, instructor, student, student2):
22
+ no password in the feature, no account created by a scenario, no platform name in a step phrase.
23
+ The steps put back what they change when the scenario ends: the quiz's attempts and results, the progress, an enrolment and its order.
24
+
25
+ Then, from the sites folder (cd ..):
26
+ bash cmd-tools-testing.sh <site> --dry-run --path tests/features/<name>.feature
27
+ bash cmd-tools-testing.sh <site> --run --path tests/features/<name>.feature
28
+
29
+ A failing scenario is a result: tell me what the site did, do not loosen the scenario.
30
+ When you are done: the scenario, the result of the run, and any step you could not find in the packs
31
+ """
32
+ ```
@@ -0,0 +1,211 @@
1
+ ---
2
+ name: learnpress-scenarios
3
+ description: Write and run webship-js scenarios for a site of courses on WordPress with LearnPress of the Webship Workspace with the LearnPress step pack (`@webship-js/learnpress-steps`, which brings the WordPress step pack along) — the phrases by area (the course list and a course page, enrolling and lessons, quizzes, the student's profile, the instructor's course editor, the course settings), the accounts by handle, the traps found on a real site of courses, and three example features. Use when asked to "write a scenario for the courses", "test the quiz of <site>", or "which step checks a course's progress".
4
+ argument-hint: '<site> [what to cover]'
5
+ ---
6
+
7
+ # learnpress-scenarios
8
+
9
+ Scenarios for a site of courses on WordPress with LearnPress of a Webship Workspace (`~/workspace`, container-based,
10
+ DDEV by default), written from the steps of [`@webship-js/learnpress-steps`](https://github.com/webship/learnpress-steps),
11
+ of the WordPress step pack it brings along and of [webship-js](https://github.com/webship/webship-js) itself, and run in
12
+ the site's container by the workspace's own command. It comes with the LearnPress plugin
13
+ (`@webship.co/workspace-learnpress`), like the builder (`cmd-learnpress-project.sh`), the courses' tool
14
+ (`cmd-tools-learnpress-courses.sh`) and the agents `learnpress-site-builder` and `learnpress-tester`.
15
+
16
+ ## Where everything is
17
+
18
+ | What | Where |
19
+ | --- | --- |
20
+ | The site | `~/workspace/<folder>/<site>`, its courses at `https://<site>.ddev.site/courses/` (`<folder>` is a sites folder: `dev`, `test`, `sandboxes`, `demos`) |
21
+ | The suite's configuration | `<site>/cucumber.js`: the step definitions it loads, the users registry (`worldParameters.users`, with each account's `name`) |
22
+ | The features | `<site>/tests/features/*.feature` (`courses.feature` and `site.feature` are the first ones the setup wrote) |
23
+ | The courses' steps | `<site>/node_modules/@webship-js/learnpress-steps/tests/step-definitions/*.steps.js` |
24
+ | The site's steps (login, administration) | `<site>/node_modules/@webship-js/wordpress-steps/tests/step-definitions/*.steps.js` |
25
+ | webship-js's steps | `<site>/node_modules/webship-js/tests/step-definitions/*.js` |
26
+ | The reports | `<site>/tests/reports/` |
27
+
28
+ ## The order of work
29
+
30
+ 1. **Make sure the testing stack is there.** From the sites folder:
31
+ ```bash
32
+ cd ~/workspace/<folder>
33
+ bash cmd-tools-testing.sh <site>
34
+ ```
35
+ It adds webship-js, both step packs (in one profile: the courses' pack extends the WordPress one), the users
36
+ registry with the handles of the courses' accounts, `tests/features/site.feature` and
37
+ `tests/features/courses.feature`, and makes sure the default accounts are on the site. It is safe to run again: it
38
+ adds what is missing and keeps what was changed.
39
+ 2. **Read the installed steps before writing a phrase.** They are the source of truth: the packs move, and a phrase
40
+ from memory is a guess.
41
+ ```bash
42
+ cd ~/workspace/<folder>/<site>
43
+ grep -hE "^(Given|When|Then)\(" node_modules/@webship-js/learnpress-steps/tests/step-definitions/*.steps.js
44
+ ```
45
+ Every step carries a comment block with five examples above it; open the file when a phrase is not obvious.
46
+ 3. **Look at the page first** (the Playwright MCP browser, a tab of your own) when the scenario is about a page you
47
+ have not seen.
48
+ 4. **Write the feature** in `<site>/tests/features/`, from phrases that exist (the lists below).
49
+ 5. **Match every step without a browser**, then run the feature, then the suite:
50
+ ```bash
51
+ cd ~/workspace/<folder>
52
+ bash cmd-tools-testing.sh <site> --dry-run --path tests/features/<name>.feature
53
+ bash cmd-tools-testing.sh <site> --run --path tests/features/<name>.feature
54
+ bash cmd-tools-testing.sh <site> --run --tags "@critical"
55
+ bash cmd-tools-testing.sh <site> --run
56
+ ```
57
+ A dry run says `Undefined` for a phrase no definition matches: fix the phrase, do not write a step for it.
58
+
59
+ ## Accounts: a handle, never a password
60
+
61
+ ```gherkin
62
+ Feature: Accounts
63
+ Scenario: The student finds its course on its profile
64
+ Given I am a logged in user with the "student" user
65
+ When I go to my courses
66
+ Then my profile should list "Webship Testing Basics"
67
+ ```
68
+
69
+ The handles of the default accounts: `admin` (the site's `administrator`), `instructor`, `student` (enrolled in
70
+ "Webship Testing Basics") and `student2` (enrolled in nothing); each shows as "<Login> Test". A visitor is `Given I am
71
+ an anonymous user`. Never create an account in a scenario, and never log in as the workspace account.
72
+
73
+ ## The phrases, by area
74
+
75
+ The course list and a course page:
76
+
77
+ ```gherkin
78
+ When I go to the course list
79
+ Then the course list should show "Webship Testing Basics"
80
+ Then the course list should not show "Webship test course"
81
+ Then the course list should show "Webship Advanced Testing", "Webship Testing Basics" in this order
82
+ Then the course "Webship Testing Basics" of the list should read "by Instructor Test"
83
+ Then the course "Webship Advanced Testing" of the list should read "Free"
84
+ When I search the courses for "Advanced"
85
+ When I order the courses by "Title z-a"
86
+ When I go to the course "Webship Testing Basics"
87
+ Then the curriculum should show the section "Getting started" with "What a scenario is", "Steps and features"
88
+ Then the course should show "Quiz" as "1 Quiz"
89
+ Then the instructor of the course should be "Instructor Test"
90
+ Then the course page should offer "Start Now"
91
+ Then the course page should not offer "Continue"
92
+ ```
93
+
94
+ Enrolling and lessons:
95
+
96
+ ```gherkin
97
+ When I start the course "Webship Testing Basics"
98
+ When I open "What a scenario is" in the course "Webship Testing Basics"
99
+ When I complete the lesson
100
+ Then the course should say "Congrats! You have completed “What a scenario is”."
101
+ Then the progress of the course should be "1 of 3 items"
102
+ Then the item "What a scenario is" should be completed
103
+ Then the item "Basics quiz" should be locked
104
+ ```
105
+
106
+ Quizzes:
107
+
108
+ ```gherkin
109
+ When I start the quiz "Basics quiz" of the course "Webship Testing Basics"
110
+ When I answer "True" to "A feature holds scenarios."
111
+ When I answer "Given", "When" and "Then" to "Which words start a step?"
112
+ When I finish the quiz
113
+ Then the quiz should be passed
114
+ Then the quiz should be failed
115
+ Then the quiz result should show "Points" as "3 / 3"
116
+ Then the quiz result should show "Skipped" as "2"
117
+ When I review the quiz
118
+ When I go back to the result of the quiz
119
+ Then the question "A feature holds scenarios." should show "True" as the right answer
120
+ Then the question "A feature holds scenarios." should show "True" as my answer
121
+ When I retake the quiz
122
+ Then the quiz should offer "Retake (2)"
123
+ Then the quiz should not offer "Review"
124
+ ```
125
+
126
+ The student's profile:
127
+
128
+ ```gherkin
129
+ When I go to my courses
130
+ When I open the "Quizzes" tab of my profile
131
+ Then my profile should count "Enrolled Course" as "1"
132
+ Then my profile should list "Webship Testing Basics" with "0%"
133
+ Then my profile should not list "Webship Advanced Testing"
134
+ ```
135
+
136
+ The instructor's course editor:
137
+
138
+ ```gherkin
139
+ Given there is no course "Webship test course"
140
+ Given there is no lesson "Webship test lesson"
141
+ When I start a new course "Webship test course"
142
+ When I add the section "Webship test section" to the curriculum
143
+ When I add the lesson "Webship test lesson" to the section "Webship test section"
144
+ When I add the quiz "Webship test quiz" to the section "Webship test section"
145
+ Then the curriculum should count "1 Section" and "2 Items"
146
+ When I publish the course
147
+ Then the course should be "Pending Review"
148
+ ```
149
+
150
+ The administration, read only (the screens by their names, with the WordPress pack's step):
151
+
152
+ ```gherkin
153
+ When I go to the "Courses" admin screen
154
+ Then the administration should list the course "Webship Testing Basics" with "2 Sections 2 Lessons 1 Quiz"
155
+ When I go to the "Course settings" admin screen
156
+ Then the "Review courses" option should be on
157
+ Then the "Courses per page" option should be "8"
158
+ ```
159
+
160
+ The screens a scenario opens by name: "Courses", "Lessons", "Quizzes", "Questions", "Orders", "Students", "Course
161
+ settings" and "Learning settings".
162
+
163
+ ## Three example features
164
+
165
+ `examples/` beside this file holds three features that pass on a fresh site built with `--install --add-users
166
+ --sample-course`; copy one into `<site>/tests/features/` to start from it:
167
+
168
+ - `examples/enrolling-and-lessons.feature`: a course page for a student who is not enrolled, a free course started
169
+ and its first lesson completed, the progress, the enrolled student's lesson and profile.
170
+ - `examples/the-quiz.feature`: a quiz passed and its review, a quiz failed and retaken, the profile's quizzes tab.
171
+ - `examples/the-course-editor.feature`: a course made by the instructor with a section, a lesson and a quiz and sent
172
+ for review; the courses and the course settings of the administration.
173
+
174
+ ## Traps found on a real site of courses
175
+
176
+ - **A free enrolment records an order.** "Start Now" on a free course makes an order of $0.00, "Completed". Moving it
177
+ to the bin does not end the enrolment: the steps put the enrolment back with the plugin's own tools and delete the
178
+ order for good.
179
+ - **Opening a lesson records progress.** An enrolled account that only opens a lesson has an item "in progress" on
180
+ its course; the steps take it away when the scenario ends.
181
+ - **The plugin keeps a history.** Every enrolment and every attempt writes a history row, which the plugin's own
182
+ "Assign" and "Unassign" keep; the steps remove it with the plugin's "Reset course progress" when every learner of
183
+ the course is an account of the users registry, and say so when one is not: give a course of the suite no other
184
+ learner.
185
+ - **The plugin asks first.** Completing a lesson, finishing a quiz and starting a retake each open a question ("Are
186
+ you sure?"), in one of two kinds of box; the steps answer yes and wait for the page that follows.
187
+ - **The quiz fills by script.** Its questions come after the page loaded, a page at a time ("#page-2"); the steps find
188
+ a question on whichever page it is and wait for the quiz's own state (started, completed).
189
+ - **An instructor's course waits for review.** With "Review courses" on (the default), the instructor's "Publish"
190
+ leaves the course "Pending Review"; the administrator publishes it.
191
+ - **The curriculum editor is drawn by script**, with its own inputs for a section and an item; the counts ("1
192
+ Section", "2 Items") are its heading.
193
+ - **The profile's tabs fill by script**: the steps wait for the tab's list, not only for its link.
194
+
195
+ ## The book
196
+
197
+ For any automated functional testing in this work (a Gherkin feature, a step definition, choosing a
198
+ step, a test run and its failures), read the book *Automated Functional Testing Recipes* first.
199
+
200
+ - **Where.** Use the first that exists: `.claude/automated-functional-testing-recipes/` in the project,
201
+ `~/.claude/automated-functional-testing-recipes/` (installed by webship/webship-js-ai-agent,
202
+ webship/webship-js-skills or webship/ai-agents), or
203
+ https://github.com/webship/webship-js-ai-agent/tree/2.0.x/automated-functional-testing-recipes
204
+ - **How.** Its `README.md` first, then the chapter that matches the task (one file per chapter,
205
+ named by its subject), not the single complete file.
206
+ - **Which wins.** The installed webship-js package and the step pack are the source of truth for
207
+ step phrasing. When they differ from the book, follow them and say so.
208
+ - **For LearnPress.** Start with `ch06-form-testing-recipes.md` (a quiz's answers and the course editor),
209
+ `ch07-waiting-dynamic-content.md` (the quiz, the profile's tabs and the curriculum filled by script),
210
+ `ch08-modal-dialog-testing.md` (the plugin's questions before a lesson is completed, a quiz finished or retaken)
211
+ and `ch21-when-tests-go-bad.md` (flaky, brittle and slow scenarios).
@@ -0,0 +1,34 @@
1
+ Feature: Enrolling and the lessons of a course
2
+ As a student
3
+ I want to enrol in a free course and work through its lessons
4
+ So that I learn it one lesson at a time
5
+
6
+ # An example of the learnpress-scenarios skill. It passes on a site built with --install --add-users
7
+ # --sample-course; the enrolment, its order and the progress come back when each scenario ends.
8
+
9
+ Scenario: A course page shows its curriculum, and a student who is not enrolled is offered to start
10
+ Given I am a logged in user with the "student2" user
11
+ When I go to the course "Webship Testing Basics"
12
+ Then the curriculum should show the section "Getting started" with "What a scenario is", "Steps and features"
13
+ And the instructor of the course should be "Instructor Test"
14
+ And the course page should offer "Start Now"
15
+ And the course page should not offer "Continue"
16
+
17
+ Scenario: A student enrols in a free course and completes its first lesson
18
+ Given I am a logged in user with the "student2" user
19
+ When I start the course "Webship Testing Basics"
20
+ Then the progress of the course should be "0 of 3 items"
21
+ When I open "What a scenario is" in the course "Webship Testing Basics"
22
+ And I complete the lesson
23
+ Then the course should say "Congrats! You have completed “What a scenario is”."
24
+ And the progress of the course should be "1 of 3 items"
25
+ And the item "What a scenario is" should be completed
26
+
27
+ Scenario: The enrolled student completes a lesson, and its profile counts the course
28
+ Given I am a logged in user with the "student" user
29
+ When I open "Steps and features" in the course "Webship Testing Basics"
30
+ And I complete the lesson
31
+ Then the item "Steps and features" should be completed
32
+ When I go to my courses
33
+ Then my profile should count "Enrolled Course" as "1"
34
+ And my profile should list "Webship Testing Basics"
@@ -0,0 +1,29 @@
1
+ Feature: The course editor of an instructor
2
+ As an instructor
3
+ I want to make a course with its sections, lessons and quiz
4
+ So that students can learn it once the administrator has reviewed it
5
+
6
+ # An example of the learnpress-scenarios skill. It passes on a site built with --install --add-users
7
+ # --sample-course; the course, its lesson and its quiz are deleted for good when the scenario ends.
8
+
9
+ Scenario: An instructor makes a course with a section, a lesson and a quiz, and sends it for review
10
+ Given there is no course "Webship test course"
11
+ And there is no lesson "Webship test lesson"
12
+ And there is no quiz "Webship test quiz"
13
+ And I am a logged in user with the "instructor" user
14
+ When I start a new course "Webship test course"
15
+ And I add the section "Webship test section" to the curriculum
16
+ And I add the lesson "Webship test lesson" to the section "Webship test section"
17
+ And I add the quiz "Webship test quiz" to the section "Webship test section"
18
+ Then the curriculum should count "1 Section" and "2 Items"
19
+ When I publish the course
20
+ Then the course should be "Pending Review"
21
+
22
+ Scenario: The administrator reads the courses and how a course is run
23
+ Given I am a logged in user with the "admin" user
24
+ When I go to the "Courses" admin screen
25
+ Then the administration should list the course "Webship Testing Basics" with "2 Sections 2 Lessons 1 Quiz"
26
+ And the administration should list the course "Webship Advanced Testing" with "Free"
27
+ When I go to the "Course settings" admin screen
28
+ Then the "Review courses" option should be on
29
+ And the "Auto start" option should be on
@@ -0,0 +1,43 @@
1
+ Feature: The quiz of a course
2
+ As a student
3
+ I want to take the quiz of a course, see my result and try again
4
+ So that I know what I learned
5
+
6
+ # An example of the learnpress-scenarios skill. It passes on a site built with --install --add-users
7
+ # --sample-course; the quiz's attempts and results come back when each scenario ends.
8
+
9
+ Scenario: A quiz answered right is passed, and its review shows the answers
10
+ Given I am a logged in user with the "student" user
11
+ When I start the quiz "Basics quiz" of the course "Webship Testing Basics"
12
+ And I answer "True" to "A feature holds scenarios."
13
+ And I answer "Given" to "Which keyword sets the scene of a scenario?"
14
+ And I answer "Given", "When" and "Then" to "Which words start a step?"
15
+ And I finish the quiz
16
+ Then the quiz should be passed
17
+ And the quiz result should show "Points" as "3 / 3"
18
+ And the quiz should offer "Retake (2)"
19
+ When I review the quiz
20
+ Then the question "A feature holds scenarios." should show "True" as the right answer
21
+ And the question "A feature holds scenarios." should show "True" as my answer
22
+
23
+ Scenario: A quiz answered wrong is failed, and a retake starts it again
24
+ Given I am a logged in user with the "student" user
25
+ When I start the quiz "Basics quiz" of the course "Webship Testing Basics"
26
+ And I answer "False" to "A feature holds scenarios."
27
+ And I finish the quiz
28
+ Then the quiz should be failed
29
+ And the quiz result should show "Wrong" as "1"
30
+ And the quiz result should show "Skipped" as "2"
31
+ When I retake the quiz
32
+ Then the quiz should offer "Finish Quiz"
33
+
34
+ Scenario: The profile lists the quiz taken, with its result
35
+ Given I am a logged in user with the "student" user
36
+ When I start the quiz "Basics quiz" of the course "Webship Testing Basics"
37
+ And I answer "True" to "A feature holds scenarios."
38
+ And I answer "Given" to "Which keyword sets the scene of a scenario?"
39
+ And I answer "Given", "When" and "Then" to "Which words start a step?"
40
+ And I finish the quiz
41
+ When I go to my courses
42
+ And I open the "Quizzes" tab of my profile
43
+ Then my profile should list "Basics quiz" with "Passed"
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # workspace-name: LearnPress (courses on WordPress)
4
+
5
+ # Installed by the LearnPress plugin (plugins.sh --install learnpress); __WORKSPACE__ is the workspace it was installed into.
6
+ #
7
+ # Build a site of courses in a container: the WordPress plugin's builder makes the site (the latest WordPress, or the
8
+ # one --wordpress-version names), then the free LearnPress plugin is added from the plugin directory, on DDEV by
9
+ # default or on the runtime --runtime names. With --install LearnPress is activated (its tables, its pages, its roles);
10
+ # with --add-users the default accounts, one per place in the courses; with --sample-course the courses, lessons, quiz
11
+ # and enrolment the step pack's features name. The courses' own tool is cmd-tools-learnpress-courses.sh; WP-CLI is
12
+ # the WordPress plugin's tool: bash cmd-tools-wordpress-cli.sh <name> --run "post list --post_type=lp_course".
13
+
14
+ # Bootstrap.
15
+ # Find the workspace tooling from this script, so a fresh clone needs no setup.
16
+ WORKSPACE_SCRIPTS="${WORKSPACE_SCRIPTS:-$(cd "$(dirname "${BASH_SOURCE[0]}")/../core/scripts" && pwd)}";
17
+ source ${WORKSPACE_SCRIPTS}/bootstrap.sh || exit 1 ;
18
+
19
+ # Load workspace settings.
20
+ eval $(parse_yaml ${WORKSPACE_CONFIG}/workspace.__WORKSPACE__.settings.yml);
21
+
22
+ # Set the versions: of LearnPress (--version) and of WordPress (--wordpress-version).
23
+ site_version="latest";
24
+ wordpress_version="latest";
25
+
26
+ # Distribution.
27
+ distribution_name="learnpress";
28
+ distribution_title="LearnPress";
29
+ distribution_webroot="";
30
+
31
+ ARGPARSE_DESCRIPTION="Build a ${distribution_title} site of courses in __WORKSPACE__"
32
+ # The args file comes with the plugin: core/scripts/plugins/learnpress/ is where plugins.sh --install puts it.
33
+ source ${WORKSPACE_SCRIPTS}/plugins/learnpress/args/arg-learnpress.sh || exit 1 ;
34
+
35
+ shift $#;
36
+
37
+ learnpress_build ;
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # Installed by the LearnPress plugin (plugins.sh --install learnpress); __WORKSPACE__ is the workspace it was installed into.
4
+ #
5
+ # The courses of one site of this workspace, in the project's web container: say what they hold (the courses and each
6
+ # account's enrolments and progress), add or cancel the default accounts, add the sample courses, take away what a
7
+ # stopped test run left. Nothing here runs on the host.
8
+
9
+ # Bootstrap.
10
+ # Find the workspace tooling from this script, so a fresh clone needs no setup.
11
+ WORKSPACE_SCRIPTS="${WORKSPACE_SCRIPTS:-$(cd "$(dirname "${BASH_SOURCE[0]}")/../core/scripts" && pwd)}";
12
+ source ${WORKSPACE_SCRIPTS}/bootstrap.sh || exit 1 ;
13
+
14
+ # Load workspace settings.
15
+ eval $(parse_yaml ${WORKSPACE_CONFIG}/workspace.__WORKSPACE__.settings.yml);
16
+
17
+ # Distribution.
18
+ distribution_name="learnpress";
19
+
20
+ ARGPARSE_DESCRIPTION="The courses of a site of __WORKSPACE__: what they hold, the default accounts, the sample courses, a tidy-up"
21
+ # The args file comes with the plugin: core/scripts/plugins/learnpress/ is where plugins.sh --install puts it.
22
+ source ${WORKSPACE_SCRIPTS}/plugins/learnpress/args/arg-learnpress-courses.sh || exit 1 ;
23
+
24
+ shift $#;
25
+
26
+ learnpress_courses_tool ;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * LearnPress for Webship Workspace: a platform plugin, on top of the WordPress plugin.
3
+ *
4
+ * What the package carries is placed by the installer from the manifest: the builder and the courses' tool in the
5
+ * sites folders, their functions and argparse under core/scripts/plugins/learnpress/, the courses' first feature and
6
+ * the script that writes the accounts' places and the sample courses beside them, and its AI items (ai/ in this
7
+ * package) in the folder of their kind: the agents in AI Agents, the skill in AI Skills, the command in AI Commands,
8
+ * the prompts in AI Prompts. The plugin needs the WordPress plugin (the manifest's `needs`): its builder starts from
9
+ * that plugin's, and the site's WP-CLI is that plugin's tool. The dashboard needs nothing drawn for it: the builder is
10
+ * in the Build list because it is a cmd-*-project.sh, the row menus are the core's, the AI items are listed like any
11
+ * other. What register() adds is what the assistant is told.
12
+ *
13
+ * Everything the dashboard is asked for goes through `api`; this package requires nothing from the dashboard's own
14
+ * files, so it can be installed from npm and removed without a trace.
15
+ */
16
+ import type { PluginApi } from '@webship.co/workspace-plugin-api';
17
+ /**
18
+ * The plugin's name: the folder of its scripts and the name its functions carry. A site of courses is a WordPress
19
+ * project of the container tool: the plugin claims it with .ddev/config.learnpress.yaml (or the x-webship block on
20
+ * another runtime), and the core's tools call its functions under learnpress.
21
+ */
22
+ export declare const PLATFORM = "learnpress";
23
+ /** The plugin it builds on (a need of the manifest): its builder makes the site, its CLI tool runs WP-CLI. */
24
+ export declare const BASE = "wordpress";
25
+ /** The commands the installer places in every sites folder. */
26
+ export declare const COMMANDS: string[];
27
+ /** The agents the installer places in the AI Agents folder. */
28
+ export declare const AGENTS: string[];
29
+ /** The skill the installer places in the AI Skills folder (a folder each, with its SKILL.md). */
30
+ export declare const SKILLS: string[];
31
+ /** The slash command the installer places in the AI Commands folder. */
32
+ export declare const AI_COMMANDS: string[];
33
+ /** The prompts the installer places in the AI Prompts folder: each a whole launch command for a new session. */
34
+ export declare const PROMPTS: string[];
35
+ /** What the assistant is told about LearnPress in this workspace. */
36
+ export declare function assistantContext(): string;
37
+ export declare function register(api: PluginApi): void;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ /**
3
+ * LearnPress for Webship Workspace: a platform plugin, on top of the WordPress plugin.
4
+ *
5
+ * What the package carries is placed by the installer from the manifest: the builder and the courses' tool in the
6
+ * sites folders, their functions and argparse under core/scripts/plugins/learnpress/, the courses' first feature and
7
+ * the script that writes the accounts' places and the sample courses beside them, and its AI items (ai/ in this
8
+ * package) in the folder of their kind: the agents in AI Agents, the skill in AI Skills, the command in AI Commands,
9
+ * the prompts in AI Prompts. The plugin needs the WordPress plugin (the manifest's `needs`): its builder starts from
10
+ * that plugin's, and the site's WP-CLI is that plugin's tool. The dashboard needs nothing drawn for it: the builder is
11
+ * in the Build list because it is a cmd-*-project.sh, the row menus are the core's, the AI items are listed like any
12
+ * other. What register() adds is what the assistant is told.
13
+ *
14
+ * Everything the dashboard is asked for goes through `api`; this package requires nothing from the dashboard's own
15
+ * files, so it can be installed from npm and removed without a trace.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.PROMPTS = exports.AI_COMMANDS = exports.SKILLS = exports.AGENTS = exports.COMMANDS = exports.BASE = exports.PLATFORM = void 0;
19
+ exports.assistantContext = assistantContext;
20
+ exports.register = register;
21
+ /**
22
+ * The plugin's name: the folder of its scripts and the name its functions carry. A site of courses is a WordPress
23
+ * project of the container tool: the plugin claims it with .ddev/config.learnpress.yaml (or the x-webship block on
24
+ * another runtime), and the core's tools call its functions under learnpress.
25
+ */
26
+ exports.PLATFORM = 'learnpress';
27
+ /** The plugin it builds on (a need of the manifest): its builder makes the site, its CLI tool runs WP-CLI. */
28
+ exports.BASE = 'wordpress';
29
+ /** The commands the installer places in every sites folder. */
30
+ exports.COMMANDS = ['cmd-learnpress-project.sh', 'cmd-tools-learnpress-courses.sh'];
31
+ /** The agents the installer places in the AI Agents folder. */
32
+ exports.AGENTS = ['learnpress-site-builder', 'learnpress-tester'];
33
+ /** The skill the installer places in the AI Skills folder (a folder each, with its SKILL.md). */
34
+ exports.SKILLS = ['learnpress-scenarios'];
35
+ /** The slash command the installer places in the AI Commands folder. */
36
+ exports.AI_COMMANDS = ['learnpress-test'];
37
+ /** The prompts the installer places in the AI Prompts folder: each a whole launch command for a new session. */
38
+ exports.PROMPTS = ['learnpress-build-and-test', 'learnpress-quiz-round'];
39
+ /** What the assistant is told about LearnPress in this workspace. */
40
+ function assistantContext() {
41
+ return [
42
+ 'LearnPress (a plugin, @webship.co/workspace-learnpress, on top of the WordPress plugin): a site of courses is built with',
43
+ '`bash cmd-learnpress-project.sh <name> --install --add-users --sample-course` from a sites folder (dev, test, sandboxes, demos):',
44
+ 'the WordPress plugin\'s builder makes the site, then the free LearnPress plugin is added from the plugin directory (its activation makes its tables, its pages and its roles),',
45
+ 'in a container like every other project: on DDEV by default, at https://<name>.ddev.site/courses/, or with `--runtime docker|podman|kubernetes|lando|docksal` on that runtime, at the address the build prints;',
46
+ '`--sample-course` adds the two free courses of the instructor, their sections and lessons, a quiz with three questions and the student\'s enrolment the step pack\'s features name,',
47
+ '`--add-users` the default accounts, one per place in the courses (administrator, instructor, student, student2).',
48
+ '`bash cmd-tools-learnpress-courses.sh <name>` says what the courses hold; with `--add-users`, `--cancel-users`, `--sample-course` or `--tidy` it changes them.',
49
+ 'WP-CLI is the WordPress plugin\'s tool: `bash cmd-tools-wordpress-cli.sh <name> --run "post list --post_type=lp_course"`.',
50
+ '`bash cmd-tools-testing.sh <name>` sets up webship-js with the LearnPress step pack and the WordPress pack it extends; `--run` runs the suite.',
51
+ `For LearnPress work, hand over to the agents ${exports.AGENTS.map((a) => `\`${a}\``).join(' and ')}.`,
52
+ `The plugin also places the skill ${exports.SKILLS.map((a) => `\`${a}\``).join(', ')} (the step pack's phrases, by area) in ai-skills/,`,
53
+ `the command ${exports.AI_COMMANDS.map((a) => `\`/${a} <site>\``).join(', ')} in ai-commands/ and the prompts ${exports.PROMPTS.map((a) => `\`${a}\``).join(' and ')} in ai-prompts/.`,
54
+ 'Never run php, wp or composer on the host for a project; never install a paid add-on or connect the site to an account anywhere.',
55
+ ].join(' ');
56
+ }
57
+ function register(api) {
58
+ api.addAssistantContext(assistantContext);
59
+ }
60
+ //# sourceMappingURL=index.js.map