| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- const { test, expect } = require('@playwright/test');
- const BASE_URL = 'https://ajy.danclub.cn';
- const TEST_ADMIN = { username: 'admin', password: 'admin123' };
- test.describe('操作日志测试', () => {
- test.beforeEach(async ({ page }) => {
- await page.goto(BASE_URL);
- await page.waitForLoadState('networkidle');
- await page.getByPlaceholder('请输入用户名').fill(TEST_ADMIN.username);
- await page.getByPlaceholder('请输入密码').fill(TEST_ADMIN.password);
- await page.getByRole('button', { name: '登 录' }).click();
- await page.waitForURL(`${BASE_URL}/#/user/app`, { timeout: 10000 });
- });
- test('OL-001: 查看操作日志列表', async ({ page }) => {
- await page.goto(`${BASE_URL}/#/system/log`);
- await page.waitForLoadState('networkidle');
- await page.waitForTimeout(1000);
- });
- test('OL-002: 按操作人筛选', async ({ page }) => {
- await page.goto(`${BASE_URL}/#/system/log`);
- await page.waitForLoadState('networkidle');
- const operatorInput = page.getByPlaceholder('请输入操作人');
- if (await operatorInput.isVisible()) {
- await operatorInput.fill('admin');
- await page.getByRole('button', { name: '查询' }).click();
- await page.waitForTimeout(1000);
- }
- });
- test('OL-003: 按操作类型筛选', async ({ page }) => {
- await page.goto(`${BASE_URL}/#/system/log`);
- await page.waitForLoadState('networkidle');
- const typeSelect = page.locator('.el-select').first();
- if (await typeSelect.isVisible()) {
- await typeSelect.click();
- await page.waitForTimeout(300);
- }
- });
- test('OL-004: 按时间范围筛选', async ({ page }) => {
- await page.goto(`${BASE_URL}/#/system/log`);
- await page.waitForLoadState('networkidle');
- });
- test('OL-005: 按模块筛选', async ({ page }) => {
- await page.goto(`${BASE_URL}/#/system/log`);
- await page.waitForLoadState('networkidle');
- });
- test('OL-006: 日志分页-每页20条', async ({ page }) => {
- await page.goto(`${BASE_URL}/#/system/log`);
- await page.waitForLoadState('networkidle');
- const pageSizeSelect = page.locator('.el-select').last();
- if (await pageSizeSelect.isVisible()) {
- await pageSizeSelect.click();
- await page.waitForTimeout(300);
- await page.getByRole('option', { name: '20 条/页' }).click();
- await page.waitForTimeout(1000);
- }
- });
- test('OL-007: 日志分页-每页50条', async ({ page }) => {
- await page.goto(`${BASE_URL}/#/system/log`);
- await page.waitForLoadState('networkidle');
- });
- test('OL-008: 导出日志Excel', async ({ page }) => {
- await page.goto(`${BASE_URL}/#/system/log`);
- await page.waitForLoadState('networkidle');
- await page.waitForTimeout(1000);
- });
- test('OL-009: 重置查询条件', async ({ page }) => {
- await page.goto(`${BASE_URL}/#/system/log`);
- await page.waitForLoadState('networkidle');
- const operatorInput = page.getByPlaceholder('请输入操作人');
- if (await operatorInput.isVisible()) {
- await operatorInput.fill('test');
- await page.getByRole('button', { name: '重置' }).click();
- await page.waitForTimeout(500);
- await expect(operatorInput).toHaveValue('');
- }
- });
- test('OL-010: 日志详情查看', async ({ page }) => {
- await page.goto(`${BASE_URL}/#/system/log`);
- await page.waitForLoadState('networkidle');
- const detailBtn = page.getByRole('button', { name: '详情' }).first();
- if (await detailBtn.isVisible()) {
- await detailBtn.click();
- await page.waitForTimeout(500);
- }
- });
- });
- test.describe('管理员管理测试', () => {
- test.beforeEach(async ({ page }) => {
- await page.goto(BASE_URL);
- await page.waitForLoadState('networkidle');
- await page.getByPlaceholder('请输入用户名').fill(TEST_ADMIN.username);
- await page.getByPlaceholder('请输入密码').fill(TEST_ADMIN.password);
- await page.getByRole('button', { name: '登 录' }).click();
- await page.waitForURL(`${BASE_URL}/#/user/app`, { timeout: 10000 });
- });
- test('OL-020: 新增管理员-用户名重复验证', async ({ page }) => {
- await page.goto(`${BASE_URL}/#/system`);
- await page.waitForLoadState('networkidle');
- const addBtn = page.getByRole('button', { name: '新增管理员' });
- if (await addBtn.isVisible()) {
- await addBtn.click();
- await page.waitForTimeout(500);
- await page.getByRole('button', { name: '保存' }).click();
- await page.waitForTimeout(500);
- }
- });
- test('OL-021: 禁用管理员', async ({ page }) => {
- await page.goto(`${BASE_URL}/#/system`);
- await page.waitForLoadState('networkidle');
- });
- test('OL-022: 启用管理员', async ({ page }) => {
- await page.goto(`${BASE_URL}/#/system`);
- await page.waitForLoadState('networkidle');
- });
- test('OL-023: 管理员密码格式验证', async ({ page }) => {
- await page.goto(`${BASE_URL}/#/system`);
- await page.waitForLoadState('networkidle');
- const addBtn = page.getByRole('button', { name: '新增管理员' });
- if (await addBtn.isVisible()) {
- await addBtn.click();
- await page.waitForTimeout(500);
- await page.getByPlaceholder('请输入密码').fill('123');
- await page.getByRole('button', { name: '保存' }).click();
- await page.waitForTimeout(500);
- }
- });
- });
|