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

141 lines
4.3 KiB
TypeScript

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