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

212 lines
6.8 KiB
TypeScript

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);
});
});