-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: page crashes if Tabs has single Tab child (#972)
- Loading branch information
1 parent
a362096
commit 0e766da
Showing
6 changed files
with
111 additions
and
7 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,16 @@ | ||
import { Tabs, Tab } from 'rspress/theme'; | ||
|
||
# Hello World | ||
|
||
## Tab A | ||
|
||
<Tabs tabContainerClassName="tabs-a"> | ||
<Tab label="label1">content1</Tab> | ||
</Tabs> | ||
|
||
## Tab B | ||
|
||
<Tabs tabContainerClassName="tabs-b"> | ||
<Tab label="label2">content2</Tab> | ||
<Tab label="label3">content3</Tab> | ||
</Tabs> |
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,16 @@ | ||
{ | ||
"name": "@rspress-fixture/rspress-tabs-component", | ||
"version": "1.0.0", | ||
"private": true, | ||
"scripts": { | ||
"dev": "rspress dev", | ||
"build": "rspress build", | ||
"preview": "rspress preview" | ||
}, | ||
"dependencies": { | ||
"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,6 @@ | ||
import * as path from 'path'; | ||
import { defineConfig } from 'rspress/config'; | ||
|
||
export default defineConfig({ | ||
root: path.join(__dirname, 'doc'), | ||
}); |
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,42 @@ | ||
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('tabs-component test', async () => { | ||
let appPort; | ||
let app; | ||
|
||
test.beforeAll(async () => { | ||
const appDir = path.join(fixtureDir, 'tabs-component'); | ||
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}`); | ||
|
||
// Tab A | ||
const tabA = await page.$('.tabs-a'); | ||
const contentA = await page.$('.tabs-a + div'); | ||
const tabAText = await page.evaluate(node => node?.innerHTML, tabA); | ||
const contentAText = await page.evaluate(node => node?.innerHTML, contentA); | ||
expect(tabAText).toContain('label1'); | ||
expect(contentAText).toContain('content1'); | ||
|
||
// Tab B | ||
const tabB = await page.$('.tabs-b'); | ||
const contentB = await page.$('.tabs-b + div'); | ||
const tabBText = await page.evaluate(node => node?.innerHTML, tabB); | ||
const contentBText = await page.evaluate(node => node?.innerHTML, contentB); | ||
expect(tabBText).toContain('label2'); | ||
expect(contentBText).toContain('content2'); | ||
}); | ||
}); |
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.