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