@designcrowd/library.brand-page 5.12.13-flacky-nav-2 → 5.12.13
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/lib/src/{CreatedOnBrandCrowd-de-de-CJd8myVU.js → CreatedOnBrandCrowd-de-de-BezsFVny.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-en-us-D4gZ2H-9.js → CreatedOnBrandCrowd-en-us-ulQgBuU-.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-es-es-Cj7neWWa.js → CreatedOnBrandCrowd-es-es-qvD2vIl0.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-fr-fr-CdBtmVE3.js → CreatedOnBrandCrowd-fr-fr-Dd_AMhTv.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-pt-pt-PoPJCQeR.js → CreatedOnBrandCrowd-pt-pt-Cc-MpjqR.js} +1 -1
- package/lib/src/{CreatedOnDcom-de-de-CaSDNyDq.js → CreatedOnDcom-de-de-XvJi63yz.js} +1 -1
- package/lib/src/{CreatedOnDcom-en-us-ma0Une6U.js → CreatedOnDcom-en-us-DnMC3nxO.js} +1 -1
- package/lib/src/{CreatedOnDcom-es-es-BEeZPSgl.js → CreatedOnDcom-es-es-KJxsvnLp.js} +1 -1
- package/lib/src/{CreatedOnDcom-fr-fr-j1DtvzYd.js → CreatedOnDcom-fr-fr-7aEPaXkS.js} +1 -1
- package/lib/src/{CreatedOnDcom-pt-pt-D1UT2017.js → CreatedOnDcom-pt-pt-CYLmzlvx.js} +1 -1
- package/lib/src/brand-page/components/background-shape/BackgroundShape.mixin.js +1 -0
- package/lib/src/brand-page/components/payment/__fixtures__/request-payment.d.ts +0 -1
- package/lib/src/brand-page/components/payment/__fixtures__/support-me.d.ts +0 -1
- package/lib/src/brand-page/models/brand-page-context.model.d.ts +0 -2
- package/lib/src/brand-page/utils/migration/migration-01.d.ts +1 -1
- package/lib/src/brand-page/utils/migration/migration-01.js +1 -1
- package/lib/src/brand-page/utils/migration/migration-02.d.ts +1 -1
- package/lib/src/brand-page/utils/migration/migration-02.js +1 -1
- package/lib/src/brand-page/utils/migration/migration-03.d.ts +1 -1
- package/lib/src/brand-page/utils/migration/migration-03.js +1 -1
- package/lib/src/brand-page/utils/migration/migration-04.d.ts +1 -1
- package/lib/src/brand-page/utils/migration/migration-04.js +1 -1
- package/lib/src/brand-page/utils/migration/migration-05.d.ts +2 -5
- package/lib/src/brand-page/utils/migration/migration-05.js +1 -1
- package/lib/src/brand-page/utils/migration.util.d.ts +1 -2
- package/lib/src/brand-page/utils/migration.util.js +4 -9
- package/lib/src/brand-page-maker/components/preview/Preview.mixin.js +0 -1
- package/lib/src/brand-page-maker/components/template-preview/TemplatePreview.mixin.js +0 -1
- package/lib/src/brand-page-maker/stores/brandpage-maker/brandpage-maker-store.js +1 -1
- package/lib/src/css/library.brand-page-brandCrowd.min.css +5 -11
- package/lib/src/css/library.brand-page-brandPage.min.css +5 -11
- package/lib/src/css/library.brand-page-designCom.min.css +5 -11
- package/lib/src/css/library.brand-page-preview.min.css +5 -11
- package/lib/src/index.mjs +1 -1
- package/lib/src/{lib-h5MCJKws.js → lib-Ts2IO7tS.js} +16787 -16943
- package/lib/src/shared/content-settings/components/content-settings-item/ContentSettingsItem.mixin.js +0 -1
- package/lib/src/shared/page-settings/store/page-settings-store.js +1 -1
- package/lib/src/shared/template-settings/store/template-settings-store.js +1 -1
- package/package.json +1 -1
- package/src/brand-page/components/background-shape/BackgroundShape.mixin.ts +2 -0
- package/src/brand-page/components/logo/Logo.vue +27 -106
- package/src/brand-page/components/logo/LogoRender.vue +4 -15
- package/src/brand-page/models/brand-page-context.model.ts +0 -2
- package/src/brand-page/utils/__snapshots__/migration.util.test.ts.snap +3 -3
- package/src/brand-page/utils/migration/logo/migration.util.logo.test.ts +2 -2
- package/src/brand-page/utils/migration/migration-01.ts +2 -2
- package/src/brand-page/utils/migration/migration-02.ts +2 -2
- package/src/brand-page/utils/migration/migration-03.ts +2 -2
- package/src/brand-page/utils/migration/migration-04.ts +2 -2
- package/src/brand-page/utils/migration/migration-05.ts +2 -12
- package/src/brand-page/utils/migration.util.test.ts +108 -155
- package/src/brand-page/utils/migration.util.ts +6 -12
- package/src/brand-page/utils/migration2.util.test.ts +2 -4
- package/src/brand-page-maker/components/preview/Preview.mixin.ts +0 -1
- package/src/brand-page-maker/components/template-preview/TemplatePreview.mixin.ts +0 -1
- package/src/brand-page-maker/stores/brandpage-maker/brandpage-maker-store.ts +1 -1
- package/src/shared/content-settings/components/content-settings-item/ContentSettingsItem.mixin.ts +0 -1
- package/src/shared/page-settings/store/page-settings-store.ts +0 -1
- package/src/shared/template-settings/store/template-settings-store.ts +1 -1
- package/lib/src/brand-page/utils/migration/migration-06.d.ts +0 -4
- package/lib/src/brand-page/utils/migration/migration-06.js +0 -96
- package/src/brand-page/utils/migration/migration-06.test.ts +0 -338
- package/src/brand-page/utils/migration/migration-06.ts +0 -164
|
@@ -4,7 +4,6 @@ import { migration02 } from './migration/migration-02';
|
|
|
4
4
|
import { migration03 } from './migration/migration-03';
|
|
5
5
|
import { migration04 } from './migration/migration-04';
|
|
6
6
|
import { migration05 } from './migration/migration-05';
|
|
7
|
-
import { migration06 } from './migration/migration-06';
|
|
8
7
|
|
|
9
8
|
interface MigrationTableItem {
|
|
10
9
|
version: number;
|
|
@@ -14,7 +13,7 @@ interface MigrationTableItem {
|
|
|
14
13
|
logoImage?: LogoImageModel;
|
|
15
14
|
isUserDraft: boolean;
|
|
16
15
|
},
|
|
17
|
-
) => BrandPageModel
|
|
16
|
+
) => BrandPageModel;
|
|
18
17
|
}
|
|
19
18
|
|
|
20
19
|
const MIGRATION_TABLE = [
|
|
@@ -38,34 +37,29 @@ const MIGRATION_TABLE = [
|
|
|
38
37
|
version: 5,
|
|
39
38
|
migrateFn: migration05,
|
|
40
39
|
},
|
|
41
|
-
{
|
|
42
|
-
version: 6,
|
|
43
|
-
migrateFn: migration06,
|
|
44
|
-
},
|
|
45
40
|
] as MigrationTableItem[];
|
|
46
41
|
|
|
47
42
|
export const GetLatestModelVersion = () =>
|
|
48
43
|
Math.max(...MIGRATION_TABLE.map((x) => x.version));
|
|
49
44
|
|
|
50
|
-
export const migrateBrandPageModel =
|
|
45
|
+
export const migrateBrandPageModel = (
|
|
51
46
|
brandPageModel: BrandPageModel,
|
|
52
47
|
options: {
|
|
53
48
|
logoImage?: LogoImageModel;
|
|
54
49
|
isUserDraft: boolean;
|
|
55
|
-
skipMigration06?: boolean;
|
|
56
50
|
},
|
|
57
|
-
):
|
|
51
|
+
): BrandPageModel => {
|
|
58
52
|
let modelVersion = brandPageModel.v;
|
|
59
53
|
|
|
60
54
|
if (!modelVersion) {
|
|
61
55
|
modelVersion = 0;
|
|
62
56
|
}
|
|
63
57
|
|
|
64
|
-
|
|
58
|
+
MIGRATION_TABLE.forEach((x) => {
|
|
65
59
|
if (modelVersion < x.version) {
|
|
66
|
-
brandPageModel =
|
|
60
|
+
brandPageModel = x.migrateFn(brandPageModel, options);
|
|
67
61
|
}
|
|
68
|
-
}
|
|
62
|
+
});
|
|
69
63
|
|
|
70
64
|
// Set the model to latest version
|
|
71
65
|
brandPageModel.v = GetLatestModelVersion();
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
} from './migration/migration-02';
|
|
6
6
|
|
|
7
7
|
describe('migration02.ts', () => {
|
|
8
|
-
test('migration02 should return converted letterspacing',
|
|
8
|
+
test('migration02 should return converted letterspacing', () => {
|
|
9
9
|
const data: BrandPageData = {
|
|
10
10
|
pages: [
|
|
11
11
|
{
|
|
@@ -94,9 +94,7 @@ describe('migration02.ts', () => {
|
|
|
94
94
|
],
|
|
95
95
|
};
|
|
96
96
|
|
|
97
|
-
const model =
|
|
98
|
-
isUserDraft: false,
|
|
99
|
-
});
|
|
97
|
+
const model = migration02(new BrandPageModel(data), { isUserDraft: false });
|
|
100
98
|
|
|
101
99
|
expect(model).toMatchSnapshot();
|
|
102
100
|
});
|
|
@@ -177,7 +177,7 @@ export const useUiTemplateSettingsStore = defineStore('uiTemplateSettings', {
|
|
|
177
177
|
|
|
178
178
|
const templateData = JSON.parse(template.data);
|
|
179
179
|
|
|
180
|
-
const brandPageModel =
|
|
180
|
+
const brandPageModel = migrateBrandPageModel(
|
|
181
181
|
new BrandPageModel(templateData),
|
|
182
182
|
{
|
|
183
183
|
logoImage: {
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { DEFAULT_LOGO_HEIGHT, DEFAULT_LOGO_WIDTH, } from '../..';
|
|
2
|
-
import { FabricRenderClient } from '../../../clients/fabric-render-client';
|
|
3
|
-
export const migration06 = async (brandPageModel, options) => {
|
|
4
|
-
console.log('Running migration 06', options.skipMigration06);
|
|
5
|
-
if (options.skipMigration06 !== undefined && options.skipMigration06) {
|
|
6
|
-
return brandPageModel;
|
|
7
|
-
}
|
|
8
|
-
const header = brandPageModel.pageHeaderDesktop;
|
|
9
|
-
try {
|
|
10
|
-
console.log('Migration 06: Attempting to fetch logo dimensions from FabricRenderClient', header);
|
|
11
|
-
const headerLogo = brandPageModel.pageHeaderDesktop;
|
|
12
|
-
const fabricClient = FabricRenderClient.getInstance();
|
|
13
|
-
const logoData = headerLogo?.logoTemplateImage?.logoTemplateToken
|
|
14
|
-
? await fabricClient.getLogoSvgUrlByLogoTemplateImageAsync(headerLogo.logoTemplateImage)
|
|
15
|
-
: await fabricClient.getLogoSvgUrlByLogoImageAsync(headerLogo.logoImage);
|
|
16
|
-
console.log('Migration 06: Fetched logo SVG URL', logoData);
|
|
17
|
-
// Try to fetch the logo image dimensions from the server
|
|
18
|
-
if (logoData && logoData.width && logoData.height) {
|
|
19
|
-
// Convert rem to pixels (assuming 1rem = 16px)
|
|
20
|
-
const remToPixels = (remValue) => {
|
|
21
|
-
const numericValue = parseFloat(remValue.replace('rem', ''));
|
|
22
|
-
return numericValue * 16;
|
|
23
|
-
};
|
|
24
|
-
// Helper function to calculate constrained dimensions for a specific section
|
|
25
|
-
const calculateConstrainedDimensions = (maxWidth, maxHeight) => {
|
|
26
|
-
const maxWidthPx = remToPixels(maxWidth);
|
|
27
|
-
const maxHeightPx = remToPixels(maxHeight);
|
|
28
|
-
// Calculate the actual displayed dimensions considering max-width and max-height constraints
|
|
29
|
-
const logoAspectRatio = logoData.width / logoData.height;
|
|
30
|
-
const maxAspectRatio = maxWidthPx / maxHeightPx;
|
|
31
|
-
let actualWidth;
|
|
32
|
-
let actualHeight;
|
|
33
|
-
if (logoAspectRatio > maxAspectRatio) {
|
|
34
|
-
// Logo is wider relative to max dimensions, constrain by width
|
|
35
|
-
actualWidth = Math.min(logoData.width, maxWidthPx);
|
|
36
|
-
actualHeight = actualWidth / logoAspectRatio;
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
// Logo is taller relative to max dimensions, constrain by height
|
|
40
|
-
actualHeight = Math.min(logoData.height, maxHeightPx);
|
|
41
|
-
actualWidth = actualHeight * logoAspectRatio;
|
|
42
|
-
}
|
|
43
|
-
// Convert back to rem for consistency
|
|
44
|
-
const actualWidthRem = `${Math.round(actualWidth / 16)}rem`;
|
|
45
|
-
const actualHeightRem = `${Math.ceil(actualHeight / 16)}rem`;
|
|
46
|
-
return { width: actualWidthRem, height: actualHeightRem };
|
|
47
|
-
};
|
|
48
|
-
// Calculate dimensions for each section individually based on their own max constraints
|
|
49
|
-
// Header Desktop
|
|
50
|
-
if (brandPageModel.pageHeaderDesktop) {
|
|
51
|
-
const currentMaxWidth = brandPageModel.pageHeaderDesktop.logoImageWidth || DEFAULT_LOGO_WIDTH;
|
|
52
|
-
const currentMaxHeight = brandPageModel.pageHeaderDesktop.logoImageHeight ||
|
|
53
|
-
DEFAULT_LOGO_HEIGHT;
|
|
54
|
-
const dimensions = calculateConstrainedDimensions(currentMaxWidth, currentMaxHeight);
|
|
55
|
-
console.log('##############################################################################', 'Migration 06: Calculated dimensions for header desktop', currentMaxHeight, currentMaxWidth, dimensions);
|
|
56
|
-
brandPageModel.pageHeaderDesktop.logoImageHeight = dimensions.height;
|
|
57
|
-
// brandPageModel.pageHeaderDesktop.logoImageWidth = dimensions.width;
|
|
58
|
-
}
|
|
59
|
-
// Header Mobile
|
|
60
|
-
if (brandPageModel.pageHeaderMobile) {
|
|
61
|
-
const currentMaxWidth = brandPageModel.pageHeaderMobile.logoImageWidth || DEFAULT_LOGO_WIDTH;
|
|
62
|
-
const currentMaxHeight = brandPageModel.pageHeaderMobile.logoImageHeight ||
|
|
63
|
-
DEFAULT_LOGO_HEIGHT;
|
|
64
|
-
const dimensions = calculateConstrainedDimensions(currentMaxWidth, currentMaxHeight);
|
|
65
|
-
brandPageModel.pageHeaderMobile.logoImageHeight = dimensions.height;
|
|
66
|
-
// brandPageModel.pageHeaderMobile.logoImageWidth = dimensions.width;
|
|
67
|
-
}
|
|
68
|
-
// Footer Desktop
|
|
69
|
-
if (brandPageModel.pageFooterDesktop) {
|
|
70
|
-
const currentMaxWidth = brandPageModel.pageFooterDesktop.logoImageWidth || DEFAULT_LOGO_WIDTH;
|
|
71
|
-
const currentMaxHeight = brandPageModel.pageFooterDesktop.logoImageHeight ||
|
|
72
|
-
DEFAULT_LOGO_HEIGHT;
|
|
73
|
-
const dimensions = calculateConstrainedDimensions(currentMaxWidth, currentMaxHeight);
|
|
74
|
-
brandPageModel.pageFooterDesktop.logoImageHeight = dimensions.height;
|
|
75
|
-
// brandPageModel.pageFooterDesktop.logoImageWidth = dimensions.width;
|
|
76
|
-
}
|
|
77
|
-
// Footer Mobile
|
|
78
|
-
if (brandPageModel.pageFooterMobile) {
|
|
79
|
-
const currentMaxWidth = brandPageModel.pageFooterMobile.logoImageWidth || DEFAULT_LOGO_WIDTH;
|
|
80
|
-
const currentMaxHeight = brandPageModel.pageFooterMobile.logoImageHeight ||
|
|
81
|
-
DEFAULT_LOGO_HEIGHT;
|
|
82
|
-
const dimensions = calculateConstrainedDimensions(currentMaxWidth, currentMaxHeight);
|
|
83
|
-
brandPageModel.pageFooterMobile.logoImageHeight = dimensions.height;
|
|
84
|
-
// brandPageModel.pageFooterMobile.logoImageWidth = dimensions.width;
|
|
85
|
-
}
|
|
86
|
-
console.log('Migration 06: Logo dimensions updated successfully');
|
|
87
|
-
console.log(`Original logo: ${logoData.width}x${logoData.height}px`);
|
|
88
|
-
console.log('Dimensions calculated for each section based on their individual constraints');
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
catch (error) {
|
|
92
|
-
// If fetching fails, silently continue without updating dimensions
|
|
93
|
-
console.warn('Migration 06: Failed to fetch logo dimensions:', error);
|
|
94
|
-
}
|
|
95
|
-
return brandPageModel;
|
|
96
|
-
};
|
|
@@ -1,338 +0,0 @@
|
|
|
1
|
-
import { BrandPageModel, type BrandPageData } from '../../models';
|
|
2
|
-
import { migration06 } from './migration-06';
|
|
3
|
-
|
|
4
|
-
describe('migration06', () => {
|
|
5
|
-
test('should skip migration when skipMigration06 is true', async () => {
|
|
6
|
-
const data: BrandPageData = {
|
|
7
|
-
pageHeaderDesktop: {
|
|
8
|
-
logoImageWidth: '12rem',
|
|
9
|
-
logoImageHeight: '9rem',
|
|
10
|
-
logoImage: { logoDraftToken: 'test-token', logoVariation: 0 },
|
|
11
|
-
},
|
|
12
|
-
pageHeaderMobile: {
|
|
13
|
-
logoImageWidth: '12rem',
|
|
14
|
-
logoImageHeight: '9rem',
|
|
15
|
-
logoImage: { logoDraftToken: 'test-token', logoVariation: 0 },
|
|
16
|
-
},
|
|
17
|
-
pageFooterDesktop: {
|
|
18
|
-
logoImageWidth: '12rem',
|
|
19
|
-
logoImageHeight: '9rem',
|
|
20
|
-
logoImage: { logoDraftToken: 'test-token', logoVariation: 0 },
|
|
21
|
-
},
|
|
22
|
-
pageFooterMobile: {
|
|
23
|
-
logoImageWidth: '12rem',
|
|
24
|
-
logoImageHeight: '9rem',
|
|
25
|
-
logoImage: { logoDraftToken: 'test-token', logoVariation: 0 },
|
|
26
|
-
},
|
|
27
|
-
} as any;
|
|
28
|
-
|
|
29
|
-
const model = new BrandPageModel(data);
|
|
30
|
-
const originalDimensions = {
|
|
31
|
-
headerDesktopWidth: model.pageHeaderDesktop.logoImageWidth,
|
|
32
|
-
headerDesktopHeight: model.pageHeaderDesktop.logoImageHeight,
|
|
33
|
-
headerMobileWidth: model.pageHeaderMobile.logoImageWidth,
|
|
34
|
-
headerMobileHeight: model.pageHeaderMobile.logoImageHeight,
|
|
35
|
-
footerDesktopWidth: model.pageFooterDesktop.logoImageWidth,
|
|
36
|
-
footerDesktopHeight: model.pageFooterDesktop.logoImageHeight,
|
|
37
|
-
footerMobileWidth: model.pageFooterMobile.logoImageWidth,
|
|
38
|
-
footerMobileHeight: model.pageFooterMobile.logoImageHeight,
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const result = await migration06(model, { skipMigration06: true });
|
|
42
|
-
|
|
43
|
-
// All dimensions should remain unchanged when skipMigration06 is true
|
|
44
|
-
expect(result.pageHeaderDesktop.logoImageWidth).toBe(
|
|
45
|
-
originalDimensions.headerDesktopWidth,
|
|
46
|
-
);
|
|
47
|
-
expect(result.pageHeaderDesktop.logoImageHeight).toBe(
|
|
48
|
-
originalDimensions.headerDesktopHeight,
|
|
49
|
-
);
|
|
50
|
-
expect(result.pageHeaderMobile.logoImageWidth).toBe(
|
|
51
|
-
originalDimensions.headerMobileWidth,
|
|
52
|
-
);
|
|
53
|
-
expect(result.pageHeaderMobile.logoImageHeight).toBe(
|
|
54
|
-
originalDimensions.headerMobileHeight,
|
|
55
|
-
);
|
|
56
|
-
expect(result.pageFooterDesktop.logoImageWidth).toBe(
|
|
57
|
-
originalDimensions.footerDesktopWidth,
|
|
58
|
-
);
|
|
59
|
-
expect(result.pageFooterDesktop.logoImageHeight).toBe(
|
|
60
|
-
originalDimensions.footerDesktopHeight,
|
|
61
|
-
);
|
|
62
|
-
expect(result.pageFooterMobile.logoImageWidth).toBe(
|
|
63
|
-
originalDimensions.footerMobileWidth,
|
|
64
|
-
);
|
|
65
|
-
expect(result.pageFooterMobile.logoImageHeight).toBe(
|
|
66
|
-
originalDimensions.footerMobileHeight,
|
|
67
|
-
);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
test('should skip migration when no logo token is available', async () => {
|
|
71
|
-
const data: BrandPageData = {
|
|
72
|
-
pageHeaderDesktop: {
|
|
73
|
-
logoImageWidth: '12rem',
|
|
74
|
-
logoImageHeight: '9rem',
|
|
75
|
-
logoImage: { logoDraftToken: '', logoVariation: 0 }, // Empty token
|
|
76
|
-
},
|
|
77
|
-
pageHeaderMobile: {
|
|
78
|
-
logoImageWidth: '12rem',
|
|
79
|
-
logoImageHeight: '9rem',
|
|
80
|
-
logoImage: { logoDraftToken: '', logoVariation: 0 },
|
|
81
|
-
},
|
|
82
|
-
pageFooterDesktop: {
|
|
83
|
-
logoImageWidth: '12rem',
|
|
84
|
-
logoImageHeight: '9rem',
|
|
85
|
-
logoImage: { logoDraftToken: '', logoVariation: 0 },
|
|
86
|
-
},
|
|
87
|
-
pageFooterMobile: {
|
|
88
|
-
logoImageWidth: '12rem',
|
|
89
|
-
logoImageHeight: '9rem',
|
|
90
|
-
logoImage: { logoDraftToken: '', logoVariation: 0 },
|
|
91
|
-
},
|
|
92
|
-
} as any;
|
|
93
|
-
|
|
94
|
-
const model = new BrandPageModel(data);
|
|
95
|
-
const originalDimensions = {
|
|
96
|
-
headerDesktopWidth: model.pageHeaderDesktop.logoImageWidth,
|
|
97
|
-
headerDesktopHeight: model.pageHeaderDesktop.logoImageHeight,
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
const result = await migration06(model, { skipMigration06: false });
|
|
101
|
-
|
|
102
|
-
// Dimensions should remain unchanged when no logo token
|
|
103
|
-
expect(result.pageHeaderDesktop.logoImageWidth).toBe(
|
|
104
|
-
originalDimensions.headerDesktopWidth,
|
|
105
|
-
);
|
|
106
|
-
expect(result.pageHeaderDesktop.logoImageHeight).toBe(
|
|
107
|
-
originalDimensions.headerDesktopHeight,
|
|
108
|
-
);
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
test('should use default dimensions when none are provided', async () => {
|
|
112
|
-
const data: BrandPageData = {
|
|
113
|
-
pageHeaderDesktop: {
|
|
114
|
-
// No logoImageWidth or logoImageHeight provided
|
|
115
|
-
logoImage: { logoDraftToken: '', logoVariation: 0 },
|
|
116
|
-
},
|
|
117
|
-
pageHeaderMobile: {
|
|
118
|
-
logoImage: { logoDraftToken: '', logoVariation: 0 },
|
|
119
|
-
},
|
|
120
|
-
pageFooterDesktop: {
|
|
121
|
-
logoImage: { logoDraftToken: '', logoVariation: 0 },
|
|
122
|
-
},
|
|
123
|
-
pageFooterMobile: {
|
|
124
|
-
logoImage: { logoDraftToken: '', logoVariation: 0 },
|
|
125
|
-
},
|
|
126
|
-
} as any;
|
|
127
|
-
|
|
128
|
-
const model = new BrandPageModel(data);
|
|
129
|
-
const result = await migration06(model, { skipMigration06: false });
|
|
130
|
-
|
|
131
|
-
// Should not crash and return the model unchanged since no logo token
|
|
132
|
-
expect(result).toBeDefined();
|
|
133
|
-
expect(result.pageHeaderDesktop).toBeDefined();
|
|
134
|
-
expect(result.pageHeaderMobile).toBeDefined();
|
|
135
|
-
expect(result.pageFooterDesktop).toBeDefined();
|
|
136
|
-
expect(result.pageFooterMobile).toBeDefined();
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
test('should handle missing pageHeaderDesktop gracefully', async () => {
|
|
140
|
-
const data: BrandPageData = {
|
|
141
|
-
// Missing pageHeaderDesktop
|
|
142
|
-
} as any;
|
|
143
|
-
|
|
144
|
-
const model = new BrandPageModel(data);
|
|
145
|
-
|
|
146
|
-
// Should not crash when pageHeaderDesktop is missing
|
|
147
|
-
await expect(
|
|
148
|
-
migration06(model, { skipMigration06: false }),
|
|
149
|
-
).resolves.toBeDefined();
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
test('should return the same model instance when skipping migration', async () => {
|
|
153
|
-
const data: BrandPageData = {
|
|
154
|
-
pageHeaderDesktop: {
|
|
155
|
-
logoImageWidth: '10rem',
|
|
156
|
-
logoImageHeight: '8rem',
|
|
157
|
-
logoImage: { logoDraftToken: 'test-token', logoVariation: 0 },
|
|
158
|
-
},
|
|
159
|
-
pageHeaderMobile: {
|
|
160
|
-
logoImageWidth: '10rem',
|
|
161
|
-
logoImageHeight: '8rem',
|
|
162
|
-
logoImage: { logoDraftToken: 'test-token', logoVariation: 0 },
|
|
163
|
-
},
|
|
164
|
-
pageFooterDesktop: {
|
|
165
|
-
logoImageWidth: '10rem',
|
|
166
|
-
logoImageHeight: '8rem',
|
|
167
|
-
logoImage: { logoDraftToken: 'test-token', logoVariation: 0 },
|
|
168
|
-
},
|
|
169
|
-
pageFooterMobile: {
|
|
170
|
-
logoImageWidth: '10rem',
|
|
171
|
-
logoImageHeight: '8rem',
|
|
172
|
-
logoImage: { logoDraftToken: 'test-token', logoVariation: 0 },
|
|
173
|
-
},
|
|
174
|
-
} as any;
|
|
175
|
-
|
|
176
|
-
const model = new BrandPageModel(data);
|
|
177
|
-
const result = await migration06(model, { skipMigration06: true });
|
|
178
|
-
|
|
179
|
-
// Should return the exact same model instance
|
|
180
|
-
expect(result).toBe(model);
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
test('should handle logoTemplateImage when available', async () => {
|
|
184
|
-
const data: BrandPageData = {
|
|
185
|
-
pageHeaderDesktop: {
|
|
186
|
-
logoImageWidth: '10rem',
|
|
187
|
-
logoImageHeight: '10rem',
|
|
188
|
-
logoImage: { logoDraftToken: 'test-token', logoVariation: 0 },
|
|
189
|
-
logoTemplateImage: { logoTemplateToken: 'template-token' },
|
|
190
|
-
},
|
|
191
|
-
pageHeaderMobile: {
|
|
192
|
-
logoImageWidth: '10rem',
|
|
193
|
-
logoImageHeight: '10rem',
|
|
194
|
-
logoImage: { logoDraftToken: 'test-token', logoVariation: 0 },
|
|
195
|
-
logoTemplateImage: { logoTemplateToken: 'template-token' },
|
|
196
|
-
},
|
|
197
|
-
pageFooterDesktop: {
|
|
198
|
-
logoImageWidth: '10rem',
|
|
199
|
-
logoImageHeight: '10rem',
|
|
200
|
-
logoImage: { logoDraftToken: 'test-token', logoVariation: 0 },
|
|
201
|
-
logoTemplateImage: { logoTemplateToken: 'template-token' },
|
|
202
|
-
},
|
|
203
|
-
pageFooterMobile: {
|
|
204
|
-
logoImageWidth: '10rem',
|
|
205
|
-
logoImageHeight: '10rem',
|
|
206
|
-
logoImage: { logoDraftToken: 'test-token', logoVariation: 0 },
|
|
207
|
-
logoTemplateImage: { logoTemplateToken: 'template-token' },
|
|
208
|
-
},
|
|
209
|
-
} as any;
|
|
210
|
-
|
|
211
|
-
const model = new BrandPageModel(data);
|
|
212
|
-
|
|
213
|
-
// The migration should attempt to process the template image
|
|
214
|
-
// Since we can't mock the API call, we expect it to either succeed or fail gracefully
|
|
215
|
-
const result = await migration06(model, { skipMigration06: false });
|
|
216
|
-
|
|
217
|
-
expect(result).toBeDefined();
|
|
218
|
-
expect(result.pageHeaderDesktop).toBeDefined();
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
test('should maintain model structure after migration', async () => {
|
|
222
|
-
const data: BrandPageData = {
|
|
223
|
-
pageHeaderDesktop: {
|
|
224
|
-
logoImageWidth: '12rem',
|
|
225
|
-
logoImageHeight: '9rem',
|
|
226
|
-
logoImage: { logoDraftToken: 'test-token', logoVariation: 0 },
|
|
227
|
-
displayStyle: 'desktop-tab-vertical-stack-centered-logo-centered-menu',
|
|
228
|
-
isLogoVisible: true,
|
|
229
|
-
},
|
|
230
|
-
pageHeaderMobile: {
|
|
231
|
-
logoImageWidth: '12rem',
|
|
232
|
-
logoImageHeight: '9rem',
|
|
233
|
-
logoImage: { logoDraftToken: 'test-token', logoVariation: 0 },
|
|
234
|
-
displayStyle: 'mobile-tab-vertical-stack-centered-logo-centered-menu',
|
|
235
|
-
isLogoVisible: true,
|
|
236
|
-
},
|
|
237
|
-
pageFooterDesktop: {
|
|
238
|
-
logoImageWidth: '12rem',
|
|
239
|
-
logoImageHeight: '9rem',
|
|
240
|
-
logoImage: { logoDraftToken: 'test-token', logoVariation: 0 },
|
|
241
|
-
displayStyle: 'centered-menu',
|
|
242
|
-
isLogoVisible: true,
|
|
243
|
-
},
|
|
244
|
-
pageFooterMobile: {
|
|
245
|
-
logoImageWidth: '12rem',
|
|
246
|
-
logoImageHeight: '9rem',
|
|
247
|
-
logoImage: { logoDraftToken: 'test-token', logoVariation: 0 },
|
|
248
|
-
displayStyle: 'centered-menu',
|
|
249
|
-
isLogoVisible: true,
|
|
250
|
-
},
|
|
251
|
-
v: 5,
|
|
252
|
-
brandPageType: 'brandSite',
|
|
253
|
-
} as any;
|
|
254
|
-
|
|
255
|
-
const model = new BrandPageModel(data);
|
|
256
|
-
const result = await migration06(model, { skipMigration06: false });
|
|
257
|
-
|
|
258
|
-
// Should maintain all original properties
|
|
259
|
-
expect(result.pageHeaderDesktop.displayStyle).toBe(
|
|
260
|
-
'desktop-tab-vertical-stack-centered-logo-centered-menu',
|
|
261
|
-
);
|
|
262
|
-
expect(result.pageHeaderDesktop.isLogoVisible).toBe(true);
|
|
263
|
-
expect(result.pageHeaderMobile.displayStyle).toBe(
|
|
264
|
-
'mobile-tab-vertical-stack-centered-logo-centered-menu',
|
|
265
|
-
);
|
|
266
|
-
expect(result.pageHeaderMobile.isLogoVisible).toBe(true);
|
|
267
|
-
expect(result.pageFooterDesktop.displayStyle).toBe('centered-menu');
|
|
268
|
-
expect(result.pageFooterDesktop.isLogoVisible).toBe(true);
|
|
269
|
-
expect(result.pageFooterMobile.displayStyle).toBe('centered-menu');
|
|
270
|
-
expect(result.pageFooterMobile.isLogoVisible).toBe(true);
|
|
271
|
-
expect(result.v).toBe(5);
|
|
272
|
-
expect(result.brandPageType).toBe('brandSite');
|
|
273
|
-
|
|
274
|
-
// Logo image objects should be preserved
|
|
275
|
-
expect(result.pageHeaderDesktop.logoImage.logoDraftToken).toBe(
|
|
276
|
-
'test-token',
|
|
277
|
-
);
|
|
278
|
-
expect(result.pageHeaderDesktop.logoImage.logoVariation).toBe(0);
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
test('should calculate dimensions independently for each section with different max constraints', async () => {
|
|
282
|
-
const data: BrandPageData = {
|
|
283
|
-
pageHeaderDesktop: {
|
|
284
|
-
logoImageWidth: '16rem', // 256px max
|
|
285
|
-
logoImageHeight: '12rem', // 192px max
|
|
286
|
-
logoImage: { logoDraftToken: 'test-token', logoVariation: 0 },
|
|
287
|
-
},
|
|
288
|
-
pageHeaderMobile: {
|
|
289
|
-
logoImageWidth: '8rem', // 128px max
|
|
290
|
-
logoImageHeight: '6rem', // 96px max
|
|
291
|
-
logoImage: { logoDraftToken: 'test-token', logoVariation: 0 },
|
|
292
|
-
},
|
|
293
|
-
pageFooterDesktop: {
|
|
294
|
-
logoImageWidth: '10rem', // 160px max
|
|
295
|
-
logoImageHeight: '10rem', // 160px max (square)
|
|
296
|
-
logoImage: { logoDraftToken: 'test-token', logoVariation: 0 },
|
|
297
|
-
},
|
|
298
|
-
pageFooterMobile: {
|
|
299
|
-
logoImageWidth: '6rem', // 96px max
|
|
300
|
-
logoImageHeight: '8rem', // 128px max (tall)
|
|
301
|
-
logoImage: { logoDraftToken: 'test-token', logoVariation: 0 },
|
|
302
|
-
},
|
|
303
|
-
} as any;
|
|
304
|
-
|
|
305
|
-
const model = new BrandPageModel(data);
|
|
306
|
-
|
|
307
|
-
const result = await migration06(model, { skipMigration06: false });
|
|
308
|
-
|
|
309
|
-
// Each section should calculate dimensions based on its own constraints
|
|
310
|
-
// Since we can't mock the API response, we verify that the function doesn't crash
|
|
311
|
-
// and that each section maintains its structure
|
|
312
|
-
expect(result.pageHeaderDesktop).toBeDefined();
|
|
313
|
-
expect(result.pageHeaderMobile).toBeDefined();
|
|
314
|
-
expect(result.pageFooterDesktop).toBeDefined();
|
|
315
|
-
expect(result.pageFooterMobile).toBeDefined();
|
|
316
|
-
|
|
317
|
-
// Verify that different sections can have different dimensions
|
|
318
|
-
// (This test will pass whether the API succeeds or fails gracefully)
|
|
319
|
-
expect(typeof result.pageHeaderDesktop.logoImageWidth).toBe('string');
|
|
320
|
-
expect(typeof result.pageHeaderDesktop.logoImageHeight).toBe('string');
|
|
321
|
-
expect(typeof result.pageHeaderMobile.logoImageWidth).toBe('string');
|
|
322
|
-
expect(typeof result.pageHeaderMobile.logoImageHeight).toBe('string');
|
|
323
|
-
expect(typeof result.pageFooterDesktop.logoImageWidth).toBe('string');
|
|
324
|
-
expect(typeof result.pageFooterDesktop.logoImageHeight).toBe('string');
|
|
325
|
-
expect(typeof result.pageFooterMobile.logoImageWidth).toBe('string');
|
|
326
|
-
expect(typeof result.pageFooterMobile.logoImageHeight).toBe('string');
|
|
327
|
-
|
|
328
|
-
// Logo image objects should be preserved for all sections
|
|
329
|
-
expect(result.pageHeaderDesktop.logoImage.logoDraftToken).toBe(
|
|
330
|
-
'test-token',
|
|
331
|
-
);
|
|
332
|
-
expect(result.pageHeaderMobile.logoImage.logoDraftToken).toBe('test-token');
|
|
333
|
-
expect(result.pageFooterDesktop.logoImage.logoDraftToken).toBe(
|
|
334
|
-
'test-token',
|
|
335
|
-
);
|
|
336
|
-
expect(result.pageFooterMobile.logoImage.logoDraftToken).toBe('test-token');
|
|
337
|
-
});
|
|
338
|
-
});
|