feat(admin): 添加用户管理相关文件
添加用户管理视图、API和状态管理文件
This commit is contained in:
@@ -0,0 +1,135 @@
|
||||
import { describe, it, expect } from '@wdio/globals';
|
||||
import { MobileAlmanacPage } from '../pages/AlmanacPage';
|
||||
|
||||
describe('Android Almanac Tests', () => {
|
||||
let almanacPage: MobileAlmanacPage;
|
||||
|
||||
before(async () => {
|
||||
almanacPage = new MobileAlmanacPage(browser);
|
||||
await almanacPage.navigate();
|
||||
});
|
||||
|
||||
it('should display current date', async () => {
|
||||
const currentDate = await almanacPage.getCurrentDate();
|
||||
expect(currentDate).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should display lunar date', async () => {
|
||||
const lunarDate = await almanacPage.getLunarDate();
|
||||
expect(lunarDate).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should display gan zhi', async () => {
|
||||
const ganzhi = await almanacPage.getGanZhi();
|
||||
expect(ganzhi).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should display zodiac', async () => {
|
||||
const zodiac = await almanacPage.getZodiac();
|
||||
expect(zodiac).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should display solar term', async () => {
|
||||
const solarTerm = await almanacPage.getSolarTerm();
|
||||
expect(solarTerm).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should display suitable activities', async () => {
|
||||
const suitable = await almanacPage.getSuitable();
|
||||
expect(suitable).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should display unsuitable activities', async () => {
|
||||
const unsuitable = await almanacPage.getUnsuitable();
|
||||
expect(unsuitable).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should display day info', async () => {
|
||||
const dayInfo = await almanacPage.getDayInfo();
|
||||
expect(dayInfo).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should allow date search', async () => {
|
||||
const date = '2026-02-11';
|
||||
await almanacPage.searchDate(date);
|
||||
const currentDate = await almanacPage.getCurrentDate();
|
||||
expect(currentDate).toContain(date);
|
||||
});
|
||||
|
||||
it('should navigate to next day', async () => {
|
||||
const currentDateBefore = await almanacPage.getCurrentDate();
|
||||
await almanacPage.navigateToNextDay();
|
||||
const currentDateAfter = await almanacPage.getCurrentDate();
|
||||
expect(currentDateBefore).not.toBe(currentDateAfter);
|
||||
});
|
||||
|
||||
it('should navigate to previous day', async () => {
|
||||
const currentDateBefore = await almanacPage.getCurrentDate();
|
||||
await almanacPage.navigateToPreviousDay();
|
||||
const currentDateAfter = await almanacPage.getCurrentDate();
|
||||
expect(currentDateBefore).not.toBe(currentDateAfter);
|
||||
});
|
||||
|
||||
it('should display today indicator', async () => {
|
||||
const isToday = await almanacPage.isToday();
|
||||
expect(isToday).toBe(true);
|
||||
});
|
||||
|
||||
it('should display almanac details', async () => {
|
||||
const details = await almanacPage.getAlmanacDetails();
|
||||
expect(details).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should allow tap on date', async () => {
|
||||
const date = '2026-02-11';
|
||||
await almanacPage.tapDate(date);
|
||||
const currentDate = await almanacPage.getCurrentDate();
|
||||
expect(currentDate).toContain(date);
|
||||
});
|
||||
|
||||
it('should allow long press on date', async () => {
|
||||
const date = '2026-02-11';
|
||||
await almanacPage.longPressDate(date);
|
||||
await browser.pause(1000);
|
||||
const currentDate = await almanacPage.getCurrentDate();
|
||||
expect(currentDate).toContain(date);
|
||||
});
|
||||
|
||||
it('should allow swipe left to next day', async () => {
|
||||
const currentDateBefore = await almanacPage.getCurrentDate();
|
||||
await almanacPage.swipeLeft();
|
||||
await browser.pause(500);
|
||||
const currentDateAfter = await almanacPage.getCurrentDate();
|
||||
expect(currentDateBefore).not.toBe(currentDateAfter);
|
||||
});
|
||||
|
||||
it('should allow swipe right to previous day', async () => {
|
||||
const currentDateBefore = await almanacPage.getCurrentDate();
|
||||
await almanacPage.swipeRight();
|
||||
await browser.pause(500);
|
||||
const currentDateAfter = await almanacPage.getCurrentDate();
|
||||
expect(currentDateBefore).not.toBe(currentDateAfter);
|
||||
});
|
||||
|
||||
it('should allow share almanac', async () => {
|
||||
await almanacPage.shareAlmanac();
|
||||
await browser.pause(1000);
|
||||
const shareDialog = await browser.$('.share-dialog');
|
||||
const isVisible = await shareDialog.isDisplayed();
|
||||
expect(isVisible).toBe(true);
|
||||
});
|
||||
|
||||
it('should allow bookmark date', async () => {
|
||||
await almanacPage.bookmarkDate();
|
||||
await browser.pause(500);
|
||||
const isBookmarked = await almanacPage.isBookmarked();
|
||||
expect(isBookmarked).toBe(true);
|
||||
});
|
||||
|
||||
it('should allow unbookmark date', async () => {
|
||||
await almanacPage.bookmarkDate();
|
||||
await browser.pause(500);
|
||||
const isBookmarked = await almanacPage.isBookmarked();
|
||||
expect(isBookmarked).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,97 @@
|
||||
import { describe, it, expect } from '@wdio/globals';
|
||||
import { MobileCalendarPage } from '../pages/CalendarPage';
|
||||
|
||||
describe('Android Calendar Tests', () => {
|
||||
let calendarPage: MobileCalendarPage;
|
||||
|
||||
before(async () => {
|
||||
calendarPage = new MobileCalendarPage(browser);
|
||||
await calendarPage.navigate();
|
||||
});
|
||||
|
||||
it('should display current date', async () => {
|
||||
const currentDate = await calendarPage.getCurrentDate();
|
||||
expect(currentDate).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should allow date selection', async () => {
|
||||
await calendarPage.selectDate('2026-02-11');
|
||||
const selectedDate = await calendarPage.getSelectedDate();
|
||||
expect(selectedDate).toContain('2026-02-11');
|
||||
});
|
||||
|
||||
it('should navigate to next month', async () => {
|
||||
const currentMonthBefore = await calendarPage.getCurrentMonth();
|
||||
await calendarPage.navigateToNextMonth();
|
||||
const currentMonthAfter = await calendarPage.getCurrentMonth();
|
||||
expect(currentMonthBefore).not.toBe(currentMonthAfter);
|
||||
});
|
||||
|
||||
it('should navigate to previous month', async () => {
|
||||
const currentMonthBefore = await calendarPage.getCurrentMonth();
|
||||
await calendarPage.navigateToPreviousMonth();
|
||||
const currentMonthAfter = await calendarPage.getCurrentMonth();
|
||||
expect(currentMonthBefore).not.toBe(currentMonthAfter);
|
||||
});
|
||||
|
||||
it('should display today indicator', async () => {
|
||||
const today = new Date();
|
||||
const todayDate = today.toISOString().split('T')[0];
|
||||
const isToday = await calendarPage.isToday(todayDate);
|
||||
expect(isToday).toBe(true);
|
||||
});
|
||||
|
||||
it('should display weekend indicators', async () => {
|
||||
const weekendDate = '2026-02-15';
|
||||
const isWeekend = await calendarPage.isWeekend(weekendDate);
|
||||
expect(isWeekend).toBe(true);
|
||||
});
|
||||
|
||||
it('should allow tap on date', async () => {
|
||||
const date = '2026-02-11';
|
||||
await calendarPage.tapDate(date);
|
||||
const selectedDate = await calendarPage.getSelectedDate();
|
||||
expect(selectedDate).toContain(date);
|
||||
});
|
||||
|
||||
it('should allow long press on date', async () => {
|
||||
const date = '2026-02-11';
|
||||
await calendarPage.longPressDate(date);
|
||||
await browser.pause(1000);
|
||||
const selectedDate = await calendarPage.getSelectedDate();
|
||||
expect(selectedDate).toContain(date);
|
||||
});
|
||||
|
||||
it('should allow swipe left to next month', async () => {
|
||||
const currentMonthBefore = await calendarPage.getCurrentMonth();
|
||||
await calendarPage.swipeLeft();
|
||||
await browser.pause(500);
|
||||
const currentMonthAfter = await calendarPage.getCurrentMonth();
|
||||
expect(currentMonthBefore).not.toBe(currentMonthAfter);
|
||||
});
|
||||
|
||||
it('should allow swipe right to previous month', async () => {
|
||||
const currentMonthBefore = await calendarPage.getCurrentMonth();
|
||||
await calendarPage.swipeRight();
|
||||
await browser.pause(500);
|
||||
const currentMonthAfter = await calendarPage.getCurrentMonth();
|
||||
expect(currentMonthBefore).not.toBe(currentMonthAfter);
|
||||
});
|
||||
|
||||
it('should display calendar events', async () => {
|
||||
const events = await calendarPage.getCalendarEvents();
|
||||
expect(Array.isArray(events)).toBe(true);
|
||||
});
|
||||
|
||||
it('should display event indicators for dates with events', async () => {
|
||||
const dateWithEvent = '2026-02-11';
|
||||
const hasEvent = await calendarPage.hasEvent(dateWithEvent);
|
||||
expect(hasEvent).toBe(true);
|
||||
});
|
||||
|
||||
it('should display all dates in current month', async () => {
|
||||
const date = '2026-02-15';
|
||||
const isVisible = await calendarPage.isDateVisible(date);
|
||||
expect(isVisible).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,211 @@
|
||||
import { describe, it, expect } from '@wdio/globals';
|
||||
import { MobileSearchPage } from '../pages/SearchPage';
|
||||
|
||||
describe('Android Search Tests', () => {
|
||||
let searchPage: MobileSearchPage;
|
||||
|
||||
before(async () => {
|
||||
searchPage = new MobileSearchPage(browser);
|
||||
await searchPage.navigate();
|
||||
});
|
||||
|
||||
it('should display search input', async () => {
|
||||
const searchInput = await browser.$('.search-input input');
|
||||
const isVisible = await searchInput.isDisplayed();
|
||||
expect(isVisible).toBe(true);
|
||||
});
|
||||
|
||||
it('should allow search', async () => {
|
||||
const keyword = '春节';
|
||||
await searchPage.search(keyword);
|
||||
const hasResults = await searchPage.hasResults();
|
||||
expect(hasResults).toBe(true);
|
||||
});
|
||||
|
||||
it('should allow clear search', async () => {
|
||||
await searchPage.search('test');
|
||||
await searchPage.clearSearch();
|
||||
const hasResults = await searchPage.hasResults();
|
||||
expect(hasResults).toBe(false);
|
||||
});
|
||||
|
||||
it('should display search results', async () => {
|
||||
const keyword = '春节';
|
||||
await searchPage.search(keyword);
|
||||
const results = await searchPage.getSearchResults();
|
||||
expect(Array.isArray(results)).toBe(true);
|
||||
expect(results.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('should display result count', async () => {
|
||||
const keyword = '春节';
|
||||
await searchPage.search(keyword);
|
||||
const count = await searchPage.getResultCount();
|
||||
expect(count).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('should display no results when no matches', async () => {
|
||||
const keyword = 'xyz123';
|
||||
await searchPage.search(keyword);
|
||||
const noResults = await searchPage.noResults();
|
||||
expect(noResults).toBe(true);
|
||||
});
|
||||
|
||||
it('should allow tap on result', async () => {
|
||||
const keyword = '春节';
|
||||
await searchPage.search(keyword);
|
||||
await searchPage.tapResult(0);
|
||||
await browser.pause(1000);
|
||||
const resultTitle = await searchPage.getResultTitle(0);
|
||||
expect(resultTitle).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should allow long press on result', async () => {
|
||||
const keyword = '春节';
|
||||
await searchPage.search(keyword);
|
||||
await searchPage.longPressResult(0);
|
||||
await browser.pause(1000);
|
||||
const resultTitle = await searchPage.getResultTitle(0);
|
||||
expect(resultTitle).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should display result title', async () => {
|
||||
const keyword = '春节';
|
||||
await searchPage.search(keyword);
|
||||
const title = await searchPage.getResultTitle(0);
|
||||
expect(title).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should display result description', async () => {
|
||||
const keyword = '春节';
|
||||
await searchPage.search(keyword);
|
||||
const description = await searchPage.getResultDescription(0);
|
||||
expect(description).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should display result date', async () => {
|
||||
const keyword = '春节';
|
||||
await searchPage.search(keyword);
|
||||
const date = await searchPage.getResultDate(0);
|
||||
expect(date).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should allow filter by type', async () => {
|
||||
const keyword = '春节';
|
||||
await searchPage.search(keyword);
|
||||
await searchPage.filterByType('holiday');
|
||||
const results = await searchPage.getSearchResults();
|
||||
expect(Array.isArray(results)).toBe(true);
|
||||
});
|
||||
|
||||
it('should allow filter by date range', async () => {
|
||||
const startDate = '2026-01-01';
|
||||
const endDate = '2026-12-31';
|
||||
await searchPage.filterByDate(startDate, endDate);
|
||||
const results = await searchPage.getSearchResults();
|
||||
expect(Array.isArray(results)).toBe(true);
|
||||
});
|
||||
|
||||
it('should allow sort', async () => {
|
||||
const keyword = '春节';
|
||||
await searchPage.search(keyword);
|
||||
await searchPage.sortBy('date');
|
||||
const currentSort = await searchPage.getCurrentSort();
|
||||
expect(currentSort).toContain('date');
|
||||
});
|
||||
|
||||
it('should display active filters', async () => {
|
||||
const keyword = '春节';
|
||||
await searchPage.search(keyword);
|
||||
await searchPage.filterByType('holiday');
|
||||
const activeFilters = await searchPage.getActiveFilters();
|
||||
expect(Array.isArray(activeFilters)).toBe(true);
|
||||
});
|
||||
|
||||
it('should allow clear filters', async () => {
|
||||
const keyword = '春节';
|
||||
await searchPage.search(keyword);
|
||||
await searchPage.filterByType('holiday');
|
||||
await searchPage.clearFilters();
|
||||
const activeFilters = await searchPage.getActiveFilters();
|
||||
expect(activeFilters.length).toBe(0);
|
||||
});
|
||||
|
||||
it('should allow save search', async () => {
|
||||
const keyword = '春节';
|
||||
await searchPage.saveSearch(keyword);
|
||||
const savedSearches = await searchPage.getSavedSearches();
|
||||
expect(savedSearches).toContain(keyword);
|
||||
});
|
||||
|
||||
it('should display saved searches', async () => {
|
||||
const savedSearches = await searchPage.getSavedSearches();
|
||||
expect(Array.isArray(savedSearches)).toBe(true);
|
||||
});
|
||||
|
||||
it('should allow delete saved search', async () => {
|
||||
const keyword = '春节';
|
||||
await searchPage.saveSearch(keyword);
|
||||
await searchPage.deleteSavedSearch(keyword);
|
||||
const savedSearches = await searchPage.getSavedSearches();
|
||||
expect(savedSearches).not.toContain(keyword);
|
||||
});
|
||||
|
||||
it('should display recent searches', async () => {
|
||||
const keyword = 'test';
|
||||
await searchPage.search(keyword);
|
||||
const recentSearches = await searchPage.getRecentSearches();
|
||||
expect(Array.isArray(recentSearches)).toBe(true);
|
||||
});
|
||||
|
||||
it('should allow clear recent searches', async () => {
|
||||
await searchPage.clearRecentSearches();
|
||||
const recentSearches = await searchPage.getRecentSearches();
|
||||
expect(recentSearches.length).toBe(0);
|
||||
});
|
||||
|
||||
it('should display search suggestions', async () => {
|
||||
const keyword = '春';
|
||||
const suggestions = await searchPage.getSearchSuggestions(keyword);
|
||||
expect(Array.isArray(suggestions)).toBe(true);
|
||||
});
|
||||
|
||||
it('should allow select suggestion', async () => {
|
||||
const keyword = '春';
|
||||
await searchPage.selectSuggestion(0);
|
||||
const hasResults = await searchPage.hasResults();
|
||||
expect(hasResults).toBe(true);
|
||||
});
|
||||
|
||||
it('should allow swipe left', async () => {
|
||||
await searchPage.swipeLeft();
|
||||
await browser.pause(500);
|
||||
const searchInput = await browser.$('.search-input input');
|
||||
const isVisible = await searchInput.isDisplayed();
|
||||
expect(isVisible).toBe(true);
|
||||
});
|
||||
|
||||
it('should allow swipe right', async () => {
|
||||
await searchPage.swipeRight();
|
||||
await browser.pause(500);
|
||||
const searchInput = await browser.$('.search-input input');
|
||||
const isVisible = await searchInput.isDisplayed();
|
||||
expect(isVisible).toBe(true);
|
||||
});
|
||||
|
||||
it('should allow swipe up', async () => {
|
||||
await searchPage.swipeUp();
|
||||
await browser.pause(500);
|
||||
const searchInput = await browser.$('.search-input input');
|
||||
const isVisible = await searchInput.isDisplayed();
|
||||
expect(isVisible).toBe(true);
|
||||
});
|
||||
|
||||
it('should allow swipe down', async () => {
|
||||
await searchPage.swipeDown();
|
||||
await browser.pause(500);
|
||||
const searchInput = await browser.$('.search-input input');
|
||||
const isVisible = await searchInput.isDisplayed();
|
||||
expect(isVisible).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,140 @@
|
||||
import { describe, it, expect } from '@wdio/globals';
|
||||
import { MobileUserPage } from '../pages/UserPage';
|
||||
|
||||
describe('Android User Tests', () => {
|
||||
let userPage: MobileUserPage;
|
||||
|
||||
before(async () => {
|
||||
userPage = new MobileUserPage(browser);
|
||||
await userPage.navigate();
|
||||
});
|
||||
|
||||
it('should display username', async () => {
|
||||
const username = await userPage.getUsername();
|
||||
expect(username).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should display user avatar', async () => {
|
||||
const avatar = await userPage.getUserAvatar();
|
||||
expect(avatar).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should check login status', async () => {
|
||||
const isLoggedIn = await userPage.isLoggedIn();
|
||||
expect(typeof isLoggedIn).toBe('boolean');
|
||||
});
|
||||
|
||||
it('should allow login', async () => {
|
||||
await userPage.navigate();
|
||||
const isLoggedInBefore = await userPage.isLoggedIn();
|
||||
|
||||
if (!isLoggedInBefore) {
|
||||
await userPage.login('test-user', 'test-password');
|
||||
const isLoggedInAfter = await userPage.isLoggedIn();
|
||||
expect(isLoggedInAfter).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
it('should allow logout', async () => {
|
||||
await userPage.logout();
|
||||
const isLoggedIn = await userPage.isLoggedIn();
|
||||
expect(isLoggedIn).toBe(false);
|
||||
});
|
||||
|
||||
it('should navigate to profile', async () => {
|
||||
await userPage.login('test-user', 'test-password');
|
||||
await userPage.navigateToProfile();
|
||||
const profile = await userPage.getProfile();
|
||||
expect(profile.username).toBe('test-user');
|
||||
});
|
||||
|
||||
it('should navigate to settings', async () => {
|
||||
await userPage.navigateToSettings();
|
||||
const settings = await userPage.getSettings();
|
||||
expect(settings.theme).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should navigate to history', async () => {
|
||||
await userPage.navigateToHistory();
|
||||
const history = await userPage.getHistory();
|
||||
expect(Array.isArray(history)).toBe(true);
|
||||
});
|
||||
|
||||
it('should navigate to favorites', async () => {
|
||||
await userPage.navigateToFavorites();
|
||||
const favorites = await userPage.getFavorites();
|
||||
expect(Array.isArray(favorites)).toBe(true);
|
||||
});
|
||||
|
||||
it('should allow profile update', async () => {
|
||||
await userPage.updateProfile({
|
||||
username: 'updated-user',
|
||||
email: 'updated@example.com',
|
||||
phone: '1234567890',
|
||||
});
|
||||
const profile = await userPage.getProfile();
|
||||
expect(profile.username).toBe('updated-user');
|
||||
});
|
||||
|
||||
it('should allow theme toggle', async () => {
|
||||
const themeBefore = await userPage.getCurrentTheme();
|
||||
await userPage.toggleTheme();
|
||||
const themeAfter = await userPage.getCurrentTheme();
|
||||
expect(themeBefore).not.toBe(themeAfter);
|
||||
});
|
||||
|
||||
it('should allow settings update', async () => {
|
||||
await userPage.updateSetting('theme', 'dark');
|
||||
const settings = await userPage.getSettings();
|
||||
expect(settings.theme).toContain('dark');
|
||||
});
|
||||
|
||||
it('should allow history clear', async () => {
|
||||
await userPage.clearHistory();
|
||||
const history = await userPage.getHistory();
|
||||
expect(history.length).toBe(0);
|
||||
});
|
||||
|
||||
it('should allow favorite removal', async () => {
|
||||
await userPage.navigateToFavorites();
|
||||
const favoritesBefore = await userPage.getFavorites();
|
||||
|
||||
if (favoritesBefore.length > 0) {
|
||||
const firstFavoriteId = '1';
|
||||
await userPage.removeFavorite(firstFavoriteId);
|
||||
const favoritesAfter = await userPage.getFavorites();
|
||||
expect(favoritesAfter.length).toBe(favoritesBefore.length - 1);
|
||||
}
|
||||
});
|
||||
|
||||
it('should allow tap on button', async () => {
|
||||
await userPage.navigate();
|
||||
await userPage.tapButton('profile-button');
|
||||
const profile = await userPage.getProfile();
|
||||
expect(profile.username).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should allow long press on button', async () => {
|
||||
await userPage.navigate();
|
||||
await userPage.longPressButton('settings-button');
|
||||
await browser.pause(1000);
|
||||
const settings = await userPage.getSettings();
|
||||
expect(settings.theme).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should allow swipe up', async () => {
|
||||
await userPage.navigate();
|
||||
await userPage.swipeUp();
|
||||
await browser.pause(500);
|
||||
const username = await userPage.getUsername();
|
||||
expect(username).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should allow swipe down', async () => {
|
||||
await userPage.navigate();
|
||||
await userPage.swipeDown();
|
||||
await browser.pause(500);
|
||||
const username = await userPage.getUsername();
|
||||
expect(username).toBeTruthy();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user