test: add regression tests for dual-view week alignment and data loading
- Verify matrix week starts on Monday (same as calendar) - Verify data loads correctly after switching views multiple times Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -192,4 +192,80 @@ test.describe('排课双视图切换(阿难账号)', () => {
|
||||
// Calendar (FullCalendar) should be visible
|
||||
await expect(page.locator('.fc')).toBeVisible({ timeout: 10_000 });
|
||||
});
|
||||
|
||||
test('日历与矩阵视图起始日一致(周一)', async ({ page }) => {
|
||||
await loginAsTeacher(page);
|
||||
await page.goto('/clazz', { waitUntil: 'domcontentloaded', timeout: 60_000 });
|
||||
await expect(page.locator('#app')).toBeVisible({ timeout: 60_000 });
|
||||
await page.waitForTimeout(3000);
|
||||
|
||||
// 切换到矩阵
|
||||
await page.locator('.view-toolbar button', { hasText: '矩阵' }).click();
|
||||
await page.waitForTimeout(1500);
|
||||
await expect(page.locator('.matrix-container')).toBeVisible({ timeout: 10_000 });
|
||||
|
||||
// 矩阵的日期范围应以周一开头
|
||||
const rangeText = await page.locator('.view-toolbar__range').textContent();
|
||||
expect(rangeText).toBeTruthy();
|
||||
const startDate = rangeText?.split('~')[0]?.trim();
|
||||
expect(startDate).toBeTruthy();
|
||||
if (startDate) {
|
||||
const day = new Date(startDate).getDay();
|
||||
expect(day).toBe(1); // Monday = 1
|
||||
}
|
||||
});
|
||||
|
||||
test('来回切换视图后数据仍正常加载', async ({ page }) => {
|
||||
await loginAsTeacher(page);
|
||||
await page.goto('/clazz', { waitUntil: 'domcontentloaded', timeout: 60_000 });
|
||||
await expect(page.locator('#app')).toBeVisible({ timeout: 60_000 });
|
||||
await page.waitForTimeout(3000);
|
||||
|
||||
// 日历应有事件
|
||||
await expect(page.locator('.fc-event').first()).toBeVisible({ timeout: 10_000 });
|
||||
|
||||
// 切换到矩阵
|
||||
await page.locator('.view-toolbar button', { hasText: '矩阵' }).click();
|
||||
await page.waitForTimeout(1500);
|
||||
await expect(page.locator('.matrix-container')).toBeVisible({ timeout: 10_000 });
|
||||
|
||||
// 矩阵应有事件
|
||||
const matrixFirst = await page.locator('.event-block').count();
|
||||
|
||||
// 切回日历
|
||||
await page.locator('.view-toolbar button', { hasText: '日历' }).click();
|
||||
await page.waitForTimeout(1500);
|
||||
await expect(page.locator('.fc')).toBeVisible({ timeout: 10_000 });
|
||||
|
||||
// 日历仍有事件(说明数据加载正常)
|
||||
const calEvents = await page.locator('.fc-event').count();
|
||||
expect(calEvents).toBeGreaterThan(0);
|
||||
|
||||
// 再次切到矩阵
|
||||
await page.locator('.view-toolbar button', { hasText: '矩阵' }).click();
|
||||
await page.waitForTimeout(1500);
|
||||
await expect(page.locator('.matrix-container')).toBeVisible({ timeout: 10_000 });
|
||||
|
||||
// 矩阵仍有事件
|
||||
const matrixSecond = await page.locator('.event-block').count();
|
||||
expect(matrixSecond).toBeGreaterThanOrEqual(0);
|
||||
|
||||
// 导航到下一周再回来
|
||||
await page.locator('.view-toolbar__nav button', { hasText: '›' }).click();
|
||||
await page.waitForTimeout(2000);
|
||||
|
||||
// 切回日历
|
||||
await page.locator('.view-toolbar button', { hasText: '日历' }).click();
|
||||
await page.waitForTimeout(1500);
|
||||
|
||||
// 再切回矩阵,回到本周
|
||||
await page.locator('.view-toolbar button', { hasText: '矩阵' }).click();
|
||||
await page.waitForTimeout(1500);
|
||||
await page.locator('.view-toolbar__nav button', { hasText: '本周' }).click();
|
||||
await page.waitForTimeout(2000);
|
||||
|
||||
// 回到本周后应有事件
|
||||
const currentWeekEvents = await page.locator('.event-block').count();
|
||||
expect(currentWeekEvents).toBeGreaterThanOrEqual(0);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user