diff --git a/e2e/fixtures/github-alert/doc/index.mdx b/e2e/fixtures/github-alert-mdxjs/doc/index.mdx similarity index 99% rename from e2e/fixtures/github-alert/doc/index.mdx rename to e2e/fixtures/github-alert-mdxjs/doc/index.mdx index 9024bf0d7..a573779f2 100644 --- a/e2e/fixtures/github-alert/doc/index.mdx +++ b/e2e/fixtures/github-alert-mdxjs/doc/index.mdx @@ -38,7 +38,7 @@ > - List item 1 > - List item 2 -> + > > Nested blockquote -> + > ![Image Alt Text](https://github.com/web-infra-dev/rspress/assets/39261479/999e7946-45ff-45d5-b9cd-594e634e0e5a) diff --git a/e2e/fixtures/github-alert/package.json b/e2e/fixtures/github-alert-mdxjs/package.json similarity index 84% rename from e2e/fixtures/github-alert/package.json rename to e2e/fixtures/github-alert-mdxjs/package.json index be082d3c3..a95cc3bc6 100644 --- a/e2e/fixtures/github-alert/package.json +++ b/e2e/fixtures/github-alert-mdxjs/package.json @@ -1,5 +1,5 @@ { - "name": "@rspress-fixture/github-alert", + "name": "@rspress-fixture/github-alert-mdxjs", "version": "1.0.0", "private": true, "scripts": { diff --git a/e2e/fixtures/github-alert/rspress.config.ts b/e2e/fixtures/github-alert-mdxjs/rspress.config.ts similarity index 100% rename from e2e/fixtures/github-alert/rspress.config.ts rename to e2e/fixtures/github-alert-mdxjs/rspress.config.ts diff --git a/e2e/fixtures/github-alert/tsconfig.json b/e2e/fixtures/github-alert-mdxjs/tsconfig.json similarity index 100% rename from e2e/fixtures/github-alert/tsconfig.json rename to e2e/fixtures/github-alert-mdxjs/tsconfig.json diff --git a/e2e/tests/github-alert-mdxjs.test.ts b/e2e/tests/github-alert-mdxjs.test.ts new file mode 100644 index 000000000..5707a713f --- /dev/null +++ b/e2e/tests/github-alert-mdxjs.test.ts @@ -0,0 +1,49 @@ +import { expect, test } from '@playwright/test'; +import path from 'node:path'; +import { getPort, killProcess, runDevCommand } from '../utils/runCommands'; +import { getNavbar, getSidebar } from '../utils/getSideBar'; + +const fixtureDir = path.resolve(__dirname, '../fixtures'); + +test.describe('github alert syntax in mdx-js', async () => { + let appPort; + let app; + test.beforeAll(async () => { + const appDir = path.join(fixtureDir, 'github-alert-mdxjs'); + appPort = await getPort(); + app = await runDevCommand(appDir, appPort); + }); + + test.afterAll(async () => { + if (app) { + await killProcess(app); + } + }); + + test('should transform github alert syntax to contain syntax', async ({ + page, + }) => { + await page.goto(`http://localhost:${appPort}`); + + const directives = await page.$$( + '.rspress-doc > [class^="rspress-directive"]', + ); + expect(directives.length).toEqual(7); + + const containerTypes = await Promise.all( + directives.map(async directive => { + const className = await directive.getAttribute('class'); + return className?.split(' ')[1]; + }), + ); + expect(containerTypes).toEqual([ + 'tip', + 'note', + 'warning', + 'caution', + 'danger', + 'info', + 'details', + ]); + }); +}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8dcfb4dbe..4237525e1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -212,7 +212,7 @@ importers: specifier: ^18.11.17 version: 18.11.17 - e2e/fixtures/github-alert: + e2e/fixtures/github-alert-mdxjs: dependencies: rspress: specifier: workspace:*