home-to-generation.spec.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. import { test, expect } from '../fixtures/base';
  2. import { HomePage } from '../pages/home.page';
  3. import { createSettingsStorage } from '../fixtures/test-data/settings';
  4. // Inject settings with modelId so the "enter classroom" button works
  5. const SETTINGS_STORAGE = createSettingsStorage();
  6. test.describe('Home → Generation', () => {
  7. test.beforeEach(async ({ page }) => {
  8. await page.addInitScript((settings) => {
  9. localStorage.setItem('settings-storage', settings);
  10. }, SETTINGS_STORAGE);
  11. });
  12. test('home page loads with core UI elements and submits requirement', async ({ page }) => {
  13. const home = new HomePage(page);
  14. await home.goto();
  15. // Core elements visible
  16. await expect(home.logo).toBeVisible();
  17. await expect(home.textarea).toBeVisible();
  18. await expect(home.enterButton).toBeDisabled();
  19. // Type requirement → button activates
  20. await home.fillRequirement('讲解光合作用');
  21. await expect(home.enterButton).toBeEnabled();
  22. // Submit → navigate to generation-preview
  23. await home.submit();
  24. await page.waitForURL(/\/generation-preview/);
  25. expect(page.url()).toContain('/generation-preview');
  26. });
  27. });