gz-laya-pilot 0.1.1 → 0.1.2

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.
@@ -68,6 +68,26 @@ def step_text(step):
68
68
  kind = step['kind']
69
69
  target = step.get('target', {}).get('name', '')
70
70
  value = step.get('value', '')
71
+ if kind in ('assert-persisted-row', 'assert-persisted-absent'):
72
+ state = '存在唯一记录' if kind == 'assert-persisted-row' else '记录不存在'
73
+ return f'在独立后台浏览器会话重新打开相同模块,查询并核对{state}:{value}(不刷新当前主子应用)'
74
+ if kind == 'expand-tree':
75
+ node = step['target']
76
+ return f'在「{node["tree"]}」树中展开「{" → ".join(node["path"])}」,核对节点已展开'
77
+ if kind == 'open-owned-record':
78
+ return f'点击本轮独立记录「{value}」的名称入口,原地打开详情'
79
+ if kind == 'assert-record-detail':
80
+ return f'核对列表之外的详情标题或定义内容包含本轮记录「{value}」,不能用列表同名文本代替'
81
+ if kind == 'assert-query-result':
82
+ return f'核对唯一关键词查询只返回本轮记录「{value}」,不能只检查输入框文字'
83
+ if kind == 'assert-tab-panel':
84
+ return f'核对「{target}」页签选中且 aria-controls 关联的内容面板已显示'
85
+ if kind == 'assert-disclosure':
86
+ return f'在「{step["target"]["tab"]}」面板内展开「{target}」,核对新控件出现,再收起并核对状态恢复'
87
+ if kind == 'assert-related-records':
88
+ return (f'在本轮父记录的「{step["target"]["tab"]}」面板点击「{step["target"]["add"]}」;'
89
+ f'选择唯一数据「{step["item"]}」并确认;断言关联列表显示该记录,在独立会话重新打开并核对;'
90
+ f'选中该关联记录,点击「{step["target"]["remove"]}」;断言列表恢复为空,并再次独立校验。')
71
91
  if kind == 'assert-discovery':
72
92
  spec = step['spec']
73
93
  check = spec['check']
@@ -81,7 +101,7 @@ def step_text(step):
81
101
  if check == 'filter-reset':
82
102
  return f'先查询不存在的关键词并核对列表为空,再点击「{spec["reset"]["name"]}」,核对条件清空且原列表记录恢复'
83
103
  if check == 'cancel-create':
84
- return f'点击「{spec["create"]["name"]}」,填写「{spec["label"]}」,点击「{spec["cancel"]["name"]}」,核对弹窗关闭且刷新后没有新增记录'
104
+ return f'展开当前列表中的分类,点击「{spec["create"]["name"]}」,填写「{spec["label"]}」,点击「{spec["cancel"]["name"]}」,核对编辑区关闭且当前页面、独立会话均无新增记录,最后原地恢复筛选条件'
85
105
  if check == 'field-invalid':
86
106
  return f'打开新增表单,向「{spec["label"]}」输入违反 {spec["constraint"]}={spec.get("bound", "邮箱格式")} 的值,核对浏览器约束校验失败,再取消(不提交)'
87
107
  raise ValueError('不支持的补充测试:' + check)
@@ -184,13 +204,23 @@ def write(payload):
184
204
  'generatedAt': file['generatedAt'],
185
205
  'moduleUrl': file['moduleUrl'],
186
206
  'coverage': file['coverage'],
207
+ 'exploration': file.get('exploration'),
187
208
  },
188
209
  ensure_ascii=False,
189
210
  )
190
211
  meta.append(['id', 'visible_sha256', 'case_json'])
191
212
  module = Path(file['moduleUrl'].split('?')[0].rstrip('/')).name or '目标页面'
213
+ if file.get('exploration'):
214
+ scope = book.create_sheet('探索范围')
215
+ scope.append(['已观察状态', '入口', '未验证原因'])
216
+ scope.append(['说明', '用例通过不代表页面功能全覆盖', '以下入口未计入通过用例'])
217
+ for gap in file['exploration'].get('gaps', []):
218
+ scope.append([clean(gap.get('state')), clean(gap.get('name')), clean(gap.get('reason'))])
219
+ scope.freeze_panes = 'A2'
220
+ for letter, width in [('A', 32), ('B', 35), ('C', 65)]:
221
+ scope.column_dimensions[letter].width = width
192
222
  for index, case in enumerate(file['cases'], 2):
