diff --git a/scripts/record-scene.py b/scripts/record-scene.py index 0167e0ba..eee37791 100644 --- a/scripts/record-scene.py +++ b/scripts/record-scene.py @@ -924,6 +924,11 @@ def point_at(self, target) -> dict: if box is None: return {} x, y = int(box["x"] + box["width"] / 2), int(box["y"] + box["height"] / 2) + width, height = self.page.viewport_size["width"], self.page.viewport_size["height"] + if x > width - AVATAR_WIDTH and y > height - AVATAR_HEIGHT: + fault = f"at {self._at():.2f}s: the press on step {self.step_number} lands at {x},{y}" + self.corner_faults.append(fault) + print(f" CORNER: {fault}", flush=True) start = self.cursor_to(x, y, CURSOR_GLIDE_SECONDS) self.page.wait_for_timeout(int(CURSOR_REST_SECONDS * 1000)) ripple_at = self._at() @@ -938,7 +943,11 @@ def clear_of_caption(self, selector: str) -> None: scroll: Playwright cannot press it, and a viewer would not see it pressed. When the thing is under the bar, room is added once below the page's last row and the thing is put in the middle of the window. A - thing already clear is left where it is, so no other take moves. + thing that reaches across into the avatar's columns is held above the + avatar's corner instead, box padding and all: the right-hand half of + the station screen (its Issue card, its queue) sits there once + scrolled, and studio draws its narrator over it. A thing already clear + is left where it is, so no other take moves. The thing is found the way the click will find it, by Playwright's own locator: a scene's selector may say `:has-text("Release")`, which @@ -949,9 +958,13 @@ def clear_of_caption(self, selector: str) -> None: if not found.count(): return found.first.evaluate( - """(node, bar) => { + """(node, [bar, cornerWidth, cornerHeight]) => { const box = node.getBoundingClientRect(); - if (box.bottom <= window.innerHeight - bar) return; + // A thing that reaches across into the avatar's columns has + // the avatar's corner as its floor, not the caption bar. + const floor = box.right > window.innerWidth - cornerWidth + ? window.innerHeight - cornerHeight : window.innerHeight - bar; + if (box.bottom <= floor) return; if (!document.getElementById('fs-scene-room')) { const room = document.createElement('div'); room.id = 'fs-scene-room'; @@ -960,7 +973,7 @@ def clear_of_caption(self, selector: str) -> None: } node.scrollIntoView({ block: 'center', behavior: 'instant' }); }""", - CAPTION_HEIGHT * 2, + [CAPTION_HEIGHT * 2, AVATAR_WIDTH, AVATAR_HEIGHT + 2 * CALLOUT_PAD], ) def wait_for(self, step: dict, timeout: float) -> None: @@ -1152,7 +1165,7 @@ def scroll_to(self, selector: str, block: str, offset: int, text: str | None = N const into = (r) => r.width > 0 && r.height > 0 && r.right > corner.left && r.bottom > corner.top && r.left < width && r.top < height; const found = []; - for (const id of ['fs-scene-cap', 'fs-scene-badge', 'fs-scene-callout-label']) { + for (const id of ['fs-scene-cap', 'fs-scene-badge', 'fs-scene-callout', 'fs-scene-callout-label']) { const el = document.getElementById(id); if (!el || getComputedStyle(el).display === 'none') continue; const r = el.getBoundingClientRect(); diff --git a/scripts/scenes/README.md b/scripts/scenes/README.md index 0479bcd1..3aad4ab4 100644 --- a/scripts/scenes/README.md +++ b/scripts/scenes/README.md @@ -36,6 +36,8 @@ after it, so those stills show the box; `label` puts a few words on a tab at the box's top left (below it when the box is at the top of the frame, inside it when the box fills the frame); `style = "spotlight"` dims the rest of the frame instead. A thing off the frame, or under the page's sticky -header or the caption bar, is scrolled clear first; a thing not on the page +header or the caption bar, or reaching into the narrator's corner at the +bottom right (240 by 200), is scrolled clear first; a thing not on the page refuses the take, naming the step. Point `at` something smaller than the -frame. `label` or `style` without `at` is refused. +frame. `label` or `style` without `at` is refused. A box, a label or a press +that still lands in the narrator's corner fails the take, as a caption there does. diff --git a/scripts/scenes/course/03-01-the-station-screen.toml b/scripts/scenes/course/03-01-the-station-screen.toml index 161544a8..2f052309 100644 --- a/scripts/scenes/course/03-01-the-station-screen.toml +++ b/scripts/scenes/course/03-01-the-station-screen.toml @@ -19,8 +19,10 @@ take_is = "lesson" part = "hook" base = "http://127.0.0.1:8040" badge = "pre-alpha · simulated plant · v{version}" -# Four to six minutes, as the outline says this class runs. -budget_seconds = 360 +# Four to six minutes, as the outline says this class runs, and up to half a +# minute more for reaching the station and the Orders page by the menus (Scott, +# 2026-11-15: click through the menus even if the class runs longer). +budget_seconds = 390 gif_skip_seconds = 2.0 width = 1280 height = 720 @@ -36,6 +38,7 @@ notes = [ "The cutlery pack carries no maintenance plan, so the maintenance card says nothing is owed. That is the product's answer for this plant, filmed as drawn.", "The second booking, 5,000 good, is typed to show that the station does not check a typed figure against the mould's own counter. It is a write to a scratch plant that is thrown away when the take ends.", "At any speed but 1x every 2D page carries the product's REPLAY 10× banner across its top. It is filmed as the product draws it.", + "The class is clicked through as a person would: the only page opened by address is the Floor, the first page after sign-in. The station is reached by the Floor menu's Station tab and the mould chosen from its Machine list; the planned order is reached by the Orders menu and found with its search box; the way back is Floor, then Station.", "The opening beat is a plain card with words on it. There is no artwork of a machine, a tablet or a person.", ] @@ -127,11 +130,28 @@ name = "four-words" # ------------------------------------------------------------ on the screen +# The station is reached the way an operator reaches it: the Floor page (the +# one page opened by address, the first after signing in), its Station chip, +# and the Machine chooser at the top of the station screen. The product has no +# other station picker; the Floor page's own forms are not the station. [[step]] part = "screen" do = "goto" -url = "/dashboard/station?m=FORK1_Mold" -settle = 3 +url = "/dashboard" +settle = 2 + +[[step]] +do = "click" +selector = "nav.subnav a:text-is(\"Station\")" + +[[step]] +do = "wait_for" +js = "document.querySelector('#machine').options.length > 1" + +[[step]] +do = "choose" +selector = "#machine" +value = "FORK1_Mold" [[step]] do = "wait_for" @@ -141,10 +161,14 @@ text = "WO-FORK1-0001" [[step]] do = "say" line = "The station screen of the fork mould, FORK1_Mold. The machine is chosen at the top; the operator starts the shift here." +at = "#machine" +label = "Machine" [[step]] do = "say" line = "First card, its state: running, and since when. Going down asks why, which is the next class." +at = "#state-buttons" +label = "State" [[step]] do = "mark" @@ -153,10 +177,14 @@ name = "its-state" [[step]] do = "say" line = "Second card, its queue: the order it is running, WO-FORK1-0001, step 10, Mold, and how many good of how many ordered." +at = "#queue li.running-op" +label = "Running order" [[step]] do = "say" line = "That count moves by itself: the mould's own counter books every shot it makes." +at = "#queue li.running-op .what .muted" +label = "Good of ordered" [[step]] do = "mark" @@ -173,6 +201,8 @@ scroll_offset = 300 [[step]] do = "say" line = "Third card, book output. Against: the order at the head of the queue, step 10. The operator counts a box." +at = "#book-order" +label = "Against" [[step]] do = "choose" @@ -192,6 +222,8 @@ text = "3" [[step]] do = "say" line = "Five hundred good, three scrap. Book." +at = "#book .big-io" +label = "Good and scrap" [[step]] do = "click" @@ -213,6 +245,8 @@ scroll_offset = 300 [[step]] do = "say" line = "Booked, against WO-FORK1-0001 step 10, under the name of the person signed in. The queue's count is up by five hundred." +at = "#queue li.running-op .what .muted" +label = "The count" [[step]] do = "mark" @@ -221,6 +255,8 @@ name = "booked-500-good-3-scrap" [[step]] do = "say" line = "Fourth card, issue material. It issues to the order running here, WO-FORK1-0001." +at = "#issue-where" +label = "Issues to" [[step]] do = "choose" @@ -235,6 +271,8 @@ text = "2" [[step]] do = "say" line = "The lot is the fork line's polypropylene resin, LOT-PP-FORK1-001. Two kilos: about what five hundred forks weigh. Issue." +at = "#issue .big-io" +label = "Lot and kilos" [[step]] do = "click" @@ -247,6 +285,8 @@ js = "[...document.querySelectorAll('#issue-lot option')].some(o => o.value === [[step]] do = "say" line = "Issued. The lot is two kilos lighter, and the order now says which resin went into it." +at = "#issue-lot" +label = "Two kilos lighter" [[step]] do = "mark" @@ -263,6 +303,8 @@ scroll_offset = 300 [[step]] do = "say" line = "Fifth card, quality, on what this machine is running: forks, UT-FORK. Only characteristics with a specification are offered." +at = "#q-char" +label = "Characteristic" [[step]] do = "choose" @@ -272,6 +314,8 @@ value = "length_mm" [[step]] do = "say" line = "Length: the specification is 164 to 166 millimetres. The operator puts a fork on the gauge." +at = "#q-spec" +label = "Specification" [[step]] do = "fill" @@ -289,6 +333,8 @@ js = "(document.querySelector('#q-recent').innerText || '').includes('165.1') && [[step]] do = "say" line = "165.1 millimetres: in spec. It is in the recent results, with the time and who measured it." +at = "#q-recent li:has-text(\"165.1\")" +label = "In spec" [[step]] do = "mark" @@ -305,10 +351,14 @@ scroll_offset = 320 [[step]] do = "say" line = "Last card, maintenance on this machine. Here, nothing is owed: this plant has no maintenance plan set up." +at = "#maint" +label = "Nothing owed" [[step]] do = "say" line = "Where a plan is set up, the jobs due on this machine are listed here, and the operator can start and complete them." +at = "#maint" +label = "Jobs due" [[step]] do = "mark" @@ -316,11 +366,26 @@ name = "what-maintenance-is-owed" # -------------------------------------------------------------- it refuses +# The Orders page by its menu, and the next fork order found by typing its +# code into the page's own search box. [[step]] part = "refuses" -do = "goto" -url = "/dashboard/orders?q=WO-FORK1-0002" -settle = 2 +do = "click" +selector = "header nav a:text-is(\"Orders\")" + +[[step]] +do = "wait_for" +selector = "#order-list" +text = "WO-" + +[[step]] +do = "fill" +selector = "#f-text" +text = "WO-FORK1-0002" + +[[step]] +do = "wait_for" +js = "[...document.querySelectorAll('#order-list tbody tr')].length === 1 && document.querySelector('#order-list tbody').innerText.includes('WO-FORK1-0002')" [[step]] do = "click" @@ -336,19 +401,27 @@ scroll_offset = 220 [[step]] do = "say" line = "Now what it refuses. This is the next fork order, WO-FORK1-0002. Its first step is on the same mould, but it is only planned." +at = "#d-status" +label = "Only planned" +style = "spotlight" [[step]] do = "mark" name = "the-next-order-is-planned" +# Back the same way: the Floor menu, then its Station chip. The station +# remembers the machine last chosen on it, FORK1_Mold. [[step]] -do = "goto" -url = "/dashboard/station?m=FORK1_Mold" -settle = 3 +do = "click" +selector = "header nav a:text-is(\"Floor\")" + +[[step]] +do = "click" +selector = "nav.subnav a:text-is(\"Station\")" [[step]] do = "wait_for" -js = "[...document.querySelectorAll('#book-order option')].map(o => o.value).join() === 'WO-FORK1-0001'" +js = "document.querySelector('#machine').value === 'FORK1_Mold' && [...document.querySelectorAll('#book-order option')].map(o => o.value).join() === 'WO-FORK1-0001'" scroll_to = "#book" scroll_block = "start" scroll_offset = 300 @@ -356,10 +429,15 @@ scroll_offset = 300 [[step]] do = "say" line = "Back at the mould, the Against list holds one order: WO-FORK1-0001. The planned order is not there to book against." +at = "#book-order" +label = "One order" +style = "spotlight" [[step]] do = "say" line = "Nor is any order of another line. An operator can only book to work released to this machine." +at = "#book-order" +label = "Released work only" [[step]] do = "mark" @@ -374,6 +452,8 @@ js = "Number(((document.querySelector('#queue').innerText.match(/Mold\\D+([0-9,] [[step]] do = "say" line = "And what it does not refuse. Type five thousand good: more forks than this mould has made since the plant started." +at = "#book-good" +label = "Good" [[step]] do = "fill" @@ -392,6 +472,8 @@ text = "Booked 5,000 good, 0 scrap." [[step]] do = "say" line = "Booked. The station took the figure as typed. Nothing on the screen says the counter disagrees." +at = "#book" +label = "No warning" [[step]] do = "mark" @@ -408,6 +490,8 @@ scroll_offset = 300 [[step]] do = "say" line = "The queue now says the mould has made thousands more than its counter saw. A typed booking is added to the count; it is not checked against it." +at = "#queue li.running-op .what .muted" +label = "Thousands more" [[step]] do = "say" diff --git a/tests/fixtures/course/class-2-1-voiced-script.txt b/tests/fixtures/course/class-2-1-voiced-script.txt new file mode 100644 index 00000000..dfe868e4 --- /dev/null +++ b/tests/fixtures/course/class-2-1-voiced-script.txt @@ -0,0 +1,30 @@ +An operator stands at one press for a whole shift, a tablet in hand. Not the plant, not the line: this one machine. +Through the shift they ask the same few things. What is it doing, and what is next for it? +What did I make, what did I put in, is it good, and is anything owed to the machine? One screen answers all of them. +Four words. A station is one machine's screen, made for the person standing at it, not for the office. +The queue is the work released to this machine, in the order it should run. Only released work is in it. +To book is to write down how many good and how many scrap, always against an order and its step. +To issue is to write down which lot of material went into that order, so it can be traced later. +The station screen of the fork mould, FORK1_Mold. The machine is chosen at the top; the operator starts the shift here. +First card, its state: running, and since when. Going down asks why, which is the next class. +Second card, its queue: the order it is running, WO-FORK1-0001, step 10, Mold, and how many good of how many ordered. +That count moves by itself: the mould's own counter books every shot it makes. +Third card, book output. Against: the order at the head of the queue, step 10. The operator counts a box. +Five hundred good, three scrap. Book. +Booked, against WO-FORK1-0001 step 10, under the name of the person signed in. The queue's count is up by five hundred. +Fourth card, issue material. It issues to the order running here, WO-FORK1-0001. +The lot is the fork line's polypropylene resin, LOT-PP-FORK1-001. Two kilos: about what five hundred forks weigh. Issue. +Issued. The lot is two kilos lighter, and the order now says which resin went into it. +Fifth card, quality, on what this machine is running: forks, UT-FORK. Only characteristics with a specification are offered. +Length: the specification is 164 to 166 millimetres. The operator puts a fork on the gauge. +165.1 millimetres: in spec. It is in the recent results, with the time and who measured it. +Last card, maintenance on this machine. Here, nothing is owed: this plant has no maintenance plan set up. +Where a plan is set up, the jobs due on this machine are listed here, and the operator can start and complete them. +Now what it refuses. This is the next fork order, WO-FORK1-0002. Its first step is on the same mould, but it is only planned. +Back at the mould, the Against list holds one order: WO-FORK1-0001. The planned order is not there to book against. +Nor is any order of another line. An operator can only book to work released to this machine. +And what it does not refuse. Type five thousand good: more forks than this mould has made since the plant started. +Booked. The station took the figure as typed. Nothing on the screen says the counter disagrees. +The queue now says the mould has made thousands more than its counter saw. A typed booking is added to the count; it is not checked against it. +So a typed figure is the operator's word. The audit trail says who typed it, and the counter's own shots stay counted beside it. +That is the station screen: one machine, read top to bottom, and the work done at it written down. You now know how to do three things. diff --git a/tests/test_a_scene_keeps_what_it_points_at_and_presses_out_of_the_avatars_corner.py b/tests/test_a_scene_keeps_what_it_points_at_and_presses_out_of_the_avatars_corner.py new file mode 100644 index 00000000..cf695853 --- /dev/null +++ b/tests/test_a_scene_keeps_what_it_points_at_and_presses_out_of_the_avatars_corner.py @@ -0,0 +1,120 @@ +"""What a scene points at or presses is kept out of the avatar's corner, and a take that cannot keep it out fails. + +Studio draws its narrator over the bottom-right of every frame, 240 by 200 +pixels. Once the station screen is scrolled, its right-hand cards (the +queue, Issue material) sit in that corner, and a box drawn round them, or a +cursor pressing Issue, would be under the narrator. The recorder already +lifts a thing out from under the caption bar before it boxes or presses it; +it now lifts a thing that reaches into the avatar's columns above the +avatar's corner, and a box or a press that still lands there fails the take, +as a caption in the corner always has. This drives the runner's own stage in +Chromium against pages of that shape; no plant is needed. +""" + +from __future__ import annotations + +import importlib.util +from pathlib import Path + +import pytest + +pytestmark = [pytest.mark.slow, pytest.mark.browser] + +REPO = Path(__file__).resolve().parents[1] +RUNNER = REPO / "scripts" / "record-scene.py" + +VIEWPORT = {"width": 1280, "height": 720} +ORIGIN = "http://scene.test/" + +# Two cards side by side, as the station screen lays them out, the pair from +# y 520 to 560: across the avatar's corner's top edge, above the caption bar's lift. +CARDS = ( + "