feat(admin): 添加用户管理相关文件
添加用户管理视图、API和状态管理文件
This commit is contained in:
@@ -0,0 +1,274 @@
|
||||
"""
|
||||
日历模块测试
|
||||
|
||||
Uniapp日历功能的测试用例。
|
||||
"""
|
||||
|
||||
import pytest
|
||||
import allure
|
||||
from playwright.sync_api import Page
|
||||
|
||||
|
||||
@allure.epic("Uniapp客户端")
|
||||
@allure.feature("日历模块")
|
||||
class TestCalendar:
|
||||
"""日历模块测试类"""
|
||||
|
||||
@allure.title("日历页面加载测试")
|
||||
@allure.description("验证日历页面可以正常加载")
|
||||
@allure.severity(allure.severity_level.CRITICAL)
|
||||
@pytest.mark.smoke
|
||||
def test_calendar_page_load(self, calendar_page) -> None:
|
||||
"""
|
||||
测试日历页面加载
|
||||
|
||||
前置条件:
|
||||
- Uniapp服务已启动
|
||||
|
||||
测试步骤:
|
||||
1. 导航到日历页面
|
||||
2. 等待页面加载
|
||||
|
||||
预期结果:
|
||||
- 日历视图可见
|
||||
- 月份显示正确
|
||||
"""
|
||||
with allure.step("导航到日历页面"):
|
||||
calendar_page.navigate()
|
||||
assert calendar_page.is_loaded(), "日历页面未加载完成"
|
||||
|
||||
with allure.step("验证页面元素"):
|
||||
month_display = calendar_page.get_month_display()
|
||||
allure.attach(f"月份显示: {month_display}", "日历信息", allure.attachment_type.TEXT)
|
||||
assert month_display, "月份未显示"
|
||||
|
||||
@allure.title("月视图显示测试")
|
||||
@allure.description("验证日历月视图正确显示")
|
||||
@allure.severity(allure.severity_level.CRITICAL)
|
||||
@pytest.mark.smoke
|
||||
def test_month_view_display(self, calendar_page) -> None:
|
||||
"""
|
||||
测试月视图显示
|
||||
|
||||
前置条件:
|
||||
- 日历页面已加载
|
||||
|
||||
测试步骤:
|
||||
1. 查看月份显示
|
||||
2. 查看日期单元格
|
||||
3. 验证日期数量
|
||||
|
||||
预期结果:
|
||||
- 月份正确显示
|
||||
- 日期单元格可见
|
||||
- 日期数量合理(28-31天)
|
||||
"""
|
||||
with allure.step("导航到日历页面"):
|
||||
calendar_page.navigate()
|
||||
calendar_page.wait_for_calendar_load()
|
||||
|
||||
with allure.step("验证月视图"):
|
||||
month_display = calendar_page.get_month_display()
|
||||
year_display = calendar_page.get_year_display()
|
||||
date_count = calendar_page.get_date_cells_count()
|
||||
|
||||
allure.attach(f"年份: {year_display}", "日历统计", allure.attachment_type.TEXT)
|
||||
allure.attach(f"月份: {month_display}", "日历统计", allure.attachment_type.TEXT)
|
||||
allure.attach(f"日期数量: {date_count}", "日历统计", allure.attachment_type.TEXT)
|
||||
|
||||
assert month_display, "月份未显示"
|
||||
assert date_count > 0, "日期单元格未显示"
|
||||
# 一个月应该有28-42个日期单元格(包括上月和下月的日期)
|
||||
assert 28 <= date_count <= 42, f"日期数量异常: {date_count}"
|
||||
|
||||
@allure.title("月份切换功能测试")
|
||||
@allure.description("验证月份切换功能正常工作")
|
||||
@allure.severity(allure.severity_level.CRITICAL)
|
||||
@pytest.mark.smoke
|
||||
def test_month_switch(self, calendar_page) -> None:
|
||||
"""
|
||||
测试月份切换功能
|
||||
|
||||
前置条件:
|
||||
- 日历页面已加载
|
||||
|
||||
测试步骤:
|
||||
1. 获取当前月份
|
||||
2. 点击上一月按钮
|
||||
3. 验证月份变化
|
||||
4. 点击下一月按钮
|
||||
5. 验证月份变化
|
||||
|
||||
预期结果:
|
||||
- 月份正确切换
|
||||
- 日历内容更新
|
||||
"""
|
||||
with allure.step("导航到日历页面"):
|
||||
calendar_page.navigate()
|
||||
calendar_page.wait_for_calendar_load()
|
||||
|
||||
with allure.step("获取当前月份"):
|
||||
initial_month = calendar_page.get_month_display()
|
||||
allure.attach(f"初始月份: {initial_month}", "月份切换", allure.attachment_type.TEXT)
|
||||
|
||||
with allure.step("点击上一月"):
|
||||
calendar_page.click_prev_month()
|
||||
calendar_page.wait_for_calendar_load()
|
||||
prev_month = calendar_page.get_month_display()
|
||||
allure.attach(f"上一月: {prev_month}", "月份切换", allure.attachment_type.TEXT)
|
||||
|
||||
with allure.step("点击下一月"):
|
||||
calendar_page.click_next_month()
|
||||
calendar_page.wait_for_calendar_load()
|
||||
next_month = calendar_page.get_month_display()
|
||||
allure.attach(f"下一月: {next_month}", "月份切换", allure.attachment_type.TEXT)
|
||||
|
||||
with allure.step("验证月份切换"):
|
||||
# 验证月份有变化
|
||||
assert prev_month != initial_month or next_month != initial_month, "月份切换未生效"
|
||||
|
||||
@allure.title("日期选择功能测试")
|
||||
@allure.description("验证日期选择功能正常工作")
|
||||
@allure.severity(allure.severity_level.CRITICAL)
|
||||
@pytest.mark.smoke
|
||||
def test_date_selection(self, calendar_page) -> None:
|
||||
"""
|
||||
测试日期选择功能
|
||||
|
||||
前置条件:
|
||||
- 日历页面已加载
|
||||
|
||||
测试步骤:
|
||||
1. 点击指定日期
|
||||
2. 验证日期被选中
|
||||
|
||||
预期结果:
|
||||
- 日期被选中
|
||||
- 选中样式正确
|
||||
"""
|
||||
with allure.step("导航到日历页面"):
|
||||
calendar_page.navigate()
|
||||
calendar_page.wait_for_calendar_load()
|
||||
|
||||
with allure.step("选择日期"):
|
||||
# 选择1号
|
||||
calendar_page.click_date(1)
|
||||
# 等待选中状态更新
|
||||
import time
|
||||
time.sleep(1)
|
||||
|
||||
with allure.step("验证日期选择"):
|
||||
# 验证有日期被选中
|
||||
selected = calendar_page.get_selected_date()
|
||||
allure.attach(f"选中日期: {selected}", "日期选择", allure.attachment_type.TEXT)
|
||||
# 选中日期应该不为空
|
||||
assert selected, "日期选择未生效"
|
||||
|
||||
@allure.title("农历显示测试")
|
||||
@allure.description("验证日历正确显示农历信息")
|
||||
@allure.severity(allure.severity_level.NORMAL)
|
||||
@pytest.mark.regression
|
||||
def test_lunar_display(self, calendar_page) -> None:
|
||||
"""
|
||||
测试农历显示
|
||||
|
||||
前置条件:
|
||||
- 日历页面已加载
|
||||
|
||||
测试步骤:
|
||||
1. 查看日期单元格的农历显示
|
||||
2. 验证农历信息
|
||||
|
||||
预期结果:
|
||||
- 农历信息正确显示
|
||||
"""
|
||||
with allure.step("导航到日历页面"):
|
||||
calendar_page.navigate()
|
||||
calendar_page.wait_for_calendar_load()
|
||||
|
||||
with allure.step("验证农历显示"):
|
||||
# 检查1号是否有农历显示
|
||||
has_lunar = calendar_page.has_lunar_text(1)
|
||||
lunar_text = calendar_page.get_lunar_text(1)
|
||||
|
||||
allure.attach(f"农历显示: {has_lunar}", "农历信息", allure.attachment_type.TEXT)
|
||||
allure.attach(f"农历文本: {lunar_text}", "农历信息", allure.attachment_type.TEXT)
|
||||
|
||||
# 农历显示可能存在也可能不存在,取决于实现
|
||||
# 这里只验证方法可以正常执行
|
||||
assert has_lunar is not None, "农历检查异常"
|
||||
|
||||
@allure.title("今天按钮功能测试")
|
||||
@allure.description("验证今天按钮功能正常工作")
|
||||
@allure.severity(allure.severity_level.NORMAL)
|
||||
@pytest.mark.regression
|
||||
def test_today_button(self, calendar_page) -> None:
|
||||
"""
|
||||
测试今天按钮功能
|
||||
|
||||
前置条件:
|
||||
- 日历页面已加载
|
||||
- 当前不在今天所在月份
|
||||
|
||||
测试步骤:
|
||||
1. 切换到其他月份
|
||||
2. 点击今天按钮
|
||||
3. 验证回到当前月份
|
||||
|
||||
预期结果:
|
||||
- 日历回到当前月份
|
||||
- 今天日期被选中
|
||||
"""
|
||||
with allure.step("导航到日历页面"):
|
||||
calendar_page.navigate()
|
||||
calendar_page.wait_for_calendar_load()
|
||||
|
||||
with allure.step("切换到其他月份"):
|
||||
calendar_page.click_next_month()
|
||||
calendar_page.wait_for_calendar_load()
|
||||
other_month = calendar_page.get_month_display()
|
||||
allure.attach(f"其他月份: {other_month}", "今天按钮", allure.attachment_type.TEXT)
|
||||
|
||||
with allure.step("点击今天按钮"):
|
||||
calendar_page.click_today()
|
||||
calendar_page.wait_for_calendar_load()
|
||||
current_month = calendar_page.get_month_display()
|
||||
allure.attach(f"当前月份: {current_month}", "今天按钮", allure.attachment_type.TEXT)
|
||||
|
||||
with allure.step("验证回到今天"):
|
||||
# 验证月份变化了
|
||||
assert current_month != other_month or calendar_page.get_selected_date(), "今天按钮未生效"
|
||||
|
||||
@allure.title("Tab切换功能测试")
|
||||
@allure.description("验证底部Tab切换功能正常")
|
||||
@allure.severity(allure.severity_level.NORMAL)
|
||||
@pytest.mark.regression
|
||||
def test_tab_switch(self, calendar_page, page: Page) -> None:
|
||||
"""
|
||||
测试Tab切换功能
|
||||
|
||||
前置条件:
|
||||
- 日历页面已加载
|
||||
|
||||
测试步骤:
|
||||
1. 点击黄历Tab
|
||||
2. 点击万年历Tab
|
||||
3. 点击我的Tab
|
||||
|
||||
预期结果:
|
||||
- Tab切换正常
|
||||
- 页面内容更新
|
||||
"""
|
||||
with allure.step("导航到日历页面"):
|
||||
calendar_page.navigate()
|
||||
calendar_page.wait_for_calendar_load()
|
||||
|
||||
with allure.step("切换到黄历Tab"):
|
||||
calendar_page.click_tab_almanac()
|
||||
# 验证URL变化
|
||||
assert "almanac" in page.url or "/pages/almanac" in page.url, "未切换到黄历"
|
||||
|
||||
with allure.step("切换回万年历Tab"):
|
||||
calendar_page.click_tab_calendar()
|
||||
# 验证URL变化
|
||||
assert "calendar" in page.url or "/pages/calendar" in page.url, "未切换回万年历"
|
||||
Reference in New Issue
Block a user