08ea5fbe98
添加用户管理视图、API和状态管理文件
151 lines
4.8 KiB
TypeScript
151 lines
4.8 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
import { MiniProgramAlmanacPage } from '../pages/AlmanacPage';
|
|
|
|
test.describe('小程序黄历测试', () => {
|
|
let almanacPage: MiniProgramAlmanacPage;
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
almanacPage = new MiniProgramAlmanacPage(page);
|
|
await almanacPage.navigate();
|
|
});
|
|
|
|
test('应该显示当前日期', async () => {
|
|
const currentDate = await almanacPage.getCurrentDate();
|
|
expect(currentDate).toBeTruthy();
|
|
});
|
|
|
|
test('应该显示农历日期', async () => {
|
|
const lunarDate = await almanacPage.getLunarDate();
|
|
expect(lunarDate).toBeTruthy();
|
|
});
|
|
|
|
test('应该显示干支', async () => {
|
|
const ganzhi = await almanacPage.getGanZhi();
|
|
expect(ganzhi).toBeTruthy();
|
|
});
|
|
|
|
test('应该显示生肖', async () => {
|
|
const zodiac = await almanacPage.getZodiac();
|
|
expect(zodiac).toBeTruthy();
|
|
});
|
|
|
|
test('应该显示节气', async () => {
|
|
const solarTerm = await almanacPage.getSolarTerm();
|
|
expect(solarTerm).toBeTruthy();
|
|
});
|
|
|
|
test('应该显示宜', async () => {
|
|
const suitable = await almanacPage.getSuitable();
|
|
expect(suitable).toBeTruthy();
|
|
});
|
|
|
|
test('应该显示忌', async () => {
|
|
const unsuitable = await almanacPage.getUnsuitable();
|
|
expect(unsuitable).toBeTruthy();
|
|
});
|
|
|
|
test('应该显示日期信息', async () => {
|
|
const dayInfo = await almanacPage.getDayInfo();
|
|
expect(dayInfo).toBeTruthy();
|
|
});
|
|
|
|
test('应该允许日期搜索', async () => {
|
|
const date = '2026-02-11';
|
|
await almanacPage.searchDate(date);
|
|
const currentDate = await almanacPage.getCurrentDate();
|
|
expect(currentDate).toContain(date);
|
|
});
|
|
|
|
test('应该能够导航到下一天', async () => {
|
|
const currentDateBefore = await almanacPage.getCurrentDate();
|
|
await almanacPage.navigateToNextDay();
|
|
const currentDateAfter = await almanacPage.getCurrentDate();
|
|
expect(currentDateBefore).not.toBe(currentDateAfter);
|
|
});
|
|
|
|
test('应该能够导航到上一天', async () => {
|
|
const currentDateBefore = await almanacPage.getCurrentDate();
|
|
await almanacPage.navigateToPreviousDay();
|
|
const currentDateAfter = await almanacPage.getCurrentDate();
|
|
expect(currentDateBefore).not.toBe(currentDateAfter);
|
|
});
|
|
|
|
test('应该显示今天指示器', async () => {
|
|
const isToday = await almanacPage.isToday();
|
|
expect(isToday).toBe(true);
|
|
});
|
|
|
|
test('应该显示黄历详情', async () => {
|
|
const details = await almanacPage.getAlmanacDetails();
|
|
expect(details).toBeTruthy();
|
|
});
|
|
|
|
test('应该允许点击日期', async () => {
|
|
const date = '2026-02-11';
|
|
await almanacPage.tapDate(date);
|
|
const currentDate = await almanacPage.getCurrentDate();
|
|
expect(currentDate).toContain(date);
|
|
});
|
|
|
|
test('应该允许长按日期', async ({ page }) => {
|
|
const date = '2026-02-11';
|
|
await almanacPage.longPressDate(date);
|
|
await page.waitForTimeout(1000);
|
|
const currentDate = await almanacPage.getCurrentDate();
|
|
expect(currentDate).toContain(date);
|
|
});
|
|
|
|
test('应该允许左滑到下一天', async ({ page }) => {
|
|
const currentDateBefore = await almanacPage.getCurrentDate();
|
|
await almanacPage.swipeLeft();
|
|
await page.waitForTimeout(500);
|
|
const currentDateAfter = await almanacPage.getCurrentDate();
|
|
expect(currentDateBefore).not.toBe(currentDateAfter);
|
|
});
|
|
|
|
test('应该允许右滑到上一天', async ({ page }) => {
|
|
const currentDateBefore = await almanacPage.getCurrentDate();
|
|
await almanacPage.swipeRight();
|
|
await page.waitForTimeout(500);
|
|
const currentDateAfter = await almanacPage.getCurrentDate();
|
|
expect(currentDateBefore).not.toBe(currentDateAfter);
|
|
});
|
|
|
|
test('应该允许分享黄历', async () => {
|
|
await almanacPage.shareAlmanac();
|
|
await page.waitForTimeout(1000);
|
|
const shareDialog = await page.$('.share-dialog');
|
|
const isVisible = await shareDialog?.isVisible();
|
|
expect(isVisible).toBe(true);
|
|
});
|
|
|
|
test('应该允许收藏日期', async () => {
|
|
await almanacPage.bookmarkDate();
|
|
await page.waitForTimeout(500);
|
|
const isBookmarked = await almanacPage.isBookmarked();
|
|
expect(isBookmarked).toBe(true);
|
|
});
|
|
|
|
test('应该允许取消收藏日期', async () => {
|
|
await almanacPage.bookmarkDate();
|
|
await page.waitForTimeout(500);
|
|
const isBookmarked = await almanacPage.isBookmarked();
|
|
expect(isBookmarked).toBe(false);
|
|
});
|
|
|
|
test('应该显示农历日历', async () => {
|
|
const lunarCalendar = await almanacPage.getLunarCalendar();
|
|
expect(lunarCalendar).toBeTruthy();
|
|
});
|
|
|
|
test('应该显示节日', async () => {
|
|
const festivals = await almanacPage.getFestivals();
|
|
expect(Array.isArray(festivals)).toBe(true);
|
|
});
|
|
|
|
test('应该显示有节日的节日指示器', async () => {
|
|
const hasFestival = await almanacPage.hasFestival();
|
|
expect(typeof hasFestival).toBe('boolean');
|
|
});
|
|
});
|