|
| 1 | +import { test, expect } from './support/fixtures'; |
| 2 | + |
| 3 | +test('[E2E-F11] 多选错题批量移动到其他错题本,标签保持不变', async ({ page, scenario }) => { |
| 4 | + test.setTimeout(60000); |
| 5 | + const target = await scenario.db.subject.create({ |
| 6 | + data: { name: 'E2E 目标本', stage: 'junior_high', subjectKey: 'math', userId: scenario.user.id }, |
| 7 | + }); |
| 8 | + const item = await scenario.item('M'); |
| 9 | + await scenario.db.errorItem.update({ where: { id: item.id }, data: { tags: { connect: [{ id: 'e2e-leaf-default' }] } } }); |
| 10 | + |
| 11 | + await scenario.guardPage(page); |
| 12 | + await scenario.login(page); |
| 13 | + await page.goto(`/notebooks/${scenario.book.id}`); |
| 14 | + await expect(page.getByText(item.questionText!, { exact: false })).toBeVisible({ timeout: 15000 }); |
| 15 | + |
| 16 | + await page.getByRole('button', { name: '多选', exact: true }).click(); |
| 17 | + const card = page.locator('a', { hasText: item.questionText! }).locator('..'); |
| 18 | + await card.getByRole('checkbox').click(); |
| 19 | + await page.getByRole('button', { name: '移动到错题本', exact: true }).click(); |
| 20 | + |
| 21 | + const dialog = page.getByRole('dialog').filter({ has: page.getByRole('heading', { name: '移动选中的错题' }) }); |
| 22 | + await expect(dialog).toBeVisible(); |
| 23 | + await dialog.locator('button[role="combobox"]').click(); |
| 24 | + await page.getByRole('option', { name: 'E2E 目标本', exact: true }).click(); |
| 25 | + |
| 26 | + const moved = page.waitForResponse((response) => response.url().includes('/api/error-items/batch-move') && response.request().method() === 'POST'); |
| 27 | + await dialog.getByRole('button', { name: '移动', exact: true }).click(); |
| 28 | + expect((await moved).ok()).toBeTruthy(); |
| 29 | + |
| 30 | + await expect.poll(async () => (await scenario.db.errorItem.findUnique({ where: { id: item.id } }))?.subjectId).toBe(target.id); |
| 31 | + const movedItem = await scenario.db.errorItem.findUnique({ where: { id: item.id }, include: { tags: true } }); |
| 32 | + expect(movedItem?.tags.map((tag) => tag.id)).toContain('e2e-leaf-default'); |
| 33 | + await expect(page.getByText(item.questionText!, { exact: false })).not.toBeVisible({ timeout: 15000 }); |
| 34 | +}); |
0 commit comments