diff --git a/commitlint.config.js b/commitlint.config.js index 813666b735..0022e44293 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -26,6 +26,7 @@ const scopes = [ 'color', 'border', 'var', + 'ssr', ] module.exports = { diff --git a/packages/components/affix/ssr/basic.vue b/packages/components/affix/ssr/basic.vue new file mode 100644 index 0000000000..c8a3c03616 --- /dev/null +++ b/packages/components/affix/ssr/basic.vue @@ -0,0 +1,5 @@ + + + Offset top 120px + + diff --git a/packages/components/alert/ssr/basic.vue b/packages/components/alert/ssr/basic.vue new file mode 100644 index 0000000000..497583e559 --- /dev/null +++ b/packages/components/alert/ssr/basic.vue @@ -0,0 +1,6 @@ + + + + + + diff --git a/packages/components/autocomplete/ssr/basic.vue b/packages/components/autocomplete/ssr/basic.vue new file mode 100644 index 0000000000..2630822669 --- /dev/null +++ b/packages/components/autocomplete/ssr/basic.vue @@ -0,0 +1,61 @@ + + + + + list suggestions when activated + + + + + + list suggestions on input + + + + + + + diff --git a/packages/components/avatar/ssr/basic.vue b/packages/components/avatar/ssr/basic.vue new file mode 100644 index 0000000000..caf0ab135a --- /dev/null +++ b/packages/components/avatar/ssr/basic.vue @@ -0,0 +1,33 @@ + + + + + + + + + + user + + + + + + + diff --git a/ssr-testing/demo.spec.puppeteer.tsx b/ssr-testing/demo.spec.puppeteer.tsx index 00af6110a1..aa1c1cd940 100644 --- a/ssr-testing/demo.spec.puppeteer.tsx +++ b/ssr-testing/demo.spec.puppeteer.tsx @@ -4,13 +4,13 @@ import { renderToString } from '@vue/server-renderer' import { beforeAll, describe, expect, it } from 'vitest' import puppeteer from 'puppeteer' import glob from 'fast-glob' -import ElementPlus from '../dist/element-plus' +import ElementPlus, { ID_INJECTION_KEY } from '../dist/element-plus' import type { Browser } from 'puppeteer' const projectRoot = process.cwd() const testRoot = `${projectRoot}/ssr-testing` -const exampleRoot = path.resolve(projectRoot, 'docs/examples') +const demoRoot = path.resolve(projectRoot, 'packages/components') describe('Cypress Button', () => { let browser: Browser beforeAll(async () => { @@ -18,10 +18,11 @@ describe('Cypress Button', () => { }) describe('when initialized', () => { - const demos = glob - .sync(`${projectRoot}/docs/examples/**/*.vue`) - .map((demo) => demo.slice(exampleRoot.length + 1)) - it.each(demos)(`render %s correctly`, async (demoPath) => { + const demoPaths = glob + .sync(`${demoRoot}/**/ssr/*.vue`) + .map((demo) => demo.slice(demoRoot.length + 1)) + + it.each(demoPaths)(`render %s correctly`, async (demoPath) => { const page = await browser.newPage() await page.goto(`file://${projectRoot}/ssr-testing/index.html`) await page.addStyleTag({ @@ -33,8 +34,13 @@ describe('Cypress Button', () => { 'index.css' ), }) - const { default: Demo } = await import(path.join(exampleRoot, demoPath)) - const app = createApp().use(ElementPlus) + const { default: Demo } = await import(path.join(demoRoot, demoPath)) + const app = createApp() + .use(ElementPlus) + .provide(ID_INJECTION_KEY, { + prefix: 100, + current: 0, + }) const html = await renderToString(app) await page.evaluate((innerHTML) => { diff --git a/ssr-testing/tsconfig.json b/ssr-testing/tsconfig.json index 5cc9e34230..cfecb9fae7 100644 --- a/ssr-testing/tsconfig.json +++ b/ssr-testing/tsconfig.json @@ -1,5 +1,6 @@ { "extends": "@vue/tsconfig/tsconfig.node.json", + "include": ["../packages/components/**/ssr/*.vue"], "compilerOptions": { "isolatedModules": false, "module": "esnext",