|
| 1 | +import path from 'node:path'; |
| 2 | +import { expect, test } from '@playwright/test'; |
| 3 | +import { getPort, killProcess, runDevCommand } from '../utils/runCommands'; |
| 4 | + |
| 5 | +const fixtureDir = path.resolve(__dirname, '../fixtures'); |
| 6 | + |
| 7 | +test.describe('plugin test', async () => { |
| 8 | + let appPort; |
| 9 | + let app; |
| 10 | + test.beforeAll(async () => { |
| 11 | + const appDir = path.join(fixtureDir, 'plugin-playground'); |
| 12 | + appPort = await getPort(); |
| 13 | + app = await runDevCommand(appDir, appPort); |
| 14 | + }); |
| 15 | + |
| 16 | + test.afterAll(async () => { |
| 17 | + if (app) { |
| 18 | + await killProcess(app); |
| 19 | + } |
| 20 | + }); |
| 21 | + |
| 22 | + test('Should render the element', async ({ page }) => { |
| 23 | + await page.goto(`http://localhost:${appPort}/`, { |
| 24 | + waitUntil: 'networkidle', |
| 25 | + }); |
| 26 | + |
| 27 | + const playgroundElements = await page.$$('.rspress-playground'); |
| 28 | + |
| 29 | + const internalDemoCodePreviewDefault = await page |
| 30 | + .locator('.rspress-playground > .rspress-playground-runner > div') |
| 31 | + .getByText('Hello World Internal (default)'); |
| 32 | + |
| 33 | + const internalDemoCodePreviewVertical = await page |
| 34 | + .locator('.rspress-playground > .rspress-playground-runner > div') |
| 35 | + .getByText('Hello World Internal (vertical)'); |
| 36 | + |
| 37 | + const externalDemoCodePreview = await page |
| 38 | + .locator('.rspress-playground > .rspress-playground-runner > div') |
| 39 | + .getByText('Hello World External'); |
| 40 | + |
| 41 | + expect(playgroundElements.length).toBe(3); |
| 42 | + expect(await internalDemoCodePreviewDefault.count()).toBe(1); |
| 43 | + expect(await internalDemoCodePreviewVertical.count()).toBe(1); |
| 44 | + expect(await externalDemoCodePreview.count()).toBe(1); |
| 45 | + }); |
| 46 | +}); |
0 commit comments