Skip to content

Commit bfd156b

Browse files
test(web): Labs entry, Labs start and the practice-check hop go red (W1)
Base: 355db26 (main after lanes S, C, R, T; wave-2 brief for W) Red-only commit, no production logic. `test_web_modules.py` drives the real app through TestClient: no Labs entry with an empty lockfile and one listing deck/task ids and prompts after `ModuleStore.add(valid-scaffold)`; the loopback route per council M0 Q2 (401 without the token header, 403 with a wrong token, 403 from a non-loopback peer, 422 naming an extra field, 200 carrying lane T's delivery outcome, 409 on a replayed (attempt_id, phase), 429 on the sixth envelope in a minute); `POST /api/modules/labs/start` reusing the one session-start path (201 start payload + drill, 200 attached when the session is live, 404 unknown drill) and a cancel that leaves the session untouched. Every red fails on its status assertion (405/404 -- no route is mounted). `tests/js/module-labs.test.js` pins the client module; `static/js/labs.js` is an interface stub whose every export throws, so the node suite fails on behaviour rather than on import (00-common.md §2). Evidence: evidence/W/w1-web-modules.red.txt (20 failed, 1 passed -- the "no Labs entry with no module" negative is green by construction), evidence/W/w1-module-labs-js.red.txt (17 fail, 0 pass).
1 parent 355db26 commit bfd156b

5 files changed

Lines changed: 1141 additions & 0 deletions

File tree

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
node --test packages/studyloop/tests/js/module-labs.test.js
2+
# worktree: module-web-labs HEAD: 355db26c 2026-10-04T23:10:30Z (W1: labs.js is an interface stub -- every export throws NotImplementedError)
3+
✖ labsEntries is empty for an options payload with no labs key, and for a non-array (0.037416ms)
4+
✖ labsEntries keeps ids, prompts and success criteria and drops anything mentor-side (0.049458ms)
5+
✖ drillCommands prefers the server commands and otherwise derives them from the phases (0.035958ms)
6+
✖ the store is unavailable until a refresh finds an installed module (0.082375ms)
7+
✖ the store becomes available with one installed module and exposes it scrubbed (0.055625ms)
8+
✖ a failed refresh hides Labs rather than showing a stale list (0.045083ms)
9+
✖ starting a drill posts the drill identity (and the chosen agent) to the labs start route (0.084584ms)
10+
✖ a fresh start (201) lands the learner in the Study Session view and re-reads the live session (0.086166ms)
11+
✖ an attached start (200) does not reload: the session was already the learner's (0.056208ms)
12+
✖ the active drill never carries mentor-side fields, whatever the server sent (0.045208ms)
13+
✖ a refused start (409 from another view, 503 without an agent) is shown, not swallowed (0.040792ms)
14+
✖ start without an agent is refused locally with the picker's own hint (0.044042ms)
15+
✖ cancel posts to the cancel route, clears the drill and leaves the session alone (0.061708ms)
16+
✖ a start in flight can be cancelled: the late 201 is dropped and nothing is adopted (0.059958ms)
17+
✖ the view restores a live drill from storage on init and reads the agents from the store (0.047875ms)
18+
ℹ tests 17
19+
ℹ suites 0
20+
ℹ pass 0
21+
ℹ fail 17
22+
ℹ cancelled 0
23+
ℹ skipped 0
24+
ℹ todo 0
25+
ℹ duration_ms 35.674208
26+
27+
✖ failing tests:
28+
29+
test at packages/studyloop/tests/js/module-labs.test.js:63:1
30+
✖ the mentor-only field list is exactly the three §5.6 fields (plus the snake_case twin) (0.891167ms)
31+
AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:
32+
+ actual - expected
33+
34+
+ []
35+
- [
36+
- 'hint',
37+
- 'mentorNotes',
38+
- 'mentor_notes',
39+
- 'solution'
40+
- ]
41+
42+
generatedMessage: true,
43+
code: 'ERR_ASSERTION',
44+
actual: [],
45+
expected: [ 'hint', 'mentorNotes', 'mentor_notes', 'solution' ],
46+
operator: 'deepStrictEqual',
47+
diff: 'simple'
48+
}
49+
50+
test at packages/studyloop/tests/js/module-labs.test.js:67:1
51+
✖ containsMentorOnlyFields finds a forbidden key anywhere in a payload (0.056209ms)
52+
Error: NotImplementedError: labs.js lands in W2
53+
54+
test at packages/studyloop/tests/js/module-labs.test.js:76:1
55+
✖ labsEntries is empty for an options payload with no labs key, and for a non-array (0.037416ms)
56+
Error: NotImplementedError: labs.js lands in W2
57+
58+
test at packages/studyloop/tests/js/module-labs.test.js:82:1
59+
✖ labsEntries keeps ids, prompts and success criteria and drops anything mentor-side (0.049458ms)
60+
Error: NotImplementedError: labs.js lands in W2
61+
62+
test at packages/studyloop/tests/js/module-labs.test.js:102:1
63+
✖ drillCommands prefers the server commands and otherwise derives them from the phases (0.035958ms)
64+
Error: NotImplementedError: labs.js lands in W2
65+
66+
test at packages/studyloop/tests/js/module-labs.test.js:113:1
67+
✖ the store is unavailable until a refresh finds an installed module (0.082375ms)
68+
Error: NotImplementedError: labs.js lands in W2
69+
70+
test at packages/studyloop/tests/js/module-labs.test.js:123:1
71+
✖ the store becomes available with one installed module and exposes it scrubbed (0.055625ms)
72+
Error: NotImplementedError: labs.js lands in W2
73+
74+
test at packages/studyloop/tests/js/module-labs.test.js:136:1
75+
✖ a failed refresh hides Labs rather than showing a stale list (0.045083ms)
76+
Error: NotImplementedError: labs.js lands in W2
77+
78+
test at packages/studyloop/tests/js/module-labs.test.js:183:1
79+
✖ starting a drill posts the drill identity (and the chosen agent) to the labs start route (0.084584ms)
80+
Error: NotImplementedError: labs.js lands in W2
81+
82+
test at packages/studyloop/tests/js/module-labs.test.js:195:1
83+
✖ a fresh start (201) lands the learner in the Study Session view and re-reads the live session (0.086166ms)
84+
Error: NotImplementedError: labs.js lands in W2
85+
86+
test at packages/studyloop/tests/js/module-labs.test.js:205:1
87+
✖ an attached start (200) does not reload: the session was already the learner's (0.056208ms)
88+
Error: NotImplementedError: labs.js lands in W2
89+
90+
test at packages/studyloop/tests/js/module-labs.test.js:215:1
91+
✖ the active drill never carries mentor-side fields, whatever the server sent (0.045208ms)
92+
Error: NotImplementedError: labs.js lands in W2
93+
94+
test at packages/studyloop/tests/js/module-labs.test.js:223:1
95+
✖ a refused start (409 from another view, 503 without an agent) is shown, not swallowed (0.040792ms)
96+
Error: NotImplementedError: labs.js lands in W2
97+
98+
test at packages/studyloop/tests/js/module-labs.test.js:235:1
99+
✖ start without an agent is refused locally with the picker's own hint (0.044042ms)
100+
Error: NotImplementedError: labs.js lands in W2
101+
102+
test at packages/studyloop/tests/js/module-labs.test.js:244:1
103+
✖ cancel posts to the cancel route, clears the drill and leaves the session alone (0.061708ms)
104+
Error: NotImplementedError: labs.js lands in W2
105+
106+
test at packages/studyloop/tests/js/module-labs.test.js:258:1
107+
✖ a start in flight can be cancelled: the late 201 is dropped and nothing is adopted (0.059958ms)
108+
Error: NotImplementedError: labs.js lands in W2
109+
110+
test at packages/studyloop/tests/js/module-labs.test.js:281:1
111+
✖ the view restores a live drill from storage on init and reads the agents from the store (0.047875ms)
112+
Error: NotImplementedError: labs.js lands in W2
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
env -u VIRTUAL_ENV uv run pytest packages/studyloop/tests/test_web_modules.py -q -p no:cacheprovider
2+
# worktree: module-web-labs HEAD: 355db26c 2026-10-04T23:10:00Z TMPDIR=$(getconf DARWIN_USER_TEMP_DIR) (W1: no route, no Labs entry, no labs.js)
3+
E AssertionError: {"detail":"Method Not Allowed"}
4+
E assert 405 == 201
5+
E + where 405 = <Response [405 Method Not Allowed]>.status_code
6+
________________ test_labs_cancel_leaves_the_session_untouched _________________
7+
packages/studyloop/tests/test_web_modules.py:418: in test_labs_cancel_leaves_the_session_untouched
8+
assert started.status_code == 201, started.text
9+
E AssertionError: {"detail":"Method Not Allowed"}
10+
E assert 405 == 201
11+
E + where 405 = <Response [405 Method Not Allowed]>.status_code
12+
_____________ test_labs_start_rejects_a_body_with_an_unknown_field _____________
13+
packages/studyloop/tests/test_web_modules.py:438: in test_labs_start_rejects_a_body_with_an_unknown_field
14+
assert response.status_code == 422, response.text
15+
E AssertionError: {"detail":"Method Not Allowed"}
16+
E assert 405 == 422
17+
E + where 405 = <Response [405 Method Not Allowed]>.status_code
18+
_____________ test_practice_check_without_the_token_header_is_401 ______________
19+
packages/studyloop/tests/test_web_modules.py:452: in test_practice_check_without_the_token_header_is_401
20+
assert response.status_code == 401, response.text
21+
E AssertionError: {"detail":"Method Not Allowed"}
22+
E assert 405 == 401
23+
E + where 405 = <Response [405 Method Not Allowed]>.status_code
24+
_______________ test_practice_check_with_the_wrong_token_is_403 ________________
25+
packages/studyloop/tests/test_web_modules.py:461: in test_practice_check_with_the_wrong_token_is_403
26+
assert response.status_code == 403, response.text
27+
E AssertionError: {"detail":"Method Not Allowed"}
28+
E assert 405 == 403
29+
E + where 405 = <Response [405 Method Not Allowed]>.status_code
30+
__ test_practice_check_from_a_non_loopback_address_is_403_even_with_the_token __
31+
packages/studyloop/tests/test_web_modules.py:471: in test_practice_check_from_a_non_loopback_address_is_403_even_with_the_token
32+
assert response.status_code == 403, response.text
33+
E AssertionError: {"detail":"Method Not Allowed"}
34+
E assert 405 == 403
35+
E + where 405 = <Response [405 Method Not Allowed]>.status_code
36+
______________ test_practice_check_names_an_extra_field_with_422 _______________
37+
packages/studyloop/tests/test_web_modules.py:484: in test_practice_check_names_an_extra_field_with_422
38+
assert response.status_code == 422, response.text
39+
E AssertionError: {"detail":"Method Not Allowed"}
40+
E assert 405 == 422
41+
E + where 405 = <Response [405 Method Not Allowed]>.status_code
42+
_____ test_practice_check_with_no_active_session_is_200_no_active_session ______
43+
packages/studyloop/tests/test_web_modules.py:497: in test_practice_check_with_no_active_session_is_200_no_active_session
44+
assert response.status_code == 200, response.text
45+
E AssertionError: {"detail":"Method Not Allowed"}
46+
E assert 405 == 200
47+
E + where 405 = <Response [405 Method Not Allowed]>.status_code
48+
_____________ test_practice_check_delivers_into_the_active_session _____________
49+
packages/studyloop/tests/test_web_modules.py:517: in test_practice_check_delivers_into_the_active_session
50+
assert response.status_code == 200, response.text
51+
E AssertionError: {"detail":"Method Not Allowed"}
52+
E assert 405 == 200
53+
E + where 405 = <Response [405 Method Not Allowed]>.status_code
54+
_ test_practice_check_token_of_another_session_is_403_when_a_session_is_active _
55+
packages/studyloop/tests/test_web_modules.py:539: in test_practice_check_token_of_another_session_is_403_when_a_session_is_active
56+
assert response.status_code == 403, response.text
57+
E AssertionError: {"detail":"Method Not Allowed"}
58+
E assert 405 == 403
59+
E + where 405 = <Response [405 Method Not Allowed]>.status_code
60+
_______ test_practice_check_replay_of_the_same_attempt_and_phase_is_409 ________
61+
packages/studyloop/tests/test_web_modules.py:553: in test_practice_check_replay_of_the_same_attempt_and_phase_is_409
62+
assert first.status_code == 200, first.text
63+
E AssertionError: {"detail":"Method Not Allowed"}
64+
E assert 405 == 200
65+
E + where 405 = <Response [405 Method Not Allowed]>.status_code
66+
__________ test_practice_check_sixth_envelope_within_a_minute_is_429 ___________
67+
packages/studyloop/tests/test_web_modules.py:569: in test_practice_check_sixth_envelope_within_a_minute_is_429
68+
assert statuses == [200, 200, 200, 200, 200, 429], statuses
69+
E AssertionError: [405, 405, 405, 405, 405, 405]
70+
E assert [405, 405, 405, 405, 405, 405] == [200, 200, 200, 200, 200, 429]
71+
E
72+
E At index 0 diff: 405 != 200
73+
E Use -v to get more diff
74+
______________ test_practice_check_with_no_claimed_session_is_401 ______________
75+
packages/studyloop/tests/test_web_modules.py:577: in test_practice_check_with_no_claimed_session_is_401
76+
assert response.status_code in (401, 403), response.text
77+
E AssertionError: {"detail":"Method Not Allowed"}
78+
E assert 405 in (401, 403)
79+
E + where 405 = <Response [405 Method Not Allowed]>.status_code
80+
____________ test_practice_check_rejects_a_non_object_body_with_400 ____________
81+
packages/studyloop/tests/test_web_modules.py:592: in test_practice_check_rejects_a_non_object_body_with_400
82+
assert response.status_code == 400, response.text
83+
E AssertionError: {"detail":"Method Not Allowed"}
84+
E assert 405 == 400
85+
E + where 405 = <Response [405 Method Not Allowed]>.status_code
86+
_________________ test_the_module_routes_are_mounted_under_api _________________
87+
packages/studyloop/tests/test_web_modules.py:604: in test_the_module_routes_are_mounted_under_api
88+
assert "/api/modules/labs" in paths
89+
E AssertionError: assert '/api/modules/labs' in {'', '/', '/api/artefacts/{course}', '/api/backlog', '/api/backlog/demote', '/api/backlog/dismiss', ...}
90+
=============================== warnings summary ===============================
91+
.venv/lib/python3.12/site-packages/starlette/testclient.py:53
92+
/Users/ataylor/code/personal/tools/studyloop-wt/module-web-labs/.venv/lib/python3.12/site-packages/starlette/testclient.py:53: DeprecationWarning: The anyio.abc.BlockingPortal alias is deprecated, use anyio.from_thread.BlockingPortal instead.
93+
_PortalFactoryType = Callable[[], AbstractContextManager[anyio.abc.BlockingPortal]]
94+
95+
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
96+
=========================== short test summary info ============================
97+
FAILED packages/studyloop/tests/test_web_modules.py::test_options_list_the_installed_module_by_deck_and_task_ids_and_prompts
98+
FAILED packages/studyloop/tests/test_web_modules.py::test_labs_route_lists_ids_prompts_and_success_criteria_only
99+
FAILED packages/studyloop/tests/test_web_modules.py::test_labs_route_is_empty_with_no_module
100+
FAILED packages/studyloop/tests/test_web_modules.py::test_labs_start_refuses_an_unknown_drill_with_404
101+
FAILED packages/studyloop/tests/test_web_modules.py::test_labs_start_starts_the_one_claimed_session_through_the_session_start_path
102+
FAILED packages/studyloop/tests/test_web_modules.py::test_labs_start_with_the_session_live_attaches_instead_of_starting_a_second
103+
FAILED packages/studyloop/tests/test_web_modules.py::test_labs_cancel_leaves_the_session_untouched
104+
FAILED packages/studyloop/tests/test_web_modules.py::test_labs_start_rejects_a_body_with_an_unknown_field
105+
FAILED packages/studyloop/tests/test_web_modules.py::test_practice_check_without_the_token_header_is_401
106+
FAILED packages/studyloop/tests/test_web_modules.py::test_practice_check_with_the_wrong_token_is_403
107+
FAILED packages/studyloop/tests/test_web_modules.py::test_practice_check_from_a_non_loopback_address_is_403_even_with_the_token
108+
FAILED packages/studyloop/tests/test_web_modules.py::test_practice_check_names_an_extra_field_with_422
109+
FAILED packages/studyloop/tests/test_web_modules.py::test_practice_check_with_no_active_session_is_200_no_active_session
110+
FAILED packages/studyloop/tests/test_web_modules.py::test_practice_check_delivers_into_the_active_session
111+
FAILED packages/studyloop/tests/test_web_modules.py::test_practice_check_token_of_another_session_is_403_when_a_session_is_active
112+
FAILED packages/studyloop/tests/test_web_modules.py::test_practice_check_replay_of_the_same_attempt_and_phase_is_409
113+
FAILED packages/studyloop/tests/test_web_modules.py::test_practice_check_sixth_envelope_within_a_minute_is_429
114+
FAILED packages/studyloop/tests/test_web_modules.py::test_practice_check_with_no_claimed_session_is_401
115+
FAILED packages/studyloop/tests/test_web_modules.py::test_practice_check_rejects_a_non_object_body_with_400
116+
FAILED packages/studyloop/tests/test_web_modules.py::test_the_module_routes_are_mounted_under_api
117+
20 failed, 1 passed, 1 warning in 1.68s
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* Labs -- the Web UI entry for installed modules' drills (module-contract v1, lane W).
3+
*
4+
* WAVE-2 W1 STUB: the public surface `tests/js/module-labs.test.js` drives, with every
5+
* body throwing. Implemented in W2.
6+
*/
7+
8+
const notImplemented = () => { throw new Error('NotImplementedError: labs.js lands in W2'); };
9+
10+
export const MENTOR_ONLY_FIELDS = Object.freeze([]);
11+
12+
export function containsMentorOnlyFields() { notImplemented(); }
13+
export function labsEntries() { notImplemented(); }
14+
export function drillCommands() { notImplemented(); }
15+
export function labsStore() { notImplemented(); }
16+
export function labsView() { notImplemented(); }

0 commit comments

Comments
 (0)