-
Notifications
You must be signed in to change notification settings - Fork 2.9k
feat(web-components): enable DSD/SSR support and testing #36105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
radium-v
wants to merge
25
commits into
microsoft:master
Choose a base branch
from
radium-v:users/radium-v/wc-fast-test-harness
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
ea6d3f1
chore: update fast-element and add new dependencies in package.json
radium-v 5075a09
replace test harness with fast-test-harness
radium-v 826dd9e
set up test harness for DSD testing via fast-test-harness
radium-v 2154b37
update test imports to use fast-test-harness
radium-v 2596b7d
add accordion and accordion-item define-async modules and ensure test…
radium-v 5363eca
add anchor-button and link define-async modules and ensure tests run …
radium-v 17c248e
add avatar define-async module and ensure tests run in DSD mode
radium-v 08581a7
add badge define-async module and ensure tests run in DSD mode
radium-v 5b354f7
add define-async modules
radium-v f7a1236
move tree-item slot assignment to connectedCallback
radium-v 41d553d
refactor: replace $fastController.isConnected with elementInternals c…
radium-v 862c038
update compound-button template to be in sync with button template
radium-v 12cdb0e
fix entry-server stylesheet
radium-v 5331fe9
move slot population to connectedcallback
radium-v be867ed
refactor: clean up styles by removing redundant properties in dialog-…
radium-v 68aac51
fix flaky tests and clean up
radium-v 8599c8b
fix rebase
radium-v 1eac8a7
change files
radium-v 310efd6
export define-async modules
radium-v f6a0cea
update image source path in tests
radium-v 32cdb68
restore e2e script and ensure tokens stylesheet is generated before r…
radium-v 82befe0
call `fastPage.setTemplate()` in every test
radium-v 8d3fd9c
typo
radium-v f1d2da5
Add common initialization for CSR and SSR tests, update entry modules…
radium-v 6863ce7
remove unused const
radium-v File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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
7 changes: 7 additions & 0 deletions
7
change/@fluentui-chart-web-components-8ab5a04f-bd00-487d-a7d5-0cd8b395e1bb.json
This file contains hidden or 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 @@ | ||
| { | ||
| "type": "none", | ||
| "comment": "chore: remove unused @microsoft/fast-element devDependency", | ||
| "packageName": "@fluentui/chart-web-components", | ||
| "email": "863023+radium-v@users.noreply.github.com", | ||
| "dependentChangeType": "none" | ||
| } |
7 changes: 7 additions & 0 deletions
7
change/@fluentui-web-components-9e4886ef-09cc-426e-a4bf-b570d204e14b.json
This file contains hidden or 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 @@ | ||
| { | ||
| "type": "prerelease", | ||
| "comment": "feat: migrate test infrastructure to @microsoft/fast-test-harness with SSR/DSD support", | ||
| "packageName": "@fluentui/web-components", | ||
| "email": "863023+radium-v@users.noreply.github.com", | ||
| "dependentChangeType": "patch" | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| test-results/ | ||
| custom-elements.json | ||
| public/fluent-tokens.css |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,35 +1,10 @@ | ||
| import type { PlaywrightTestConfig } from '@playwright/test'; | ||
| import { devices } from '@playwright/test'; | ||
| import defaultConfig from '@microsoft/fast-test-harness/playwright.config.mjs'; | ||
| import { defineConfig } from '@playwright/test'; | ||
|
|
||
| const config: PlaywrightTestConfig = { | ||
| reporter: process.env.CI ? 'github' : 'list', | ||
| retries: 3, | ||
| fullyParallel: process.env.CI ? false : true, | ||
| timeout: process.env.CI ? 10000 : 30000, | ||
| use: { | ||
| baseURL: 'http://localhost:5173', | ||
| }, | ||
| projects: [ | ||
| { | ||
| name: 'chromium', | ||
| use: { ...devices['Desktop Chrome'] }, | ||
| }, | ||
| { | ||
| name: 'firefox', | ||
| use: { ...devices['Desktop Firefox'] }, | ||
| }, | ||
| { | ||
| name: 'webkit', | ||
| use: { ...devices['Desktop Safari'] }, | ||
| }, | ||
| ], | ||
| webServer: { | ||
| command: 'yarn vite preview test/harness', | ||
| port: 5173, | ||
| reuseExistingServer: true, | ||
| stderr: 'pipe', | ||
| stdout: 'pipe', | ||
| }, | ||
| }; | ||
| const CI = process.env.CI === 'true'; | ||
|
|
||
| export default config; | ||
| export default defineConfig({ | ||
| ...defaultConfig, | ||
| reporter: CI ? 'github' : 'list', | ||
| testMatch: 'src/**/*.spec.ts', | ||
| }); |
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,37 +1,56 @@ | ||
| import fs from 'node:fs'; | ||
| import path from 'node:path'; | ||
| /** | ||
| * Generates design token artifacts from @fluentui/tokens: | ||
| * | ||
| * 1. src/theme/design-tokens.ts — TypeScript constants mapping token | ||
| * names to CSS custom property var() references. | ||
| * | ||
| * 2. public/fluent-tokens.css — A plain CSS stylesheet with all token | ||
| * values under :root, for SSR/DSD testing where JS setTheme() isn't | ||
| * available. | ||
| */ | ||
|
|
||
| import chalk from 'chalk'; | ||
| import { mkdirSync, writeFileSync } from 'node:fs'; | ||
| import { join } from 'node:path'; | ||
|
|
||
| import tokensPackage from '@fluentui/tokens'; | ||
|
|
||
| main(); | ||
|
|
||
| function main() { | ||
| console.log(tokensPackage); | ||
| const { tokens, webLightTheme } = tokensPackage; | ||
| const tokenNames = Object.keys(tokens); | ||
| const rootDir = join(import.meta.dirname, '..'); | ||
|
|
||
| const fluentTokens = Object.keys(tokensPackage.tokens); | ||
| const comment = '// THIS FILE IS GENERATED AS PART OF THE BUILD PROCESS. DO NOT MANUALLY MODIFY THIS FILE\n'; | ||
| // ── 1. design-tokens.ts ───────────────────────────────────────────────── | ||
|
|
||
| const generatedTokens = fluentTokens.reduce((acc, t) => { | ||
| const token = ` | ||
| const tsContent = | ||
| '// THIS FILE IS GENERATED AS PART OF THE BUILD PROCESS. DO NOT MANUALLY MODIFY THIS FILE\n' + | ||
| tokenNames | ||
| .map( | ||
| t => | ||
| ` | ||
| /** | ||
| * CSS custom property value for the {@link @fluentui/tokens#${t} | \`${t}\`} design token. | ||
| * @public | ||
| */ | ||
| export const ${t} = 'var(--${t})'; | ||
| `; | ||
| return acc + token; | ||
| }, ''); | ||
|
|
||
| const dir = path.join(import.meta.dirname, '../src', 'theme'); | ||
|
|
||
| if (!fs.existsSync(dir)) { | ||
| fs.mkdirSync(dir, { recursive: true }); | ||
| } | ||
|
|
||
| fs.writeFile(path.join(dir, 'design-tokens.ts'), comment + generatedTokens, err => { | ||
| if (err) throw err; | ||
| console.log(chalk.greenBright(`Design token file has been successfully created!`)); | ||
| }); | ||
| } | ||
| export const ${t} = 'var(--${t})';`, | ||
| ) | ||
| .join('\n') + | ||
| '\n'; | ||
|
|
||
| const tsDir = join(rootDir, 'src', 'theme'); | ||
| mkdirSync(tsDir, { recursive: true }); | ||
| writeFileSync(join(tsDir, 'design-tokens.ts'), tsContent); | ||
| console.log(`✔ ${tokenNames.length} token constants → src/theme/design-tokens.ts`); | ||
|
|
||
| // ── 2. fluent-tokens.css ──────────────────────────────────────────────── | ||
|
|
||
| const cssContent = | ||
| '/* THIS FILE IS GENERATED AS PART OF THE BUILD PROCESS. DO NOT MANUALLY MODIFY THIS FILE */\n:root {\n' + | ||
| tokenNames | ||
| .filter(t => t in webLightTheme) | ||
| .map(t => ` --${t}: ${webLightTheme[t]};`) | ||
| .join('\n') + | ||
| '\n}\n'; | ||
|
|
||
| const cssDir = join(rootDir, 'public'); | ||
| mkdirSync(cssDir, { recursive: true }); | ||
| writeFileSync(join(cssDir, 'fluent-tokens.css'), cssContent); | ||
| console.log(`✔ ${tokenNames.length} token properties → public/fluent-tokens.css`); |
4 changes: 2 additions & 2 deletions
4
packages/web-components/src/accordion-item/accordion-item.spec.ts
This file contains hidden or 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 hidden or 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,8 @@ | ||
| import { RenderableFASTElement } from '@microsoft/fast-html'; | ||
| import { AccordionItem } from './accordion-item.js'; | ||
| import { tagName } from './accordion-item.options.js'; | ||
|
|
||
| RenderableFASTElement(AccordionItem).defineAsync({ | ||
| name: tagName, | ||
| templateOptions: 'defer-and-hydrate', | ||
| }); |
This file contains hidden or 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 hidden or 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,8 @@ | ||
| import { RenderableFASTElement } from '@microsoft/fast-html'; | ||
| import { Accordion } from './accordion.js'; | ||
| import { tagName } from './accordion.options.js'; | ||
|
|
||
| RenderableFASTElement(Accordion).defineAsync({ | ||
| name: tagName, | ||
| templateOptions: 'defer-and-hydrate', | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.