Skip to content

Commit

Permalink
test(e2e): add vue-components cases
Browse files Browse the repository at this point in the history
  • Loading branch information
meteorlxy committed Sep 10, 2024
1 parent d776236 commit 0fe831f
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 1 deletion.
6 changes: 5 additions & 1 deletion e2e/docs/.vuepress/client.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { defineClientConfig } from 'vuepress/client'
import ComponentForMarkdownGlobal from './components/ComponentForMarkdownGlobal.vue'
import RootComponentFromUserConfig from './components/RootComponentFromUserConfig.vue'

// static imported styles file
import '@vuepress-e2e/style-exports/foo.css'

export default defineClientConfig({
async enhance() {
async enhance({ app }) {
// register global components
app.component('ComponentForMarkdownGlobal', ComponentForMarkdownGlobal)

// dynamic imported styles file
await import('@vuepress-e2e/style-exports')
},
Expand Down
5 changes: 5 additions & 0 deletions e2e/docs/.vuepress/components/ComponentForMarkdownGlobal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template>
<div class="component-for-markdown-global">
<p>component for markdown global</p>
</div>
</template>
5 changes: 5 additions & 0 deletions e2e/docs/.vuepress/components/ComponentForMarkdownImport.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template>
<div class="component-for-markdown-import">
<p>component for markdown import</p>
</div>
</template>
8 changes: 8 additions & 0 deletions e2e/docs/markdown/vue-components.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<ComponentForMarkdownGlobal />

<ComponentForMarkdownImport />

<script setup>
// TODO: relative path import?
import ComponentForMarkdownImport from '@source/.vuepress/components/ComponentForMarkdownImport.vue';
</script>
12 changes: 12 additions & 0 deletions e2e/tests/markdown/vue-components.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { expect, test } from '@playwright/test'

test('should render vue components correctly', async ({ page }) => {
await page.goto('markdown/vue-components.html')

await expect(page.locator('.component-for-markdown-global p')).toHaveText(
'component for markdown global',
)
await expect(page.locator('.component-for-markdown-import p')).toHaveText(
'component for markdown import',
)
})

0 comments on commit 0fe831f

Please sign in to comment.