@qwickapps/react-framework 1.3.5 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1691 -2
- package/dist/__tests__/schemas/transformers/MockSerializableComponent.d.ts +66 -0
- package/dist/__tests__/schemas/transformers/MockSerializableComponent.d.ts.map +1 -0
- package/dist/components/ErrorBoundary.d.ts +7 -0
- package/dist/components/ErrorBoundary.d.ts.map +1 -1
- package/dist/components/Html.d.ts +28 -18
- package/dist/components/Html.d.ts.map +1 -1
- package/dist/components/Logo.d.ts +12 -35
- package/dist/components/Logo.d.ts.map +1 -1
- package/dist/components/Markdown.d.ts +18 -13
- package/dist/components/Markdown.d.ts.map +1 -1
- package/dist/components/QwickApp.d.ts +16 -3
- package/dist/components/QwickApp.d.ts.map +1 -1
- package/dist/components/QwickIcon.d.ts +23 -0
- package/dist/components/QwickIcon.d.ts.map +1 -0
- package/dist/components/SafeSpan.d.ts +12 -5
- package/dist/components/SafeSpan.d.ts.map +1 -1
- package/dist/components/Scaffold.d.ts.map +1 -1
- package/dist/components/base/ModelView.d.ts +101 -0
- package/dist/components/base/ModelView.d.ts.map +1 -0
- package/dist/components/base/index.d.ts +11 -0
- package/dist/components/base/index.d.ts.map +1 -0
- package/dist/components/blocks/Article.d.ts +12 -2
- package/dist/components/blocks/Article.d.ts.map +1 -1
- package/dist/components/blocks/Code.d.ts +13 -2
- package/dist/components/blocks/Code.d.ts.map +1 -1
- package/dist/components/blocks/CoverImageHeader.d.ts.map +1 -1
- package/dist/components/blocks/FeatureCard.d.ts.map +1 -1
- package/dist/components/blocks/FeatureGrid.d.ts.map +1 -1
- package/dist/components/blocks/Footer.d.ts.map +1 -1
- package/dist/components/blocks/HeroBlock.d.ts +27 -13
- package/dist/components/blocks/HeroBlock.d.ts.map +1 -1
- package/dist/components/blocks/Image.d.ts +41 -0
- package/dist/components/blocks/Image.d.ts.map +1 -0
- package/dist/components/blocks/PageBannerHeader.d.ts.map +1 -1
- package/dist/components/blocks/Section.d.ts +16 -2
- package/dist/components/blocks/Section.d.ts.map +1 -1
- package/dist/components/blocks/Text.d.ts +41 -0
- package/dist/components/blocks/Text.d.ts.map +1 -0
- package/dist/components/blocks/index.d.ts +4 -0
- package/dist/components/blocks/index.d.ts.map +1 -1
- package/dist/components/buttons/Button.d.ts +23 -7
- package/dist/components/buttons/Button.d.ts.map +1 -1
- package/dist/components/forms/FormBlock.d.ts +19 -13
- package/dist/components/forms/FormBlock.d.ts.map +1 -1
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/input/ChoiceInputField.d.ts +17 -11
- package/dist/components/input/ChoiceInputField.d.ts.map +1 -1
- package/dist/components/input/HtmlInputField.d.ts +17 -11
- package/dist/components/input/HtmlInputField.d.ts.map +1 -1
- package/dist/components/input/SelectInputField.d.ts +16 -10
- package/dist/components/input/SelectInputField.d.ts.map +1 -1
- package/dist/components/input/SwitchInputField.d.ts +16 -10
- package/dist/components/input/SwitchInputField.d.ts.map +1 -1
- package/dist/components/input/TextField.d.ts.map +1 -1
- package/dist/components/input/TextInputField.d.ts +16 -11
- package/dist/components/input/TextInputField.d.ts.map +1 -1
- package/dist/components/layout/GridCell.d.ts +23 -6
- package/dist/components/layout/GridCell.d.ts.map +1 -1
- package/dist/components/layout/GridLayout.d.ts +24 -23
- package/dist/components/layout/GridLayout.d.ts.map +1 -1
- package/dist/components/pages/FormPage.d.ts.map +1 -1
- package/dist/components/pages/Page.d.ts +49 -87
- package/dist/components/pages/Page.d.ts.map +1 -1
- package/dist/components/pages/index.d.ts +2 -2
- package/dist/components/pages/index.d.ts.map +1 -1
- package/dist/config/AppConfig.d.ts +49 -0
- package/dist/config/AppConfig.d.ts.map +1 -0
- package/dist/config/AppConfigBuilder.d.ts +75 -0
- package/dist/config/AppConfigBuilder.d.ts.map +1 -0
- package/dist/config/index.d.ts +13 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/types.d.ts +130 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config.d.ts +15 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.esm.js +451 -0
- package/dist/config.js +455 -0
- package/dist/contexts/PrintModeContext.d.ts +27 -0
- package/dist/contexts/PrintModeContext.d.ts.map +1 -0
- package/dist/contexts/QwickAppContext.d.ts +2 -2
- package/dist/contexts/QwickAppContext.d.ts.map +1 -1
- package/dist/contexts/index.d.ts +2 -0
- package/dist/contexts/index.d.ts.map +1 -1
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/usePrintMode.d.ts +39 -0
- package/dist/hooks/usePrintMode.d.ts.map +1 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.css +1 -1
- package/dist/index.esm.js +10951 -6238
- package/dist/index.js +11014 -6287
- package/dist/schemas/CodeSchema.d.ts +2 -1
- package/dist/schemas/CodeSchema.d.ts.map +1 -1
- package/dist/schemas/CollapsibleLayoutSchema.d.ts +2 -1
- package/dist/schemas/CollapsibleLayoutSchema.d.ts.map +1 -1
- package/dist/schemas/ContentSchema.d.ts +2 -1
- package/dist/schemas/ContentSchema.d.ts.map +1 -1
- package/dist/schemas/GridCellSchema.d.ts +25 -0
- package/dist/schemas/GridCellSchema.d.ts.map +1 -0
- package/dist/schemas/GridLayoutSchema.d.ts +23 -0
- package/dist/schemas/GridLayoutSchema.d.ts.map +1 -0
- package/dist/schemas/HtmlSchema.d.ts +14 -0
- package/dist/schemas/HtmlSchema.d.ts.map +1 -0
- package/dist/schemas/ImageSchema.d.ts +32 -0
- package/dist/schemas/ImageSchema.d.ts.map +1 -0
- package/dist/schemas/LogoSchema.d.ts +35 -0
- package/dist/schemas/LogoSchema.d.ts.map +1 -0
- package/dist/schemas/MarkdownSchema.d.ts +14 -0
- package/dist/schemas/MarkdownSchema.d.ts.map +1 -0
- package/dist/schemas/PageTemplateSchema.d.ts +31 -0
- package/dist/schemas/PageTemplateSchema.d.ts.map +1 -0
- package/dist/schemas/PrintConfigSchema.d.ts +31 -0
- package/dist/schemas/PrintConfigSchema.d.ts.map +1 -0
- package/dist/schemas/SectionSchema.d.ts +2 -1
- package/dist/schemas/SectionSchema.d.ts.map +1 -1
- package/dist/schemas/TextSchema.d.ts +37 -0
- package/dist/schemas/TextSchema.d.ts.map +1 -0
- package/dist/schemas/ViewModelSchema.d.ts +23 -0
- package/dist/schemas/ViewModelSchema.d.ts.map +1 -0
- package/dist/schemas/index.d.ts +15 -1
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/transformers/ComponentTransformer.d.ts +116 -0
- package/dist/schemas/transformers/ComponentTransformer.d.ts.map +1 -0
- package/dist/schemas/transformers/ReactNodeTransformer.d.ts +53 -0
- package/dist/schemas/transformers/ReactNodeTransformer.d.ts.map +1 -0
- package/dist/schemas/transformers/__tests__/MockSerializableComponent.d.ts +66 -0
- package/dist/schemas/transformers/__tests__/MockSerializableComponent.d.ts.map +1 -0
- package/dist/schemas/transformers/registry.d.ts +15 -0
- package/dist/schemas/transformers/registry.d.ts.map +1 -0
- package/dist/schemas/types/Serializable.d.ts +46 -0
- package/dist/schemas/types/Serializable.d.ts.map +1 -0
- package/dist/utils/htmlTransform.d.ts.map +1 -1
- package/dist/utils/reactUtils.d.ts +12 -3
- package/dist/utils/reactUtils.d.ts.map +1 -1
- package/package.json +17 -3
- package/src/{components/__tests__ → __tests__/components}/AccessibilityProvider.test.tsx +1 -1
- package/src/{components/__tests__ → __tests__/components}/Article.test.tsx +1 -1
- package/src/{components/__tests__ → __tests__/components}/Breadcrumbs.test.tsx +1 -1
- package/src/{components/__tests__ → __tests__/components}/Button.test.tsx +1 -1
- package/src/{components/__tests__ → __tests__/components}/CardListGrid.test.tsx +2 -2
- package/src/{components/__tests__ → __tests__/components}/ChoiceInputField.test.tsx +1 -1
- package/src/{components/__tests__ → __tests__/components}/Code.test.tsx +1 -1
- package/src/{components/__tests__ → __tests__/components}/Content.integration.test.tsx +1 -1
- package/src/{components/__tests__ → __tests__/components}/Content.test.tsx +1 -1
- package/src/{components/__tests__ → __tests__/components}/CoverImageHeader.test.tsx +2 -2
- package/src/{components/__tests__ → __tests__/components}/ErrorBoundary.test.tsx +1 -1
- package/src/{components/__tests__ → __tests__/components}/FeatureCard.integration.test.tsx +2 -2
- package/src/{components/__tests__ → __tests__/components}/FeatureGrid.integration.test.tsx +2 -2
- package/src/{components/__tests__ → __tests__/components}/FeatureGrid.test.tsx +2 -2
- package/src/{components/__tests__ → __tests__/components}/Footer.test.tsx +4 -4
- package/src/{components/__tests__ → __tests__/components}/FormBlock.test.tsx +1 -1
- package/src/{components/__tests__ → __tests__/components}/HeroBlock.integration.test.tsx +2 -2
- package/src/{components/__tests__ → __tests__/components}/HeroBlock.test.tsx +233 -7
- package/src/{components/__tests__ → __tests__/components}/Html.test.tsx +11 -2
- package/src/{components/__tests__ → __tests__/components}/HtmlInputField.test.tsx +3 -3
- package/src/__tests__/components/Logo.test.js +3 -3
- package/src/{components/__tests__ → __tests__/components}/Markdown.test.tsx +1 -1
- package/src/{components/__tests__ → __tests__/components}/PageBannerHeader.test.tsx +3 -3
- package/src/{components/__tests__ → __tests__/components}/PaletteSwitcher.test.tsx +3 -3
- package/src/{components/__tests__ → __tests__/components}/ProductCard.test.tsx +4 -4
- package/src/{components/__tests__ → __tests__/components}/SafeSpan.integration.test.tsx +2 -2
- package/src/{components/__tests__ → __tests__/components}/SafeSpan.simple.test.tsx +1 -1
- package/src/{components/__tests__ → __tests__/components}/SafeSpan.test.tsx +1 -1
- package/src/{components/__tests__ → __tests__/components}/Section.integration.test.tsx +1 -1
- package/src/{components/__tests__ → __tests__/components}/Section.test.tsx +1 -1
- package/src/{components/__tests__ → __tests__/components}/SelectInputField.test.tsx +1 -1
- package/src/{components/__tests__ → __tests__/components}/TextInputField.test.tsx +3 -3
- package/src/{components/__tests__ → __tests__/components}/ThemeSwitcher.test.tsx +3 -3
- package/src/__tests__/components/base/ModelView.test.tsx +220 -0
- package/src/__tests__/components/blocks/Code.performance.test.tsx +625 -0
- package/src/__tests__/components/blocks/Code.serialization.test.tsx +507 -0
- package/src/__tests__/components/blocks/HeroBlock.serialization.test.tsx +414 -0
- package/src/__tests__/components/blocks/Image.serialization.test.tsx +257 -0
- package/src/__tests__/components/blocks/Section.serialization.test.tsx +553 -0
- package/src/__tests__/components/blocks/Text.performance.test.tsx +442 -0
- package/src/__tests__/components/blocks/Text.serialization.test.tsx +491 -0
- package/src/__tests__/components/buttons/Button.serialization.test.tsx +443 -0
- package/src/__tests__/components/input/FormComponents.serialization.test.tsx +482 -0
- package/src/__tests__/components/input/SelectInputField.serialization.test.tsx +439 -0
- package/src/__tests__/components/input/TextInputField.serialization.test.tsx +359 -0
- package/src/{components/layout/CollapsibleLayout/__tests__ → __tests__/components/layout}/CollapsibleLayout.test.tsx +4 -4
- package/src/__tests__/components/layout/GridCell.serialization.test.tsx +403 -0
- package/src/__tests__/components/layout/GridLayout.serialization.test.tsx +311 -0
- package/src/__tests__/hooks/usePrintMode.test.ts +89 -0
- package/src/__tests__/schemas/PageTemplateSchema.test.ts +161 -0
- package/src/__tests__/schemas/PrintConfigSchema.test.ts +127 -0
- package/src/__tests__/schemas/ViewModelSchema.test.ts +80 -0
- package/src/__tests__/schemas/transformers/ComponentSerializationPatterns.test.tsx +602 -0
- package/src/__tests__/schemas/transformers/ComponentTransformer.htmlPatterns.test.ts +301 -0
- package/src/__tests__/schemas/transformers/ComponentTransformer.test.ts +521 -0
- package/src/__tests__/schemas/transformers/CrossBrowserCompatibility.test.ts +586 -0
- package/src/__tests__/schemas/transformers/MockSerializableComponent.ts +103 -0
- package/src/__tests__/schemas/transformers/RealWorldScenarios.test.tsx +1165 -0
- package/src/__tests__/schemas/transformers/SerializationErrorHandling.test.ts +602 -0
- package/src/__tests__/schemas/transformers/SerializationIntegration.test.tsx +691 -0
- package/src/__tests__/schemas/transformers/SerializationPerformance.test.ts +460 -0
- package/src/__tests__/schemas/transformers/TestAutomation.test.ts +597 -0
- package/src/{utils/__tests__ → __tests__/utils}/nested-dom-fix.test.tsx +1 -1
- package/src/components/ErrorBoundary.tsx +8 -8
- package/src/components/Html.tsx +147 -44
- package/src/components/Logo.tsx +198 -100
- package/src/components/Markdown.tsx +125 -16
- package/src/components/QwickApp.tsx +64 -31
- package/src/components/QwickIcon.tsx +59 -0
- package/src/components/SafeSpan.tsx +65 -10
- package/src/components/Scaffold.tsx +2 -8
- package/src/components/base/ModelView.tsx +199 -0
- package/src/components/base/index.ts +11 -0
- package/src/components/blocks/Article.tsx +57 -18
- package/src/components/blocks/Code.md +529 -0
- package/src/components/blocks/Code.tsx +102 -15
- package/src/components/blocks/CoverImageHeader.tsx +9 -4
- package/src/components/blocks/FeatureCard.tsx +1 -2
- package/src/components/blocks/FeatureGrid.tsx +19 -1
- package/src/components/blocks/Footer.tsx +13 -1
- package/src/components/blocks/HeroBlock.tsx +87 -20
- package/src/components/blocks/Image.tsx +395 -0
- package/src/components/blocks/PageBannerHeader.tsx +14 -12
- package/src/components/blocks/ProductCard.tsx +1 -1
- package/src/components/blocks/Section.tsx +113 -8
- package/src/components/blocks/Text.tsx +285 -0
- package/src/components/blocks/index.ts +4 -0
- package/src/components/buttons/Button.tsx +184 -15
- package/src/components/forms/FormBlock.tsx +70 -17
- package/src/components/index.ts +5 -0
- package/src/components/input/ChoiceInputField.tsx +48 -18
- package/src/components/input/HtmlInputField.tsx +48 -18
- package/src/components/input/SelectInputField.tsx +48 -16
- package/src/components/input/SwitchInputField.tsx +48 -17
- package/src/components/input/TextField.tsx +41 -1
- package/src/components/input/TextInputField.tsx +52 -18
- package/src/components/layout/GridCell.tsx +118 -9
- package/src/components/layout/GridLayout.tsx +125 -24
- package/src/components/pages/FormPage.tsx +0 -1
- package/src/components/pages/Page.css +304 -332
- package/src/components/pages/Page.tsx +307 -255
- package/src/components/pages/index.ts +2 -2
- package/src/config/AppConfig.ts +133 -0
- package/src/config/AppConfigBuilder.ts +421 -0
- package/src/config/__tests__/AppConfig.test.ts +385 -0
- package/src/config/__tests__/AppConfigBuilder.test.ts +432 -0
- package/src/config/index.ts +24 -0
- package/src/config/types.ts +170 -0
- package/src/config.ts +25 -0
- package/src/contexts/PrintModeContext.tsx +332 -0
- package/src/contexts/QwickAppContext.tsx +2 -2
- package/src/contexts/index.ts +2 -0
- package/src/hooks/index.ts +5 -1
- package/src/hooks/usePrintMode.ts +73 -0
- package/src/index.ts +3 -0
- package/src/schemas/CodeSchema.ts +3 -3
- package/src/schemas/CollapsibleLayoutSchema.ts +2 -1
- package/src/schemas/ContentSchema.ts +2 -1
- package/src/schemas/GridCellSchema.ts +164 -0
- package/src/schemas/GridLayoutSchema.ts +133 -0
- package/src/schemas/HtmlSchema.ts +47 -0
- package/src/schemas/ImageSchema.ts +235 -0
- package/src/schemas/LogoSchema.ts +241 -0
- package/src/schemas/MarkdownSchema.ts +47 -0
- package/src/schemas/PageTemplateSchema.ts +186 -0
- package/src/schemas/PrintConfigSchema.ts +207 -0
- package/src/schemas/README.md +661 -0
- package/src/schemas/SectionSchema.ts +2 -1
- package/src/schemas/TextSchema.ts +329 -0
- package/src/schemas/ViewModelSchema.ts +115 -0
- package/src/schemas/index.ts +21 -2
- package/src/schemas/transformers/ComponentTransformer.ts +403 -0
- package/src/schemas/transformers/ReactNodeTransformer.ts +236 -0
- package/src/schemas/transformers/registry.ts +72 -0
- package/src/schemas/types/Serializable.ts +51 -0
- package/src/stories/AccessibilityProvider.stories.tsx +253 -253
- package/src/stories/Article.stories.tsx +433 -433
- package/src/stories/Button.stories.tsx +1 -1
- package/src/stories/CardListGrid.stories.tsx +451 -451
- package/src/stories/ChoiceInputField.stories.tsx +503 -503
- package/src/stories/Code.stories.tsx +1 -1
- package/src/stories/CollapsibleLayout.stories.tsx +1414 -1414
- package/src/stories/Content.stories.tsx +393 -393
- package/src/stories/CoverImageHeader.stories.tsx +701 -701
- package/src/stories/DataBinding.advanced.stories.tsx +432 -432
- package/src/stories/DataProvider.stories.tsx +1192 -1192
- package/src/stories/FeatureCard.stories.tsx +557 -557
- package/src/stories/FeatureGrid.stories.tsx +594 -594
- package/src/stories/Footer.stories.tsx +640 -640
- package/src/stories/FormBlock.stories.tsx +760 -760
- package/src/stories/FormComponents.stories.tsx +349 -541
- package/src/stories/GridCell.stories.tsx +417 -0
- package/src/stories/GridLayout.stories.tsx +353 -0
- package/src/stories/HeroBlock.stories.tsx +862 -373
- package/src/stories/HtmlInputField.stories.tsx +474 -474
- package/src/stories/Image.stories.tsx +819 -0
- package/src/stories/Introduction.stories.tsx +667 -667
- package/src/stories/LayoutBlocks.stories.tsx +324 -324
- package/src/stories/Logo.stories.tsx +165 -6
- package/src/stories/Markdown.stories.tsx +137 -137
- package/src/stories/ModelView.stories.tsx +477 -0
- package/src/stories/Page.stories.tsx +688 -688
- package/src/stories/PageBannerHeader.stories.tsx +864 -864
- package/src/stories/PaletteSwitcher.stories.tsx +119 -119
- package/src/stories/ProductCard.stories.tsx +424 -424
- package/src/stories/QwickApp.stories.tsx +368 -368
- package/src/stories/ResponsiveMenu.stories.tsx +249 -249
- package/src/stories/SafeSpan.stories.tsx +531 -531
- package/src/stories/Section.stories.tsx +90 -2
- package/src/stories/SelectInputField.stories.tsx +524 -524
- package/src/stories/Text.stories.tsx +560 -0
- package/src/stories/TextInputField.stories.tsx +443 -443
- package/src/stories/ThemeSwitcher.stories.tsx +123 -123
- package/src/utils/htmlTransform.tsx +74 -53
- package/src/utils/reactUtils.tsx +57 -6
- package/dist/index.bundled.css +0 -12
- /package/src/{hooks/__tests__ → __tests__/hooks}/useDataBinding.test.tsx.disabled +0 -0
- /package/src/{schemas/__tests__ → __tests__/schemas}/builders.test.ts +0 -0
- /package/src/{utils/__tests__ → __tests__/utils}/createDataDrivenComponent.test.tsx.disabled +0 -0
- /package/src/{utils/__tests__ → __tests__/utils}/htmlTransform.test.tsx +0 -0
- /package/src/{utils/__tests__ → __tests__/utils}/optional-logging.test.ts +0 -0
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AppConfig Tests
|
|
3
|
+
*
|
|
4
|
+
* Test suite for the AppConfig class.
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2025 QwickApps.com. All rights reserved.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { AppConfig } from '../AppConfig';
|
|
10
|
+
import type { AppIdentity, BuildConfig, PWAConfig, UIConfig, CopyrightConfig } from '../types';
|
|
11
|
+
|
|
12
|
+
describe('AppConfig', () => {
|
|
13
|
+
const mockAppIdentity: AppIdentity = {
|
|
14
|
+
id: 'test-app',
|
|
15
|
+
name: 'Test Application',
|
|
16
|
+
shortName: 'Test App',
|
|
17
|
+
description: 'A test application',
|
|
18
|
+
version: '1.0.0',
|
|
19
|
+
logo: '/test-logo.svg',
|
|
20
|
+
author: 'Test Author',
|
|
21
|
+
homepage: 'https://test.com',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const mockBuildConfig: BuildConfig = {
|
|
25
|
+
port: 3000,
|
|
26
|
+
previewPort: 4173,
|
|
27
|
+
outputDir: 'dist',
|
|
28
|
+
publicPath: '/',
|
|
29
|
+
base: '/',
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const mockPWAConfig: PWAConfig = {
|
|
33
|
+
themeColor: '#2196f3',
|
|
34
|
+
backgroundColor: '#ffffff',
|
|
35
|
+
startUrl: '/',
|
|
36
|
+
scope: '/',
|
|
37
|
+
display: 'standalone',
|
|
38
|
+
orientation: 'portrait',
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const mockUIConfig: UIConfig = {
|
|
42
|
+
defaultTheme: 'light',
|
|
43
|
+
defaultPalette: 'default',
|
|
44
|
+
enableScaffolding: true,
|
|
45
|
+
showThemeSwitcher: false,
|
|
46
|
+
showPaletteSwitcher: false,
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const mockCopyrightConfig: CopyrightConfig = {
|
|
50
|
+
year: 2025,
|
|
51
|
+
author: 'Test Author',
|
|
52
|
+
text: 'All rights reserved.',
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
describe('Constructor', () => {
|
|
56
|
+
it('should create an AppConfig instance with provided configuration', () => {
|
|
57
|
+
const config = new AppConfig({
|
|
58
|
+
app: mockAppIdentity,
|
|
59
|
+
build: mockBuildConfig,
|
|
60
|
+
pwa: mockPWAConfig,
|
|
61
|
+
ui: mockUIConfig,
|
|
62
|
+
copyright: mockCopyrightConfig,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
expect(config.app).toEqual(mockAppIdentity);
|
|
66
|
+
expect(config.build).toEqual(mockBuildConfig);
|
|
67
|
+
expect(config.pwa).toEqual(mockPWAConfig);
|
|
68
|
+
expect(config.ui).toEqual(mockUIConfig);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('should create immutable configuration sections', () => {
|
|
72
|
+
const config = new AppConfig({
|
|
73
|
+
app: mockAppIdentity,
|
|
74
|
+
build: mockBuildConfig,
|
|
75
|
+
pwa: mockPWAConfig,
|
|
76
|
+
ui: mockUIConfig,
|
|
77
|
+
copyright: mockCopyrightConfig,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// Attempt to modify should fail
|
|
81
|
+
expect(() => {
|
|
82
|
+
(config.app as any).name = 'Modified Name';
|
|
83
|
+
}).toThrow();
|
|
84
|
+
|
|
85
|
+
expect(() => {
|
|
86
|
+
(config.build as any).port = 4000;
|
|
87
|
+
}).toThrow();
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
describe('Vite Configuration', () => {
|
|
92
|
+
it('should generate correct vite configuration', () => {
|
|
93
|
+
const config = new AppConfig({
|
|
94
|
+
app: mockAppIdentity,
|
|
95
|
+
build: mockBuildConfig,
|
|
96
|
+
pwa: mockPWAConfig,
|
|
97
|
+
ui: mockUIConfig,
|
|
98
|
+
copyright: mockCopyrightConfig,
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
const viteConfig = config.viteConfig;
|
|
102
|
+
|
|
103
|
+
expect(viteConfig.server?.port).toBe(3000);
|
|
104
|
+
expect(viteConfig.server?.host).toBe(true);
|
|
105
|
+
expect(viteConfig.preview?.port).toBe(4173);
|
|
106
|
+
expect(viteConfig.preview?.host).toBe(true);
|
|
107
|
+
expect(viteConfig.build?.outDir).toBe('dist');
|
|
108
|
+
expect(viteConfig.base).toBe('/');
|
|
109
|
+
expect(viteConfig.publicDir).toBe('public');
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('should include app-specific defines', () => {
|
|
113
|
+
const config = new AppConfig({
|
|
114
|
+
app: mockAppIdentity,
|
|
115
|
+
build: mockBuildConfig,
|
|
116
|
+
pwa: mockPWAConfig,
|
|
117
|
+
ui: mockUIConfig,
|
|
118
|
+
copyright: mockCopyrightConfig,
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
const viteConfig = config.viteConfig;
|
|
122
|
+
|
|
123
|
+
expect(viteConfig.define?.__APP_NAME__).toBe('"Test Application"');
|
|
124
|
+
expect(viteConfig.define?.__APP_ID__).toBe('"test-app"');
|
|
125
|
+
expect(viteConfig.define?.__APP_VERSION__).toBe('"1.0.0"');
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('should handle custom build configuration', () => {
|
|
129
|
+
const customBuildConfig: BuildConfig = {
|
|
130
|
+
port: 8080,
|
|
131
|
+
previewPort: 8081,
|
|
132
|
+
outputDir: 'build',
|
|
133
|
+
publicPath: '/static/',
|
|
134
|
+
base: '/app/',
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const config = new AppConfig({
|
|
138
|
+
app: mockAppIdentity,
|
|
139
|
+
build: customBuildConfig,
|
|
140
|
+
pwa: mockPWAConfig,
|
|
141
|
+
ui: mockUIConfig,
|
|
142
|
+
copyright: mockCopyrightConfig,
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
const viteConfig = config.viteConfig;
|
|
146
|
+
|
|
147
|
+
expect(viteConfig.server?.port).toBe(8080);
|
|
148
|
+
expect(viteConfig.preview?.port).toBe(8081);
|
|
149
|
+
expect(viteConfig.build?.outDir).toBe('build');
|
|
150
|
+
expect(viteConfig.base).toBe('/app/');
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
describe('PWA Manifest', () => {
|
|
155
|
+
it('should generate correct PWA manifest', () => {
|
|
156
|
+
const config = new AppConfig({
|
|
157
|
+
app: mockAppIdentity,
|
|
158
|
+
build: mockBuildConfig,
|
|
159
|
+
pwa: mockPWAConfig,
|
|
160
|
+
ui: mockUIConfig,
|
|
161
|
+
copyright: mockCopyrightConfig,
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
const manifest = config.pwaManifest;
|
|
165
|
+
|
|
166
|
+
expect(manifest.name).toBe('Test Application');
|
|
167
|
+
expect(manifest.short_name).toBe('Test App');
|
|
168
|
+
expect(manifest.description).toBe('A test application');
|
|
169
|
+
expect(manifest.start_url).toBe('/');
|
|
170
|
+
expect(manifest.display).toBe('standalone');
|
|
171
|
+
expect(manifest.orientation).toBe('portrait');
|
|
172
|
+
expect(manifest.theme_color).toBe('#2196f3');
|
|
173
|
+
expect(manifest.background_color).toBe('#ffffff');
|
|
174
|
+
expect(manifest.scope).toBe('/');
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it('should include default PWA icons', () => {
|
|
178
|
+
const config = new AppConfig({
|
|
179
|
+
app: mockAppIdentity,
|
|
180
|
+
build: mockBuildConfig,
|
|
181
|
+
pwa: mockPWAConfig,
|
|
182
|
+
ui: mockUIConfig,
|
|
183
|
+
copyright: mockCopyrightConfig,
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
const manifest = config.pwaManifest;
|
|
187
|
+
|
|
188
|
+
expect(manifest.icons).toHaveLength(2);
|
|
189
|
+
expect(manifest.icons[0]).toEqual({
|
|
190
|
+
src: 'pwa-192x192.png',
|
|
191
|
+
sizes: '192x192',
|
|
192
|
+
type: 'image/png',
|
|
193
|
+
});
|
|
194
|
+
expect(manifest.icons[1]).toEqual({
|
|
195
|
+
src: 'pwa-512x512.png',
|
|
196
|
+
sizes: '512x512',
|
|
197
|
+
type: 'image/png',
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
it('should handle different PWA display modes', () => {
|
|
202
|
+
const fullscreenPWAConfig: PWAConfig = {
|
|
203
|
+
...mockPWAConfig,
|
|
204
|
+
display: 'fullscreen',
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
const config = new AppConfig({
|
|
208
|
+
app: mockAppIdentity,
|
|
209
|
+
build: mockBuildConfig,
|
|
210
|
+
pwa: fullscreenPWAConfig,
|
|
211
|
+
ui: mockUIConfig,
|
|
212
|
+
copyright: mockCopyrightConfig,
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
const manifest = config.pwaManifest;
|
|
216
|
+
expect(manifest.display).toBe('fullscreen');
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
describe('JSON Serialization', () => {
|
|
221
|
+
it('should serialize to JSON correctly', () => {
|
|
222
|
+
const config = new AppConfig({
|
|
223
|
+
app: mockAppIdentity,
|
|
224
|
+
build: mockBuildConfig,
|
|
225
|
+
pwa: mockPWAConfig,
|
|
226
|
+
ui: mockUIConfig,
|
|
227
|
+
copyright: mockCopyrightConfig,
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
const json = config.toJSON();
|
|
231
|
+
|
|
232
|
+
expect(json).toEqual({
|
|
233
|
+
app: mockAppIdentity,
|
|
234
|
+
build: mockBuildConfig,
|
|
235
|
+
pwa: mockPWAConfig,
|
|
236
|
+
ui: mockUIConfig,
|
|
237
|
+
copyright: mockCopyrightConfig,
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
it('should be JSON.stringify compatible', () => {
|
|
242
|
+
const config = new AppConfig({
|
|
243
|
+
app: mockAppIdentity,
|
|
244
|
+
build: mockBuildConfig,
|
|
245
|
+
pwa: mockPWAConfig,
|
|
246
|
+
ui: mockUIConfig,
|
|
247
|
+
copyright: mockCopyrightConfig,
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
const jsonString = JSON.stringify(config);
|
|
251
|
+
const parsed = JSON.parse(jsonString);
|
|
252
|
+
|
|
253
|
+
expect(parsed.app).toEqual(mockAppIdentity);
|
|
254
|
+
expect(parsed.build).toEqual(mockBuildConfig);
|
|
255
|
+
expect(parsed.pwa).toEqual(mockPWAConfig);
|
|
256
|
+
expect(parsed.ui).toEqual(mockUIConfig);
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
describe('Configuration Override', () => {
|
|
261
|
+
it('should create new instance with overrides', () => {
|
|
262
|
+
const originalConfig = new AppConfig({
|
|
263
|
+
app: mockAppIdentity,
|
|
264
|
+
build: mockBuildConfig,
|
|
265
|
+
pwa: mockPWAConfig,
|
|
266
|
+
ui: mockUIConfig,
|
|
267
|
+
copyright: mockCopyrightConfig,
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
const newConfig = originalConfig.with({
|
|
271
|
+
app: { name: 'Modified App Name' },
|
|
272
|
+
build: { port: 8080 },
|
|
273
|
+
ui: { defaultTheme: 'dark' },
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
// Original config should be unchanged
|
|
277
|
+
expect(originalConfig.app.name).toBe('Test Application');
|
|
278
|
+
expect(originalConfig.build.port).toBe(3000);
|
|
279
|
+
expect(originalConfig.ui.defaultTheme).toBe('light');
|
|
280
|
+
|
|
281
|
+
// New config should have overrides
|
|
282
|
+
expect(newConfig.app.name).toBe('Modified App Name');
|
|
283
|
+
expect(newConfig.app.id).toBe('test-app'); // Unchanged
|
|
284
|
+
expect(newConfig.build.port).toBe(8080);
|
|
285
|
+
expect(newConfig.build.previewPort).toBe(4173); // Unchanged
|
|
286
|
+
expect(newConfig.ui.defaultTheme).toBe('dark');
|
|
287
|
+
expect(newConfig.ui.enableScaffolding).toBe(true); // Unchanged
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
it('should handle partial overrides', () => {
|
|
291
|
+
const originalConfig = new AppConfig({
|
|
292
|
+
app: mockAppIdentity,
|
|
293
|
+
build: mockBuildConfig,
|
|
294
|
+
pwa: mockPWAConfig,
|
|
295
|
+
ui: mockUIConfig,
|
|
296
|
+
copyright: mockCopyrightConfig,
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
const newConfig = originalConfig.with({
|
|
300
|
+
pwa: { themeColor: '#ff5722' },
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
expect(newConfig.pwa.themeColor).toBe('#ff5722');
|
|
304
|
+
expect(newConfig.pwa.backgroundColor).toBe('#ffffff'); // Unchanged
|
|
305
|
+
expect(newConfig.pwa.display).toBe('standalone'); // Unchanged
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
it('should maintain immutability after override', () => {
|
|
309
|
+
const originalConfig = new AppConfig({
|
|
310
|
+
app: mockAppIdentity,
|
|
311
|
+
build: mockBuildConfig,
|
|
312
|
+
pwa: mockPWAConfig,
|
|
313
|
+
ui: mockUIConfig,
|
|
314
|
+
copyright: mockCopyrightConfig,
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
const newConfig = originalConfig.with({
|
|
318
|
+
app: { name: 'New Name' },
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
expect(() => {
|
|
322
|
+
(newConfig.app as any).name = 'Another Name';
|
|
323
|
+
}).toThrow();
|
|
324
|
+
});
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
describe('Edge Cases', () => {
|
|
328
|
+
it('should handle undefined optional fields gracefully', () => {
|
|
329
|
+
const minimalApp: AppIdentity = {
|
|
330
|
+
id: 'minimal-app',
|
|
331
|
+
name: 'Minimal App',
|
|
332
|
+
shortName: 'Minimal',
|
|
333
|
+
description: 'Minimal description',
|
|
334
|
+
version: '1.0.0',
|
|
335
|
+
logo: '/logo.svg',
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
const minimalPWAConfig: PWAConfig = {
|
|
339
|
+
themeColor: '#2196f3',
|
|
340
|
+
backgroundColor: '#ffffff',
|
|
341
|
+
startUrl: '/',
|
|
342
|
+
scope: '/',
|
|
343
|
+
display: 'standalone',
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
const config = new AppConfig({
|
|
347
|
+
app: minimalApp,
|
|
348
|
+
build: mockBuildConfig,
|
|
349
|
+
pwa: minimalPWAConfig,
|
|
350
|
+
ui: mockUIConfig,
|
|
351
|
+
copyright: mockCopyrightConfig,
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
expect(config.app.author).toBeUndefined();
|
|
355
|
+
expect(config.app.homepage).toBeUndefined();
|
|
356
|
+
expect(config.pwa.orientation).toBeUndefined();
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
it('should generate valid vite config even with minimal configuration', () => {
|
|
360
|
+
const minimalBuild: BuildConfig = {
|
|
361
|
+
port: 3000,
|
|
362
|
+
previewPort: 4173,
|
|
363
|
+
outputDir: 'dist',
|
|
364
|
+
publicPath: '/',
|
|
365
|
+
base: '/',
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
const config = new AppConfig({
|
|
369
|
+
app: mockAppIdentity,
|
|
370
|
+
build: minimalBuild,
|
|
371
|
+
pwa: mockPWAConfig,
|
|
372
|
+
ui: mockUIConfig,
|
|
373
|
+
copyright: mockCopyrightConfig,
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
const viteConfig = config.viteConfig;
|
|
377
|
+
|
|
378
|
+
expect(viteConfig).toBeDefined();
|
|
379
|
+
expect(viteConfig.server).toBeDefined();
|
|
380
|
+
expect(viteConfig.preview).toBeDefined();
|
|
381
|
+
expect(viteConfig.build).toBeDefined();
|
|
382
|
+
expect(viteConfig.define).toBeDefined();
|
|
383
|
+
});
|
|
384
|
+
});
|
|
385
|
+
});
|