节点在线、应用在线、配置在线使用令牌查询
大石头 authored at 2021-12-16 19:49:30
2.50 KiB
Stardust
import { test, expect } from './fixtures';
import { gotoLeafPage, assertPageRendered, collectErrors } from './helpers';

/**
 * Configs/ConfigHistory/Index 迁移 e2e
 *
 * MVC 自定义逻辑:仅 _List_Search 自定义(类别 action / 状态 success / 日期范围),
 * 控制器为标准 ConfigsEntityController<ConfigHistory>(只读列表)。
 *
 * 验证结论:cube-vue AutoPage 可渲染标准表格,但不会自动暴露 _List_Search 中的
 * 「类别」「时间」字段(后端 GetPage 默认搜索字段只含 success),因此需要
 * 自定义视图还原这三个搜索字段。
 *
 * 种子数据为空时列表 0 行属正常,仅校验:渲染 + 搜索字段 + 无 >=400 错误。
 */
test('Configs/ConfigHistory 页面渲染(列表 + 自定义搜索字段)', async ({ page }) => {
  const errs = collectErrors(page);
  await gotoLeafPage(page, 'Configs/ConfigHistory');
  const rendered = await assertPageRendered(page);
  expect(rendered).toBe('list');

  // 列表与表格必须渲染
  await expect(page.locator('main.cosmic-content .list-page')).toBeVisible();
  await expect(page.locator('main.cosmic-content .el-table').first()).toBeVisible();

  // 自定义搜索区必须包含 _List_Search 关键字段:类别 / 状态 / 时间(日期范围)
  await expect(
    page.locator('main.cosmic-content').getByText('类别', { exact: true }).first(),
  ).toBeVisible();
  await expect(
    page.locator('main.cosmic-content').getByText('状态', { exact: true }).first(),
  ).toBeVisible();
  await expect(
    page.locator('main.cosmic-content').getByText('æ—¶é—´', { exact: true }).first(),
  ).toBeVisible();

  const captured = await errs;
  if (captured.errors.length) {
    console.log('NET_ERR=' + JSON.stringify(captured.errors));
    throw new Error('存在接口/资源 >=400 错误: ' + JSON.stringify(captured.errors));
  }

  // 截图 1:列表态(含搜索区)
  await page.screenshot({
    path: 'e2e/screenshots/Configs/ConfigHistory/list.png',
    fullPage: true,
  });

  // 截图 2:触发一次搜索后态(空种子可能无结果,截空态即可)
  try {
    await page
      .locator('main.cosmic-content')
      .getByRole('button', { name: '搜索' })
      .first()
      .click({ timeout: 3000 });
    await page.waitForTimeout(800);
  } catch (e) {
    console.log('SEARCH_CLICK_SKIPPED=' + String(e));
  }
  await page.screenshot({
    path: 'e2e/screenshots/Configs/ConfigHistory/after-search.png',
    fullPage: true,
  });

  expect(true).toBe(true);
});