summaryrefslogtreecommitdiff
path: root/docs/customization
AgeCommit message (Collapse)AuthorFilesLines
2026-01-23Migrate unit tests from Jest to VitestJason Westover1-11/+11
Replace Jest test runner with Vitest for native ES modules support and faster test execution. This migration aligns the test tooling with the Vite build system and eliminates CommonJS compatibility issues. Why Vitest over Jest? While Jest is a mature ecosystem with broader adoption (45.5k GitHub stars vs Vitest's 15.7k), Vitest is the recommended testing framework for Vue 3 + Vite projects: 1. **Native ESM Support**: Vitest runs tests directly as ESM without transformation, while Jest requires Babel/transformation layers that add complexity and slow down test execution. 2. **Vite Integration**: Shares the same configuration, plugins, and resolvers as the Vite build system. This eliminates the dual-config maintenance burden (vite.config.js + jest.config.js). 3. **Vue 3 Ecosystem Alignment**: Vitest is created by the Vue team and is the official recommendation in Vue 3 documentation. It has first-class Vue component testing support via @vue/test-utils. 4. **Performance**: Cold start is significantly faster due to Vite's on-demand compilation. HMR for tests provides instant feedback during test-driven development. 5. **API Compatibility**: Vitest intentionally matches Jest's API, making migration straightforward and allowing developers to leverage existing Jest knowledge. ESLint 9 Upgrade: - Upgrade ESLint from 8.57.1 to 9.18.0 - Migrate from .eslintrc.cjs to eslint.config.js (flat config) - Upgrade eslint-plugin-vue from 9.2.0 to 10.0.0 - Replace eslint-plugin-vitest with @vitest/eslint-plugin@1.1.43 - Replace @vue/eslint-config-prettier with eslint-config-prettier - Add globals package for flat config environment definitions - Update lint-staged from 13.0.3 to 16.0.0 - Update prettier from 3.2.5 to 3.4.2 - Disable stricter vue rules for follow-up PR: vue/no-reserved-component-names, vue/no-unused-components, vue/no-deprecated-delete-set, vue/no-required-prop-with-default Pre-commit Hooks: - Add simple-git-hooks and lint-staged for automatic linting - Run eslint --fix on JS/Vue files before commit - Run prettier --write on markdown files before commit - Add .prettierrc.yaml matching CI configuration - Include .cjs/.mjs files in prettier JS override Documentation: - Update unit testing guide for Vitest - Update coding standards with pre-commit hook details References: - Vitest official comparison: https://vitest.dev/guide/comparisons.html#jest - Vue 3 testing guide: https://vuejs.org/guide/scaling-up/testing.html#unit-testing - Vite ecosystem recommendations: https://vitejs.dev/guide/features.html#testing Test Results: - 19 test files, 123 tests passing - No warnings or deprecation messages - Test execution: ~3.1s (on par with Jest) Changes: - Replace jest.config.js with Vitest config in vite.config.js - Create tests/vitest.setup.js with Vitest-compatible mocks - Update package.json scripts for Vitest - Add vue3-snapshot-serializer for cleaner snapshots - Use happy-dom and real i18n instance for faster tests Dependency Updates: - Remove @vue/cli-plugin-unit-jest, @vue/vue3-jest, babel-jest, jest - Add vitest, @vitest/coverage-v8, jsdom, happy-dom, vue3-snapshot-serializer Test File Migrations: - Replace jest.fn() with vi.fn() - Replace jest.spyOn() with vi.spyOn() - Replace jest.mock() with vi.mock() - Replace jest.resetModules() with vi.resetModules() - Replace jest.unmock() with vi.unmock() - Replace require() with dynamic import() for ESM compatibility - Add explicit Vitest imports (vi, describe, it, expect, etc.) Snapshot Improvements: - Use vue3-snapshot-serializer to strip data-v-* scoped style attributes from snapshots for cleaner, more stable output - Add SVG component stubs for logo assets to avoid verbose path data in snapshots (logo-header.svg, login-company-logo.svg, built-on-openbmc-logo.svg) - Updated all snapshot files for Vitest format - Removed obsolete Jest snapshot entries Performance Optimizations: - Use happy-dom instead of jsdom (17% faster environment setup) - Use real i18n instance instead of mock (eliminates redundant dynamic imports, 55% faster test execution) Tested: - npm run test:unit runs 19 test files, 123 tests, and passed them all with 0 warnings. Change-Id: Iaf04335db54a5ceeff09bcd43675a488828dc44f Signed-off-by: Jason Westover <jwestover@nvidia.com>
2026-01-20Migrate build system from Vue-CLI to ViteJason Westover1-32/+35
"Vue CLI is in Maintenance Mode!" https://cli.vuejs.org/ Vite is created by Vue's creator and is the recommended build tool for Vue 3. It supports most of the configured conventions in Vue CLI. Dev Server startup is 60X faster and HMR is noticeably faster ~50ms. Better Tree-shaking support and modern ESM support. This migration preserves all existing functionality while eliminating Vue 2 legacy dependencies. Build Output Comparison (gzipped): Master (Webpack) Vite Delta CSS: 39 KB 45 KB +6 KB (+15%) JS: 505 KB 483 KB -22 KB (-4.4%) Total dist: 556 KB 544 KB -12 KB (-2.2%) Build time: ~29s ~7s ~4x faster Build System Changes: - Replace vue.config.js with vite.config.js - Remove babel.config.js (Vite uses esbuild) - Remove postcss.config.js (Vite handles PostCSS internally) - Add index.html to project root with ESM module entry point - Add custom Vite plugin for directory import resolution - Rename .eslintrc.js to .eslintrc.cjs (ESM compatibility) Dependency Updates: - Remove @vue/cli-* packages and webpack-related dependencies - Add vite, @vitejs/plugin-vue, @vitejs/plugin-basic-ssl - Add vite-svg-loader, vite-plugin-compression - Upgrade Bootstrap to 5.3.8 - Upgrade Sass to 1.97.2 (supports quietDeps option) - Upgrade xterm to @xterm/xterm v6 (new package name) - Upgrade xterm-addon-* to @xterm/addon-* packages - Upgrade vue-i18n to v11 - Upgrade eslint to 8.57.1 - Upgrade axios-cache-interceptor to latest Environment Variable Migration: - Change VUE_APP_* prefix to VITE_* (Vite convention) - Replace process.env with import.meta.env in source files - Update .env.ibm, .env.intel example files - Update documentation with new variable names ESM Module Compatibility: - Replace require('@/eventBus') with ESM imports (~23 files) - Ensure event bus listeners are registered/unregistered with stable handler references to prevent leaks - Replace require.context with import.meta.glob in i18n.js - Convert SVG inline loader to vite-svg-loader component imports SCSS/Sass Updates: - Remove tilde (~) prefix from node_modules imports - Add silenceDeprecations and quietDeps for Bootstrap warnings - Fix color() function syntax for Sass 2.0 compatibility xterm.js v6 Migration: - Update imports to @xterm/xterm, @xterm/addon-attach, @xterm/addon-fit - Replace deprecated setOption() with constructor options - Add CSS fix for helper textarea visibility Dev Server: - Configure HTTPS with @vitejs/plugin-basic-ssl - Preserve proxy configuration for BMC backend - Add WebSocket proxy auth token forwarding for /console, /kvm, /vm - Configure HMR on separate WebSocket path (/ws_hmr) X-Auth-Token Persistence (opt-in): - Add VITE_STORE_SESSION env flag for non-cookie auth backends - Persist X-Auth-Token to session cookie when enabled - Enables direct browser navigation to Redfish endpoints Follow-on: CI/testing updates (unit test runner + run-ci alignment) Some Jest config changes skipped here since this follow-on commit switches to Vitest. follow-up change is here: https://gerrit.openbmc.org/c/openbmc/webui-vue/+/86511 Tested: Sanity tested most navigational screens in the default UI, including many different types of API calls. Tested most build options. Tested the new i18n:report and it is working correctly. Change-Id: Ie84d1ed6121ffe7d2ddb379084d833b8d5a6fccf Signed-off-by: Jason Westover <jwestover@nvidia.com>
2025-12-02Document all the Vue App environmental settingsHariharan Rangasamy1-0/+19
List all the vue app/env flags and add oneline description Fixes https://github.com/openbmc/webui-vue/issues/75 Change-Id: I0133645297588784f6589b234ad8ac1e0814e782 Signed-off-by: Hariharan Rangasamy <hariharanr@ami.com>
2025-06-12markdownlint: fixesPatrick Williams1-27/+27
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I5d07d550b9c483de6c4d5f64570ea8336564297a
2022-12-08prettier: re-formatPatrick Williams3-91/+88
Prettier is enabled in openbmc-build-scripts on Markdown, JSON, and YAML files to have consistent formatting for these file types. Re-run the formatter on the whole repository. Change-Id: I2804ee3ab5ff6bcbf986b028db2fafec8e616779 Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
2021-06-09Update docs theme section to customizationDerick Montague3-0/+722
The themes section of the webui style guide contained a section named theme. This section also included information about the environmental builds. The name was misleading and confusing, so we determined in the GUI Design Work Group to update the section name. Signed-off-by: Derick Montague <derick.montague@ibm.com> Change-Id: Iad245199048f65f346e6c033a766605f303b0ade