| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- import { test, expect } from '../../utils/test-setup';
- import { readFileSync } from 'fs';
- import { join, dirname } from 'path';
- import { fileURLToPath } from 'url';
- const __filename = fileURLToPath(import.meta.url);
- const __dirname = dirname(__filename);
- const testUsers = JSON.parse(readFileSync(join(__dirname, '../../fixtures/test-users.json'), 'utf-8'));
- test.describe.serial('银行名称删除功能验证', () => {
- test.beforeEach(async ({ adminLoginPage }) => {
- await adminLoginPage.goto();
- await adminLoginPage.login(testUsers.admin.username, testUsers.admin.password);
- await adminLoginPage.expectLoginSuccess();
- });
- test('调试银行名称页面加载问题', async ({ page }) => {
- // 监听 API 响应
- page.on('response', async (response) => {
- const url = response.url();
- if (url.includes('/api/v1/bank-names')) {
- const status = response.status();
- console.log(' [API] ' + status + ' ' + url);
-
- if (status === 200) {
- try {
- const body = await response.text();
- console.log(' [API Body] ' + body.substring(0, 200));
- } catch (e) {
- console.log(' [API] 无法读取响应体');
- }
- }
- }
- });
-
- // 监听控制台
- page.on('console', (msg) => {
- if (msg.type() === 'error' || msg.type() === 'warn') {
- console.log(' [Console ' + msg.type() + '] ' + msg.text());
- }
- });
-
- console.log('1. 导航到银行名称管理页面...');
- await page.goto('http://localhost:8080/admin/bank-names');
- await page.waitForLoadState('domcontentloaded');
-
- // 等待更长时间
- console.log(' 等待页面完全加载...');
- await page.waitForTimeout(5000);
-
- // 截图
- await page.screenshot({ path: 'test-results/bank-debug-1-initial.png' });
-
- // 检查页面元素
- console.log('2. 检查页面状态...');
-
- const searchVisible = await page.getByTestId('search-input').isVisible().catch(() => false);
- console.log(' 搜索框可见: ' + searchVisible);
-
- // 检查 tbody
- const tbody = page.locator('tbody');
- const tbodyExists = await tbody.count();
- console.log(' tbody 数量: ' + tbodyExists);
-
- if (tbodyExists > 0) {
- const tbodyText = await tbody.first().textContent();
- console.log(' tbody 内容: "' + (tbodyText || 'empty') + '"');
-
- // 检查 tr
- const trCount = await page.locator('tbody tr').count();
- console.log(' tbody tr 数量: ' + trCount);
- }
-
- // 检查是否有加载状态
- const loadingElements = await page.locator('[aria-busy="true"], .loading, .spinner').all();
- console.log(' 加载指示器数量: ' + loadingElements.length);
-
- // 检查是否有空状态提示
- const emptyState = await page.locator('text=暂无').isVisible().catch(() => false);
- console.log(' 显示"暂无"提示: ' + emptyState);
-
- // 在控制台中执行 JavaScript 检查状态
- const pageState = await page.evaluate(() => {
- return {
- url: window.location.href,
- readyState: document.readyState,
- bodyText: document.body?.textContent?.substring(0, 200)
- };
- });
- console.log(' 页面状态: ' + JSON.stringify(pageState).substring(0, 200));
- });
- });
|