test: add E2E for logged-in student viewing course package store on teacher home
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { expect, test } from './fixtures';
|
||||
|
||||
const testOrgId = '57753e11dff343b1ab95623933e8960b';
|
||||
const moicenUnionid = process.env.MOICEN_E2E_UNIONID?.trim();
|
||||
|
||||
test.describe('课包商店', () => {
|
||||
|
||||
@@ -179,3 +180,76 @@ test.describe('课包商店', () => {
|
||||
await expect(retryBtn).toBeVisible({ timeout: 15_000 });
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('课包商店(已登录学生查看老师主页)', () => {
|
||||
|
||||
test('学生登录后 /teacher/home 显示课包商店', async ({ page }) => {
|
||||
test.setTimeout(180_000);
|
||||
|
||||
if (!moicenUnionid) {
|
||||
test.skip(true, 'MOICEN_E2E_UNIONID 未设置');
|
||||
return;
|
||||
}
|
||||
|
||||
// Login as student (status=2)
|
||||
const q = new URLSearchParams({ unionid: moicenUnionid, status: '2' });
|
||||
await page.goto(`/?${q.toString()}`, { waitUntil: 'domcontentloaded', timeout: 60_000 });
|
||||
await expect(page.locator('#app')).toBeVisible({ timeout: 60_000 });
|
||||
await page.waitForTimeout(5000);
|
||||
|
||||
// Select student role if prompted
|
||||
const roleSelect = page.getByText('请选择您的登录身份');
|
||||
if (await roleSelect.isVisible().catch(() => false)) {
|
||||
const studentRole = page.locator('.van-grid-item').filter({ hasText: '学生' });
|
||||
if (await studentRole.isVisible().catch(() => false)) {
|
||||
await studentRole.click();
|
||||
await page.waitForTimeout(5000);
|
||||
}
|
||||
}
|
||||
|
||||
// Handle org select if needed
|
||||
if (page.url().includes('/org/select')) {
|
||||
if (await page.getByText('请返回微信小程序完成登录').isVisible().catch(() => false)) {
|
||||
test.skip(true, '会话不可用');
|
||||
return;
|
||||
}
|
||||
const orgCell = page.locator('#app .van-cell-group .van-cell').first();
|
||||
if (await orgCell.isVisible().catch(() => false)) {
|
||||
await orgCell.click();
|
||||
await page.waitForTimeout(5000);
|
||||
}
|
||||
}
|
||||
|
||||
// Navigate to teacher home
|
||||
await page.goto('/teacher/home', { waitUntil: 'domcontentloaded', timeout: 60_000 });
|
||||
await expect(page.locator('#app')).toBeVisible({ timeout: 60_000 });
|
||||
await page.waitForTimeout(5000);
|
||||
|
||||
// Should NOT see the login prompt
|
||||
await expect(page.getByText('请返回微信小程序完成登录')).not.toBeVisible();
|
||||
|
||||
// Should see the course package section
|
||||
const section = page.locator('.course-package-section');
|
||||
await expect(section).toBeVisible({ timeout: 15_000 });
|
||||
await expect(section.locator('.section-header')).toContainText('课包商店');
|
||||
|
||||
// Should see at least one package card
|
||||
const cards = page.locator('.course-package-store .package-card');
|
||||
await expect(cards.first()).toBeVisible({ timeout: 15_000 });
|
||||
const cardCount = await cards.count();
|
||||
expect(cardCount).toBeGreaterThan(0);
|
||||
|
||||
// Each card should have package name and lesson count (no pricing)
|
||||
for (let i = 0; i < cardCount; i++) {
|
||||
const card = cards.nth(i);
|
||||
const text = await card.innerText();
|
||||
expect(text.length).toBeGreaterThan(0);
|
||||
expect(text).not.toContain('¥');
|
||||
expect(text).not.toContain('售价');
|
||||
}
|
||||
|
||||
// Should have a preview button on each card
|
||||
const previewBtns = page.locator('.course-package-store .preview-btn');
|
||||
expect(await previewBtns.count()).toBe(cardCount);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user