193
- uses_owned_record = case['operation'] in ('create', 'search', 'view', 'edit', 'delete')
223
+ uses_owned_record = case['operation'] in ('create', 'search', 'view', 'related-records', 'edit', 'delete')
194
224
  precondition = (
195
225
  '已登录并进入目标模块;使用本轮唯一命名的独立测试记录'
196
226
  if uses_owned_record
@@ -277,6 +307,7 @@ def read(payload):
277
307
  'moduleUrl': header['moduleUrl'],
278
308
  'cases': cases,
279
309
  'coverage': header.get('coverage', []),
310
+ 'exploration': header.get('exploration'),
280
311
  }
281
312
 
282
313
 
@@ -152,6 +152,8 @@ test('write verification requires matching page, successful request and expected
152
152
  const { workflow, page } = setup();
153
153
  workflow.attemptState = { writeSequence: 0 };
154
154
  workflow.snapshot = async () => ({ controls: [{ name: '新增' }] });
155
+ workflow.editorPresent = async () => false;
156
+ workflow.ownedRows = () => ({ count: async () => 1 });
155
157
  page.getByText = () => ({});
156
158
  page.locator = () => ({ filter: () => ({ count: async () => 1 }) });
157
159
  const step = { purpose: 'save' };
@@ -212,12 +214,23 @@ test('creation entry probing stops at three and observes fresh controls each tim
212
214
  count: async () => 1,
213
215
  isVisible: async () => true,
214
216
  click: async () => clicked.push(ref),
217
+ evaluate: async () => false, // These toolbar entries do not belong to a tree.
215
218
  }),
216
219
  },
217
220
  ],
218
221
  };
219
222
  };
220
- workflow.waitForModal = async () => {};
223
+ workflow.editorPresent = async () => false;
224
+ workflow.waitForEditor = async () => {
225
+ throw Error('No editor opened');
226
+ };
227
+ workflow.chooseFromSnapshot = async (snap, candidates) => {
228
+ const control = candidates[0];
229
+ return {
230
+ control,
231
+ locator: snap.frames[control.frame].locator(`[data-laya-live-ref="${control.ref}"]`),
232
+ };
233
+ };
221
234
  await assert.rejects(workflow.clickCreate(), /尝试3次/);
222
235
  assert.equal(observed, 3);
223
236
  assert.equal(clicked.length, 3);
@@ -24,7 +24,14 @@ test('sibling labels name input fields without renaming save/cancel buttons', as
24
24
  closest: () => null,
25
25
  querySelector: () => null,
26
26
  matches: () => false,
27
- getBoundingClientRect: () => ({ width: 100, height: 30 }),
27
+ getBoundingClientRect: () => ({
28
+ width: 100,
29
+ height: 30,
30
+ left: 0,
31
+ right: 100,
32
+ top: 0,
33
+ bottom: 30,
34
+ }),
28
35
  classList: { contains: () => false },
29
36
  });
30
37
  const label = node('LABEL', '名称'),
@@ -75,6 +82,7 @@ test('create retries use fresh refs and reach the second live entry', async () =
75
82
  locator: (selector) => ({
76
83
  count: async () => (selector.includes('"' + generation + '-') ? 1 : 0),
77
84
  isVisible: async () => true,
85
+ evaluate: async () => false, // Entries in this fixture are outside a tree.
78
86
  }),
79
87
  },
80
88
  ],
@@ -82,8 +90,18 @@ test('create retries use fresh refs and reach the second live entry', async () =
82
90
  },
83
91
  safeClick: async (_, name) => clicked.push(name),
84
92
  record: () => {},
85
- waitForModal: async () => {},
86
- modalPresent: async () => clicked.includes('新增乙'),
93
+ waitForEditor: async () => {
94
+ if (!clicked.includes('新增乙')) throw Error('No editor opened');
95
+ },
96
+ editorPresent: async () => clicked.includes('新增乙'),
97
+ chooseFromSnapshot: async (snap, candidates) => {
98
+ const control = candidates[0];
99
+ const locator = snap.frames[control.frame].locator(
100
+ `[data-laya-live-ref="${control.ref}"]`,
101
+ );
102
+ assert.equal(await locator.count(), 1, 'must select the current observed reference');
103
+ return { control, locator };
104
+ },
87
105
  dismissModal: async () => {},
88
106
  };
89
107
  await Workflow.prototype.withAttempts.call(fake, 'clickCreate', () =>