-
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.
- Loading branch information
Showing
10 changed files
with
138 additions
and
13 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,21 @@ | ||
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> | ||
<Tab label="label4">content4</Tab> | ||
</Tabs> | ||
|
||
## Tab C | ||
|
||
<Tabs tabContainerClassName="tabs-c"></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,55 @@ | ||
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'); | ||
const notSelected = await page.$$eval( | ||
'.tabs-b div', | ||
divs => divs.filter(div => div.className.includes('not-selected')).length, | ||
); | ||
expect(notSelected).toEqual(2); | ||
|
||
// Tab C | ||
const tabC = await page.$('.tabs-c'); | ||
const contentC = await page.$('.tabs-c + div'); | ||
const tabCText = await page.evaluate(node => node?.innerHTML, tabC); | ||
const contentCText = await page.evaluate(node => node?.innerHTML, contentC); | ||
expect(tabCText).toEqual(''); | ||
expect(contentCText).toEqual(''); | ||
}); | ||
}); |
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
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
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.