[Feature] Testing Scenarios

发布时间:2026/9/18 17:23:25
[Feature] Testing Scenarios [Feature] Testing Scenarios【免费下载链接】actorsRivet Actors are the primitive for stateful workloads. Built for AI agents, collaborative apps, and durable execution.项目地址: https://gitcode.com/GitHub_Trending/riv/actorsQuick ReferenceLinks to reference documentsTesting EnvironmentURLs, endpoints, prerequisitesCritical User FlowsFlow N: [Flow Name]Scenario: Brief descriptionPrerequisites(if needed): What must be true before testingVerify:Point 1Point 2ORTest Cases:TCN.N: [Test Case Name]Given: Initial conditionsWhen: User actionThen: Expected outcome (high-level)以 [frontend/docs/testing/INSPECTOR.md](https://link.gitcode.com/i/78d2cccf5db5a99e1fd1a35407c7a8ab) 的实际落地为例其 Quick Reference 一节即指向四份引用文档 - [Connection States Reference](https://link.gitcode.com/i/b4d2b692776bbbd2dcec5bcfa5bd3f9b) - [Error States Reference](https://link.gitcode.com/i/9c6dfa9e8e7fc07032949ed729e9a66f) - [Actor States Reference](https://link.gitcode.com/i/9ade8dab2e67ee125b50644df2091918) - [UI Components Reference](https://link.gitcode.com/i/0bae698385cd68dd6ba04a6f0b9a2349) Testing Environment 则明确开发地址 http://localhost:5173、生产地址 https://inspect.rivet.dev、默认 RivetKit 端点 http://localhost:6420。 ### 2.2 引用文档模板 共享概念如 Actor 状态机、连接状态、错误类型沉淀为引用文档 markdown # [Topic] Reference ## [Category] ### [Item Name] **When**: Condition when this applies **User is informed about**: - Information point 1 - Information point 2 **Available actions**: - Action 1 - Action 2 **Displays** (optional): - UI element 1 - UI element 2仓库references/目录下现有六份引用文档正好构成一套完整的领域状态参考actor-states.md、connection-states.md、error-states.md、integration-form.md、onboarding-states.md、ui-components.md。三、写作风格用动词时态与语义精确性提升可测性规范对语言有四项硬性要求使用现在时写 User is informed不写 User will be informed。保持简洁避免不必要的词。精确表达意图写 User is informed about connection failure不写 Show error。避免实现细节写 Rivet Actor can be destroyed不写 Click destroy button and confirm in dialog。3.1 三种语义化验证点文档进一步把验证陈述收敛为三个固定短语使手工测试与自动化用例能一一对应短语适用场景示例Verify功能验证点列式检查Feature works as expectedUser is informed about错误/信息状态What went wrong、How to fix itAvailable actions用户可执行的操作Retry connection、Modify settings3.2 Scenario 与 Test Case 的选择Scenario用于高层用户流程、集成测试、多步骤过程Test Case用于特定条件、边界情况、单个功能验证。3.3 正反对照规范中的典型示例测试状态变化 ✅ 好Rivet Actor state updates when changed; Events appear in real-time ❌ 差When actor state changes from {old} to {new}, the UI updates within 100ms showing the new state in JSON format测试错误处理 ✅ 好When connection fails → User is informed about connection failure possible reasons → Available actions: Retry connection ❌ 差Show red error banner with text Connection failed: ERR_CONNECTION_REFUSED... and a Retry button in blue测试用户操作 ✅ 好Rivet Actor can be created; Rivet Actor appears in list after creation ❌ 差逐步点击 按钮、填写表单字段、等待 toast 的 5 步脚本规范还给出了完整的 Good/Bad 场景对照好场景描述用户访问 inspector URL 而无 RivetKit 服务器时显示入门卡片、连接表单默认端点、可输入自定义端点、提供 Connect 按钮坏场景则陷入白底、蓝色按钮、hover 变深蓝等样式细节——这些正是最易随 UI 改版而过期的信息。四、命名约定让测试 ID 自解释类别格式示例测试用例 IDTC[Flow].[Case]TC1.1、TC5.14集成测试 IDI[Number]I1、I4边界用例 IDE[Number]E1、E3引用文档名小写连字符connection-states.md、actor-states.md、error-states.md、ui-components.md这些 ID 约定在 frontend/docs/testing/INSPECTOR.md 中得到完整应用Flow 1 下包含TC1.1服务器不可用、TC1.2非 RivetKit 服务器、TC1.3本地网络访问未授权、TC1.4连接成功四个用例集成测试区则有I1完整连接流程、I2Actor 生命周期、I3实时更新、I4多 Actor 管理边界区包括E1网络中断、E2RivetKit 重启、E3浏览器刷新、E4非法端点格式、E5CORS 错误。五、E2E 实现从规范到 Playwright 代码规范第四章给出了 E2E 自动化实现的具体指引这也是从文档规范走向可执行测试的关键桥梁。5.1 元素选择策略data-testid 优先优先使用 test ID通过data-testid属性做稳定元素选择避免依赖 UI 文案。✅page.getByTestId(onboarding-path-agent)❌page.getByText(Use Coding Agent)按需为组件补充 test ID缺失时手动添加使用描述性 kebab-case 命名如data-testidonboarding-path-agent。回退层级无 test ID 时getByRole()——面向可访问元素按钮、链接、标题getByLabel()——表单输入getByPlaceholder()——带占位符的输入getByText()——最后手段避免精确匹配5.2 Test ID 命名约定与源码印证命名格式为{feature}-{element}-{variant?}规范示例onboarding-path-agent——onboarding 中的 Agent 路径选项onboarding-path-template——模板路径选项onboarding-back-button——返回按钮template-card-chat-room——聊天室模板卡片该约定在真实组件中已落地。以 frontend/src/components/onboarding/path-selection.tsx 为例组件通过集中的TEST_IDS.Onboarding.PathSelection、PathSelectionAgent、PathSelectionManual常量注入data-testid与规范中描述性、kebab-case、按 feature 分层的要求一一对应保证测试选择器与 UI 文案解耦。5.3 为组件添加 Test ID// In the component Button>await expect(page).toHaveScreenshot(onboarding-path-selection.png);组件级截图针对特定元素const card page.getByTestId(onboarding-path-agent); await expect(card).toHaveScreenshot(agent-card.png);截图时机页面加载后验证初始状态、改变 UI 的用户操作之后、错误态与加载态、表单校验反馈。命名约定{feature}-{state}.png如onboarding-path-selection.png、onboarding-provider-step.png、onboarding-error-invalid-endpoint.png。基线更新对刻意的 UI 改动使用更新快照命令重生成基线pnpm test:e2e --update-snapshots【免费下载链接】actorsRivet Actors are the primitive for stateful workloads. Built for AI agents, collaborative apps, and durable execution.项目地址: https://gitcode.com/GitHub_Trending/riv/actors创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

关于本文作者

来自尧图内容编辑团队

尧图内容编辑团队 内容团队

尧图内容编辑团队

本文由尧图网络内容编辑团队执笔。团队由资深项目经理、前端工程师与设计师组成,所有内容均来自亲手交付的真实项目,先讲清问题、再给出可落地的解法。尧图深耕北京网站建设十年,服务过京华建材集团、智造科技等各行业客户,把一线经验沉淀为可复用的行业观察。

  • 十年建站经验,覆盖建材、制造、服务、文创等
  • 项目经理把关选题与事实准确性
  • 工程师与设计师联合撰写专业细节
  • 统一编辑规范,保证文风与排版一致
  • 每月复盘转化数据,迭代选题方向

延伸阅读

相关资讯与近期热门内容

深度阅读推荐

建站决策前值得细读的三篇

网站改版的5个关键决策
2024-08-12

网站改版的5个关键决策

什么时候该改版、改到什么程度、如何避免流量掉光,京华建材集团改版复盘给出答案。

获取专属建站方案

看完文章,把您的行业与预算告诉我们,免费获取一份量身定制的官网建设方案与报价。

立即免费咨询