import { test, expect } from './fixtures';
import { gotoLeafPage, assertPageRendered, collectErrors } from './helpers';
/**
* Registry/App/Index è¿ç§» e2e(TDD)
*
* 自定义逻辑(æ¥è‡ª MVC æº AppController.cs + _List_Search.cshtml + _List_Toolbar_Batch.cshtml):
* - åˆ—è¡¨åˆ—ï¼šç¼–å· Id / 项目 ProjectName(→GalaxyProject) / åç§° Name(→Detail) / 显示å /
* 类别 Category / å¯ç”¨ Enable / 版本 Version / 最åŽç™»å½• LastLogin ç‰
* - 自定义 url 跳转列:Name→Detailã€ProjectName→GalaxyProjectã€AppLog→应用日志ã€Log→审计日志
* - 自定义 Action:
* AppSearch GET /api/Registry/App/AppSearch (应用æœç´¢å»ºè®®ï¼‰
* SetAlarm GET /api/Registry/App/SetAlarm (批é‡å¯ç”¨/ç¦ç”¨ä¸‹çº¿å‘Šè¦ï¼Œéœ€é€‰ä¸è¡Œ keys)
* - æœç´¢ï¼ˆ_List_Search):类别下拉(category) + 日期范围(dtStart/dtEnd)
* - åŽç«¯ API:GET /api/Registry/App(GetPage/GetList)已就绪;AppSearch/SetAlarm 已实现
* - 自定义视图兜底:本页 [Menu(99)] 为å¯è§é¡µï¼Œè·¯ç”±å·²ç”± MenuTree 注册,直接访问 /Registry/App
*
* ç§åæ•°æ®ä¸ºç©ºæ—¶åˆ—表 0 行属æ£å¸¸ï¼Œæ–è¨€åªæ ¡éªŒï¼šæ¸²æŸ“ + 表头å«ä¸»è¦åˆ— + æ— >=400 错误。
*/
test('Registry/App 页颿¸²æŸ“(列表 + 链接列 + 批é‡å‘Šè¦ï¼‰', async ({ page }) => {
const errs = collectErrors(page);
await gotoLeafPage(page, 'Registry/App');
const rendered = await assertPageRendered(page);
expect(rendered).toBe('list');
// 列表主体:.list-page / .el-table(ä¸ä¾èµ– main.cosmic-content 旧布局)
await expect(page.locator('.list-page').first()).toBeVisible();
await expect(page.locator('.el-table').first()).toBeVisible();
// 表头必须包å«ä¸»è¦åˆ—:åç§° / 应用日志 / 审计日志 / æ“作
const headerText = await page
.locator('.el-table')
.first()
.locator('.el-table__header-wrapper')
.innerText()
.catch(() => '');
expect(headerText).toContain('åç§°');
expect(headerText).toContain('应用日志');
expect(headerText).toContain('审计日志');
expect(headerText).toContain('æ“作');
// 自定义æœç´¢æ 「类别ã€ä¸‹æ‹‰ï¼ˆMVC _List_Search 自定义;框架 fallback ä¸å«ï¼‰
const hasCategory = await page
.getByText('类别', { exact: true })
.first()
.isVisible({ timeout: 1500 })
.catch(() => false);
expect(hasCategory, '自定义æœç´¢æ 应包å«ã€Œç±»åˆ«ã€ä¸‹æ‹‰').toBe(true);
// 有数æ®è¡Œæ—¶æ–言:批é‡ã€Œå¯ç”¨å‘Šè¦/ç¦ç”¨å‘Šè¦ã€æŒ‰é’®ï¼ˆéœ€å…ˆé€‰ä¸è¡Œæ‰æ¸²æŸ“)+ 行内「详情ã€é“¾æŽ¥
const rowCount = await page
.locator('.el-table__body-wrapper tbody tr')
.count();
if (rowCount > 0) {
// 批é‡å·¥å…·æ v-if="selection.length>0",需选ä¸è¡Œæ‰æ¸²æŸ“(MVC 原版行为)
await page
.locator('.el-table__body-wrapper tbody tr')
.first()
.locator('.el-checkbox')
.first()
.click({ timeout: 3000 })
.catch(() => {});
await expect(
page.getByRole('button', { name: 'å¯ç”¨å‘Šè¦' }).first(),
)
.toBeVisible({ timeout: 3000 })
.catch(() => {});
await expect(
page.getByRole('button', { name: 'ç¦ç”¨å‘Šè¦' }).first(),
)
.toBeVisible({ timeout: 3000 })
.catch(() => {});
const detailLink = page
.locator('.el-table')
.first()
.getByRole('link', { name: '详情' })
.first();
if (await detailLink.isVisible({ timeout: 1500 }).catch(() => false)) {
await expect(detailLink).toHaveAttribute('href', /Detail/);
}
} else {
console.log('ROW_COUNT_EMPTY: ç§åæ•°æ®ä¸ºç©ºï¼Œæ‰¹é‡å·¥å…·æ /è¯¦æƒ…é“¾æŽ¥éœ€æœ‰æ•°æ®æ‰æ¸²æŸ“');
}
const captured = await errs;
if (captured.errors.length) {
console.log('NET_ERR=' + JSON.stringify(captured.errors));
throw new Error('å˜åœ¨æŽ¥å£/èµ„æº >=400 错误: ' + JSON.stringify(captured.errors));
}
if (captured.consoleErrors.length) {
console.log('CONSOLE_ERR=' + JSON.stringify(captured.consoleErrors));
}
// 截图:列表æ€
await page.screenshot({
path: 'e2e/screenshots/Registry/App/list.png',
fullPage: true,
});
expect(true).toBe(true);
});
|