|
| 1 | +import * as path from "node:path"; |
| 2 | +import { test, expect } from "./fixtures"; |
| 3 | +import { |
| 4 | + ensureAuthenticatedInPage, |
| 5 | + gotoWithAuthRecovery, |
| 6 | + refreshAuthState, |
| 7 | +} from "./helpers/auth-refresh"; |
| 8 | + |
| 9 | +test.describe("Help Center Markdown Import", () => { |
| 10 | + test.describe.configure({ timeout: 120000 }); |
| 11 | + |
| 12 | + test.beforeEach(async ({ page }) => { |
| 13 | + await refreshAuthState(); |
| 14 | + const ok = await ensureAuthenticatedInPage(page); |
| 15 | + if (!ok) { |
| 16 | + test.skip(true, "[help-center-import.spec] Could not authenticate test page"); |
| 17 | + } |
| 18 | + }); |
| 19 | + |
| 20 | + test("imports docs folder and shows articles in help center", async ({ page }) => { |
| 21 | + await gotoWithAuthRecovery(page, "/articles"); |
| 22 | + await expect(page.getByRole("heading", { name: /^articles$/i })).toBeVisible({ |
| 23 | + timeout: 10000, |
| 24 | + }); |
| 25 | + |
| 26 | + const docsFolderPath = path.resolve(process.cwd(), "docs"); |
| 27 | + await page.getByTestId("markdown-import-folder-input").setInputFiles(docsFolderPath); |
| 28 | + await expect(page.getByTestId("markdown-import-selection-count")).toBeVisible({ |
| 29 | + timeout: 10000, |
| 30 | + }); |
| 31 | + |
| 32 | + await page.getByTestId("markdown-import-preview-button").click(); |
| 33 | + await expect(page.getByText(/Preview ready\./i)).toBeVisible({ timeout: 45000 }); |
| 34 | + |
| 35 | + await page.getByTestId("markdown-import-sync-button").click(); |
| 36 | + await expect(page.getByText(/Synced \d+ markdown files\./i)).toBeVisible({ timeout: 45000 }); |
| 37 | + |
| 38 | + const downloadPromise = page.waitForEvent("download"); |
| 39 | + await page.getByTestId("markdown-export-button").click(); |
| 40 | + const download = await downloadPromise; |
| 41 | + expect(download.suggestedFilename()).toMatch(/help-center-markdown.*\.zip/i); |
| 42 | + |
| 43 | + await gotoWithAuthRecovery(page, "/help"); |
| 44 | + await expect(page.getByRole("heading", { name: /help center/i })).toBeVisible({ |
| 45 | + timeout: 10000, |
| 46 | + }); |
| 47 | + |
| 48 | + const importedArticleLink = page.getByRole("link", { name: /Architecture Overview/i }).first(); |
| 49 | + await expect(importedArticleLink).toBeVisible({ timeout: 20000 }); |
| 50 | + const articleHref = await importedArticleLink.getAttribute("href"); |
| 51 | + expect(articleHref).toBeTruthy(); |
| 52 | + await gotoWithAuthRecovery(page, articleHref!); |
| 53 | + await expect(page.getByRole("heading", { name: /Architecture Overview/i })).toBeVisible({ |
| 54 | + timeout: 10000, |
| 55 | + }); |
| 56 | + await expect(page.getByText(/high-level architecture/i)).toBeVisible({ timeout: 10000 }); |
| 57 | + }); |
| 58 | +}); |
0 commit comments