Files
everything-is-suitable/everything-is-suitable-uniapp/e2e/miniprogram/calendar.spec.ts
T
张翔 08ea5fbe98 feat(admin): 添加用户管理相关文件
添加用户管理视图、API和状态管理文件
2026-03-28 14:37:29 +08:00

115 lines
4.0 KiB
TypeScript

import { test, expect } from '@playwright/test';
import { MiniProgramCalendarPage } from '../pages/CalendarPage';
test.describe('小程序日历测试', () => {
let calendarPage: MiniProgramCalendarPage;
test.beforeEach(async ({ page }) => {
calendarPage = new MiniProgramCalendarPage(page);
await calendarPage.navigate();
});
test('应该显示当前日期', async () => {
const currentDate = await calendarPage.getCurrentDate();
expect(currentDate).toBeTruthy();
});
test('应该允许选择日期', async () => {
await calendarPage.selectDate('2026-02-11');
const selectedDate = await calendarPage.getSelectedDate();
expect(selectedDate).toContain('2026-02-11');
});
test('应该能够导航到下个月', async () => {
const currentMonthBefore = await calendarPage.getCurrentMonth();
await calendarPage.navigateToNextMonth();
const currentMonthAfter = await calendarPage.getCurrentMonth();
expect(currentMonthBefore).not.toBe(currentMonthAfter);
});
test('应该能够导航到上个月', async () => {
const currentMonthBefore = await calendarPage.getCurrentMonth();
await calendarPage.navigateToPreviousMonth();
const currentMonthAfter = await calendarPage.getCurrentMonth();
expect(currentMonthBefore).not.toBe(currentMonthAfter);
});
test('应该显示今天指示器', async () => {
const today = new Date();
const todayDate = today.toISOString().split('T')[0];
const isToday = await calendarPage.isToday(todayDate);
expect(isToday).toBe(true);
});
test('应该显示周末指示器', async () => {
const weekendDate = '2026-02-15';
const isWeekend = await calendarPage.isWeekend(weekendDate);
expect(isWeekend).toBe(true);
});
test('应该允许点击日期', async () => {
const date = '2026-02-11';
await calendarPage.tapDate(date);
const selectedDate = await calendarPage.getSelectedDate();
expect(selectedDate).toContain(date);
});
test('应该允许长按日期', async ({ page }) => {
const date = '2026-02-11';
await calendarPage.longPressDate(date);
await page.waitForTimeout(1000);
const selectedDate = await calendarPage.getSelectedDate();
expect(selectedDate).toContain(date);
});
test('应该允许左滑到下个月', async ({ page }) => {
const currentMonthBefore = await calendarPage.getCurrentMonth();
await calendarPage.swipeLeft();
await page.waitForTimeout(500);
const currentMonthAfter = await calendarPage.getCurrentMonth();
expect(currentMonthBefore).not.toBe(currentMonthAfter);
});
test('应该允许右滑到上个月', async ({ page }) => {
const currentMonthBefore = await calendarPage.getCurrentMonth();
await calendarPage.swipeRight();
await page.waitForTimeout(500);
const currentMonthAfter = await calendarPage.getCurrentMonth();
expect(currentMonthBefore).not.toBe(currentMonthAfter);
});
test('应该显示日历事件', async () => {
const events = await calendarPage.getCalendarEvents();
expect(Array.isArray(events)).toBe(true);
});
test('应该显示有事件日期的事件指示器', async () => {
const dateWithEvent = '2026-02-11';
const hasEvent = await calendarPage.hasEvent(dateWithEvent);
expect(hasEvent).toBe(true);
});
test('应该显示当前月份的所有日期', async () => {
const date = '2026-02-15';
const isVisible = await calendarPage.isDateVisible(date);
expect(isVisible).toBe(true);
});
test('应该显示月份视图', async () => {
const monthView = await calendarPage.getMonthView();
expect(monthView).toBeTruthy();
});
test('应该显示星期几', async () => {
const weekDays = await calendarPage.getWeekDays();
expect(Array.isArray(weekDays)).toBe(true);
expect(weekDays.length).toBe(7);
});
test('应该显示月份中的所有日期', async () => {
const dates = await calendarPage.getDatesInMonth();
expect(Array.isArray(dates)).toBe(true);
expect(dates.length).toBeGreaterThan(0);
});
});