You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ghost/e2e/tests/admin/analytics/post-analytics/overview.test.ts

65 lines
3.2 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import {test, expect} from '../../../../helpers/playwright';
import {
AnalyticsOverviewPage,
PostAnalyticsPage,
PostAnalyticsGrowthPage,
PostAnalyticsWebTrafficPage
} from '../../../../helpers/pages/admin';
/**
* 文件说明:
* 这个测试文件包含文章级别 Analytics 的 Overview 视图相关的 e2e 测试。
* 场景主要验证在“空数据”情况下,各个卡片/选项卡的可见性和提示文本。
*/
test.describe('Ghost Admin - Post Analytics - Overview', () => {
// 在每个测试前都执行:导航到 Analytics 概览并打开最新文章的 analytics 面板
test.beforeEach(async ({page}) => {
const analyticsOverviewPage = new AnalyticsOverviewPage(page);
await analyticsOverviewPage.goto();
// 在概览页点击“最新文章”的 analytics 按钮,进入文章分析面板
await analyticsOverviewPage.latestPost.analyticsButton.click();
});
// 验证概览页面存在三个主要选项卡Overview / Web traffic / Growth
test('empty page with all tabs', async ({page}) => {
const postAnalyticsPage = new PostAnalyticsPage(page);
// 三个切换按钮都应可见,确保页面结构完整
await expect(postAnalyticsPage.overviewButton).toBeVisible();
await expect(postAnalyticsPage.webTrafficButton).toBeVisible();
await expect(postAnalyticsPage.growthButton).toBeVisible();
});
// 在 Overview -> Web performance 区块点击 "View more" 应进入 Web traffic 视图并显示无访问提示
test('empty page - overview - web performance - view more', async ({page}) => {
const postAnalyticsPage = new PostAnalyticsPage(page);
// 点击 Web performance 区块的 “View more” 按钮,进入流量详情页
await postAnalyticsPage.webPerformanceSection.viewMoreButton.click();
const postAnalyticsWebTrafficPage = new PostAnalyticsWebTrafficPage(page);
// 在空数据场景下web traffic 页面应包含“No visitors in the last 30 days”提示
await expect(postAnalyticsWebTrafficPage.body).toContainText('No visitors in the last 30 days');
});
// 验证 Growth 区块在空数据情况下显示“Free members” 并且数量为 0
test('empty page - overview - growth', async ({page}) => {
const postAnalyticsPage = new PostAnalyticsPage(page);
await expect(postAnalyticsPage.growthSection.card).toContainText('Free members');
await expect(postAnalyticsPage.growthSection.card).toContainText('0');
});
// 在 Overview -> Growth 区块点击 "View more" 应进入 Growth 详情并显示无来源数据提示
test('empty page - overview - growth - view more', async ({page}) => {
const postAnalyticsPage = new PostAnalyticsPage(page);
// 点击 Growth 卡片的“View more”按钮进入增长详情页
await postAnalyticsPage.growthSection.viewMoreButton.click();
const postAnalyticsGrowthPage = new PostAnalyticsGrowthPage(page);
// 在空数据场景下top sources 卡片应展示“No sources data available”提示
await expect(postAnalyticsGrowthPage.topSourcesCard).toContainText('No sources data available');
});
});