模拟考 A · Support Ticket BoardMock exam A · Support Ticket Board
IT 支持工单看板。可以新建工单(标题 + 优先级)、关闭工单、改派(编辑)工单,还能按优先级筛选。业务场景换了,数据结构多了一个枚举字段和一个筛选状态,但底层要你会的东西和 Notes Manager 一模一样。An IT support ticket board. You can create a ticket (title plus priority), close one, reassign (edit) one, and filter by priority. The business setting is different and the data has one extra enum field and one filter state, but what you need to know underneath is the same as in Notes Manager.
与真实 Q1 完全相同的考点:受控输入、列表渲染与 key、useState 的三种不可变更新(增 / 删 / 就地替换)、useEffect 同步外部 prop、派生数据、状态提升、双模式按钮与 id 复用。额外增加一个「筛选」考点 —— 这是这类题最常见的变式方向。Exactly the same points as the real Q1: controlled inputs, list rendering and key, the three ways useState updates without changing the original (add, remove, replace in place), useEffect syncing an outside prop, derived data, lifting state up, and a two-mode button reusing an id. One point is added: filtering, which is the most common way this kind of task is varied.
- 填写标题、选择优先级,点 Create 后新工单出现在列表末尾Fill in a title, pick a priority, and after Create the new ticket appears at the end of the list
- 标题为空(含只有空格)时 Create 按钮必须 disabledWhile the title is empty (spaces only counts as empty) the Create button must be disabled
- 优先级下拉默认选中 mediumThe priority dropdown starts on medium
- 提交后清空表单(标题清空,优先级回到 medium)The form clears after submitting: the title empties and the priority goes back to medium
- 点某一行的 Close,该工单按 id 从列表移除Clicking Close on a row removes that ticket from the list by id
- 两条标题相同的工单,只移除被点的那一条With two tickets that share a title, only the one that was clicked is removed
- 点某一行的 Reassign:标题和优先级回填进表单,按钮文字变成 SaveClicking Reassign on a row puts its title and priority back into the form, and the button now reads Save
- 改完提交:该工单在原位置被更新,顺序不变Submitting the change updates that ticket in place; the order does not change
- 提交后退出改派模式:表单清空、按钮回到 CreateSubmitting leaves reassign mode: the form clears and the button goes back to Create
- 改派时必须复用原 idReassigning has to reuse the original id
- 顶部有一个筛选下拉(data-testid="filter-priority"),选项:all / low / medium / highThere is a filter dropdown at the top (data-testid="filter-priority") with the options all / low / medium / high
- 选中某个优先级后,列表只显示该优先级的工单Picking a priority shows only the tickets with that priority
- 筛选不能影响底层数据 —— 切回 all 应该恢复全部Filtering must not touch the underlying data — switching back to all brings everything back
- 筛选结果必须是派生数据,不许再开一个 state 存筛选后的数组The filtered result has to be derived data; do not add a second piece of state holding the filtered array
- 列表用 map 渲染,key 用 ticket.idThe list is rendered with map, using ticket.id as the key
- 所有 data-testid 与需求一致Every data-testid matches the requirements
- npx tsc --noEmit 无错误npx tsc --noEmit reports no errors
- 五个测试全过All five tests pass
这一页故意不给运行环境There is deliberately no runner on this page
不是做不到。是这一档的意义就在于什么都不给。Coding 题里那 11 道浏览器沙箱把文件、依赖、 测试全备好了 —— 你只要写函数体。真实考试不是这样:你会拿到一个空文件夹 或者一份跑不起来的脚手架,自己 npm install、自己读报错、 自己决定文件放哪。Not because we cannot. Because getting nothing is the point of this tier. The 11 browser sandboxes under Coding hand you files, deps and tests. A real assessment does not: you get an empty folder or a scaffold that does not build, and you install, read the errors and lay out the files yourself.
所以下面给足了三样东西:能直接抄的命令、完整的文件树、起始态和做对之后各该看到什么(都是实测数字)。搭不起来不该是这道题的难点。So below you get three things: commands you can paste, the full file tree, and what the tests actually print before and after (both measured). Getting set up should not be the hard part.
去哪跑:本机 + VS Code 最接近真实考试,要先装好 Node。 装不了 Node 就用 StackBlitz,选 Vite + React + TS 模板。代码会上传到 StackBlitz 的服务器上。Where: local VS Code is closest to the real thing; install Node first. No Node? Use StackBlitz with the Vite + React + TS template. Your code is uploaded to StackBlitz.
Tests: 5 failed, 5 total —— 第一条报 Unable to find an element by: [data-testid="ticket-subject"]Tests: 5 failed, 5 total — the first reports Unable to find an element by: [data-testid="ticket-subject"]看不到这个就是环境没搭对,先解决它再动手。If you do not see this, the setup is wrong. Fix that first.Test Files 1 passed (1) / Tests 5 passed (5)Test Files 1 passed (1) / Tests 5 passed (5)这个数字是参考解法在本机实测出来的,不是估的。Measured from the reference solution on a real machine.讲解里会直接说出每一处陷阱在哪。请确认你已经在本机把这套题做完、跑过测试、按 rubric 自评过,再打开。The walkthrough names every trap outright. Only open it once you have finished the paper locally, run the tests, and scored yourself against the rubric.