-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(e2e): add case for api-docgen plugin
- Loading branch information
1 parent
5a2e7af
commit 111d401
Showing
8 changed files
with
117 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Hello World | ||
|
||
## API | ||
|
||
This is API Table | ||
|
||
<API moduleName="button" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "@rspress-fixture/rspress-api-docgen", | ||
"version": "1.0.0", | ||
"private": true, | ||
"scripts": { | ||
"dev": "rspress dev", | ||
"build": "rspress build", | ||
"preview": "rspress preview" | ||
}, | ||
"dependencies": { | ||
"@rspress/plugin-api-docgen": "workspace:*", | ||
"rspress": "workspace:*" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^14" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import path from 'path'; | ||
import { defineConfig } from 'rspress/config'; | ||
import { pluginApiDocgen } from '@rspress/plugin-api-docgen'; | ||
|
||
export default defineConfig({ | ||
root: path.join(__dirname, 'doc'), | ||
plugins: [ | ||
pluginApiDocgen({ | ||
entries: { | ||
button: './src/Button.ts', | ||
}, | ||
apiParseTool: 'react-docgen-typescript', | ||
}), | ||
], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export type ButtonProps = { | ||
/** | ||
* Whether to disable the button | ||
*/ | ||
disabled?: boolean; | ||
/** | ||
* Type of Button | ||
* @default 'default' | ||
*/ | ||
size?: 'mini' | 'small' | 'default' | 'large'; | ||
}; | ||
|
||
export const Button = (props?: ButtonProps) => {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { expect, test } from '@playwright/test'; | ||
import path from 'path'; | ||
import { getPort, killProcess, runDevCommand } from '../utils/runCommands'; | ||
|
||
const fixtureDir = path.resolve(__dirname, '../fixtures'); | ||
|
||
test.describe('api-docgen test', async () => { | ||
let appPort; | ||
let app; | ||
|
||
test.beforeAll(async () => { | ||
const appDir = path.join(fixtureDir, 'api-docgen'); | ||
appPort = await getPort(); | ||
app = await runDevCommand(appDir, appPort); | ||
}); | ||
|
||
test.afterAll(async () => { | ||
if (app) { | ||
await killProcess(app); | ||
} | ||
}); | ||
|
||
test('Index page', async ({ page }) => { | ||
await page.goto(`http://localhost:${appPort}`); | ||
const table = await page.$('table'); | ||
const tableContent = await page.evaluate(table => table?.innerHTML, table); | ||
|
||
// Property | ||
expect(tableContent).toContain('Property'); | ||
expect(tableContent).toContain('disabled'); | ||
expect(tableContent).toContain('size'); | ||
|
||
// Description | ||
expect(tableContent).toContain('Description'); | ||
expect(tableContent).toContain('Whether to disable the button'); | ||
expect(tableContent).toContain('Type of Button'); | ||
|
||
// Type | ||
expect(tableContent).toContain('Type'); | ||
expect(tableContent).toContain('boolean'); | ||
expect(tableContent).toContain('"mini" | "small" | "default" | "large"'); | ||
|
||
// Default Value | ||
expect(tableContent).toContain('Default Value'); | ||
expect(tableContent).toContain('-'); | ||
expect(tableContent).toContain("'default'"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.