/**
 * 学校端 E2E 测试 - 完整业务流程
 */

import { test, expect } from '@playwright/test';
import { loginAsSchool, clickSubMenu, logout } from './helpers';
import { SCHOOL_CONFIG } from './fixtures';

test.describe('学校端完整业务流程测试', () => {
  test('学校端完整业务流程', async ({ page }) => {
    test.slow();

    // ========== 登录 ==========
    await loginAsSchool(page);
    await page.waitForTimeout(1000);

    // 截图：仪表盘
    await page.screenshot({ path: 'test-results/school-full-flow-01-dashboard.png' });

    // ========== 班级管理 ==========
    await clickSubMenu(page, '人员管理', '班级管理');
    await page.waitForURL('**/school/classes*', { timeout: 10000 });
    await page.waitForTimeout(1000);
    await page.screenshot({ path: 'test-results/school-full-flow-02-classes.png' });

    // ========== 学生管理 ==========
    await clickSubMenu(page, '人员管理', '学生管理');
    await page.waitForURL('**/school/students*', { timeout: 10000 });
    await page.waitForTimeout(1000);
    await page.screenshot({ path: 'test-results/school-full-flow-03-students.png' });

    // ========== 教师管理 ==========
    await clickSubMenu(page, '人员管理', '教师管理');
    await page.waitForURL('**/school/teachers*', { timeout: 10000 });
    await page.waitForTimeout(1000);
    await page.screenshot({ path: 'test-results/school-full-flow-04-teachers.png' });

    // ========== 家长管理 ==========
    await clickSubMenu(page, '人员管理', '家长管理');
    await page.waitForURL('**/school/parents*', { timeout: 10000 });
    await page.waitForTimeout(1000);
    await page.screenshot({ path: 'test-results/school-full-flow-05-parents.png' });

    // ========== 课程管理 ==========
    await clickSubMenu(page, '教学管理', '课程管理');
    await page.waitForURL('**/courses*', { timeout: 10000 });
    await page.waitForTimeout(1000);
    await page.screenshot({ path: 'test-results/school-full-flow-06-courses.png' });

    // ========== 校本课程包 ==========
    await clickSubMenu(page, '教学管理', '校本课程包');
    await page.waitForURL('**/school-courses*', { timeout: 10000 });
    await page.waitForTimeout(1000);
    await page.screenshot({ path: 'test-results/school-full-flow-07-school-courses.png' });

    // ========== 阅读任务 ==========
    await clickSubMenu(page, '教学管理', '阅读任务');
    await page.waitForURL('**/school/tasks*', { timeout: 10000 });
    await page.waitForTimeout(1000);
    await page.screenshot({ path: 'test-results/school-full-flow-08-tasks.png' });

    // ========== 成长档案 ==========
    await clickSubMenu(page, '数据中心', '成长档案');
    await page.waitForURL('**/school/growth*', { timeout: 10000 });
    await page.waitForTimeout(1000);
    await page.screenshot({ path: 'test-results/school-full-flow-09-growth.png' });

    // ========== 系统设置 ==========
    await clickSubMenu(page, '系统管理', '系统设置');
    await page.waitForURL('**/school/settings*', { timeout: 10000 });
    await page.waitForTimeout(1000);
    await page.screenshot({ path: 'test-results/school-full-flow-10-settings.png' });

    // ========== 退出登录 ==========
    await logout(page);
    await page.waitForTimeout(1000);
    await page.screenshot({ path: 'test-results/school-full-flow-11-login.png' });

    test.info().annotations.push({
      type: 'success',
      description: '学校端完整业务流程测试完成',
    });
  });
});
