ip-operator-p2-core.spec.ts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { expect, Page, test } from '@playwright/test';
  2. import path from 'node:path';
  3. declare global {
  4. interface Window {
  5. __seedIpOperatorScenario?: (scenario: 'ready') => unknown;
  6. }
  7. }
  8. const scenarioSeedPath = path.resolve(__dirname, '../scripts/validation/ip-operator-scenario-seed.js');
  9. const planKey = 'tiktok.ipOperator.plan.ip_plan_e2e_ready.local-guest';
  10. async function seedP2Scenario(page: Page) {
  11. await page.addInitScript({ path: scenarioSeedPath });
  12. await page.addInitScript(() => {
  13. window.__seedIpOperatorScenario?.('ready');
  14. localStorage.setItem('tiktok.currentTab', 'ip-operator');
  15. });
  16. }
  17. test('P2 core keeps account evidence connected to direction topics and production actions', async ({ page }) => {
  18. await seedP2Scenario(page);
  19. await page.goto('/');
  20. await expect(page.locator('.ip-operator-page')).toBeVisible();
  21. await expect(page.locator('.account-monitor-panel')).toContainText('账号内容与数据');
  22. await page.getByRole('button', { name: /方向选题/ }).click();
  23. const firstTopicCard = page.locator('.direction-topic-card').first();
  24. await expect(firstTopicCard).toBeVisible();
  25. await expect(firstTopicCard).toContainText('来源证据');
  26. await firstTopicCard.getByRole('button', { name: /生成分镜脚本|分镜脚本已生成/ }).click();
  27. await expect(page.locator('.shot-script-modal')).toBeVisible();
  28. await expect(page.locator('.shot-script-modal')).toContainText('核心观点');
  29. await page.locator('.shot-script-modal__close').click();
  30. await firstTopicCard.getByRole('button', { name: '生成发布包' }).click();
  31. await expect(page.locator('.workspace-tabs button.is-active')).toContainText('发布复盘');
  32. await expect.poll(async () => page.evaluate((nextPlanKey) => {
  33. const plan = JSON.parse(localStorage.getItem(nextPlanKey) || '{}');
  34. return (plan.publishPackages || []).length;
  35. }, planKey)).toBeGreaterThan(0);
  36. });