diff --git a/.npmignore b/.npmignore index 3ba6feeee01..b7599e66bb7 100644 --- a/.npmignore +++ b/.npmignore @@ -2,3 +2,4 @@ sonar-project.properties sub-folder/ .pipeline/ +tmp/** diff --git a/.prettierrc b/.prettierrc index 544138be456..c1a6f667131 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,3 +1,4 @@ { - "singleQuote": true + "singleQuote": true, + "trailingComma": "es5" } diff --git a/ci-scripts/publish-sample-data.sh b/ci-scripts/publish-sample-data.sh index 45a9c403557..d2e418599bf 100755 --- a/ci-scripts/publish-sample-data.sh +++ b/ci-scripts/publish-sample-data.sh @@ -4,8 +4,12 @@ TAG_NAME="sampledata" SAMPLE_DATA_ASSETS_FOLDER="sample-data-assets" STOREFRONT_FILE_NAME="spartacussampledata" -SAMPLE_DATA_UNRELEASED_BRANCH="release/6.x" -UNRELEASED_SPARTACUS_VERSION_NAME="$STOREFRONT_FILE_NAME-version-6-x" + +SAMPLE_DATA_UNRELEASED_BRANCH="release/2211.x" +UNRELEASED_SPARTACUS_VERSION_NAME="$STOREFRONT_FILE_NAME-version-2211-x" + +SAMPLE_DATA_UNRELEASED_BRANCH6="release/6.x" +UNRELEASED_SPARTACUS_VERSION_NAME6="$STOREFRONT_FILE_NAME-version-6-x" SAMPLE_DATA_CURRENT_BRANCH="release/5.x" CURRENT_SPARTACUS_VERSION_NAME="$STOREFRONT_FILE_NAME-version-5-x" @@ -23,12 +27,17 @@ function download_sample_data_from_spartacussample_repo { } echo "-----" -echo "Downloading UNRELEASED sample data for 6.x" +echo "Downloading PREVIOUS sample data for 6.x" download_sample_data_from_spartacussample_repo $SAMPLE_DATA_UNRELEASED_BRANCH $UNRELEASED_SPARTACUS_VERSION_NAME echo "-----" -echo "Downloading CURRENT sample data for 5.x" +echo "Downloading PREVIOUS sample data for 6.x" + +download_sample_data_from_spartacussample_repo $SAMPLE_DATA_UNRELEASED_BRANCH6 $UNRELEASED_SPARTACUS_VERSION_NAME6 + +echo "-----" +echo "Downloading PREVIOUS sample data for 5.x" download_sample_data_from_spartacussample_repo $SAMPLE_DATA_CURRENT_BRANCH $CURRENT_SPARTACUS_VERSION_NAME @@ -55,7 +64,8 @@ echo "-----" echo "Create a release with created tag" gh release create $TAG_NAME ./$SAMPLE_DATA_ASSETS_FOLDER/** --repo "https://$GH_TOKEN@github.com/SAP-samples/cloud-commerce-sample-setup.git" --title "Spartacus Sample Data" --notes "Spartacus sample data releases: -6-x: unreleased -5-x: current release +2211-x: current release +6-x: previous release +5-x: previous release 4-x: previous release -3-x: old release" +3-x: old release" \ No newline at end of file diff --git a/ci-scripts/release-packer.sh b/ci-scripts/release-packer.sh index 690df6b02f4..17583a51e24 100755 --- a/ci-scripts/release-packer.sh +++ b/ci-scripts/release-packer.sh @@ -5,12 +5,15 @@ set -e shopt -s extglob dotglob +# Build all the libraries and generate the dist folders to use when releasing +function build_libs { + npm ci && npm run build:libs +} + # Configure the project to move everything into a sub-folder to keep root clean for publishing function configure_project { mkdir sub-folder mv !(sub-folder) sub-folder - cd sub-folder - npm ci && npm run build:libs } # Clear root containing the old package so the next package can be published @@ -49,6 +52,8 @@ function pack { if [[ $1 == 'configure' ]]; then configure_project +elif [[ $1 == 'build' ]]; then + build_libs else clear_root pack "$1" diff --git a/core-libs/setup/package.json b/core-libs/setup/package.json index 25b4c84b539..23d96af4548 100644 --- a/core-libs/setup/package.json +++ b/core-libs/setup/package.json @@ -1,6 +1,6 @@ { "name": "@spartacus/setup", - "version": "2211.24.0", + "version": "2211.25.1", "description": "Includes features that makes Spartacus and it's setup easier and streamlined.", "keywords": [ "spartacus", @@ -21,10 +21,10 @@ "peerDependencies": { "@angular/core": "^17.0.5", "@angular/ssr": "^17.0.5", - "@spartacus/cart": "2211.24.0", - "@spartacus/core": "2211.24.0", - "@spartacus/order": "2211.24.0", - "@spartacus/user": "2211.24.0" + "@spartacus/cart": "2211.25.1", + "@spartacus/core": "2211.25.1", + "@spartacus/order": "2211.25.1", + "@spartacus/user": "2211.25.1" }, "optionalDependencies": { "@angular/platform-server": "^17.0.5", diff --git a/core-libs/setup/ssr/optimized-engine/optimized-ssr-engine.spec.ts b/core-libs/setup/ssr/optimized-engine/optimized-ssr-engine.spec.ts index 763e56cb506..561aeba796a 100644 --- a/core-libs/setup/ssr/optimized-engine/optimized-ssr-engine.spec.ts +++ b/core-libs/setup/ssr/optimized-engine/optimized-ssr-engine.spec.ts @@ -137,6 +137,7 @@ describe('OptimizedSsrEngine', () => { }); }); }); + describe('logOptions', () => { let dateSpy: jest.SpyInstance; @@ -151,6 +152,10 @@ describe('OptimizedSsrEngine', () => { dateSpy.mockReset(); }); + afterAll(() => { + dateSpy.mockRestore(); + }); + it('should log the provided options', () => { new TestEngineRunner({ timeout: 50, @@ -181,6 +186,30 @@ describe('OptimizedSsrEngine', () => { }); }); + describe('rendering cache', () => { + it('should be initialized with default optimization options none of the custom options are provided', () => { + const engineRunner = new TestEngineRunner({}); + expect( + engineRunner.optimizedSsrEngine['renderingCache']['options'] + ).toEqual(defaultSsrOptimizationOptions); + }); + + it('should be initialized with the provided custom options', () => { + const engineRunner = new TestEngineRunner({ + cacheSize: 100, + ttl: 200, + }); + expect(engineRunner.optimizedSsrEngine['renderingCache']).toBeDefined(); + expect( + engineRunner.optimizedSsrEngine['renderingCache']['options'] + ).toEqual({ + ...defaultSsrOptimizationOptions, + cacheSize: 100, + ttl: 200, + }); + }); + }); + describe('timeout option', () => { it('should fallback to CSR if rendering exceeds timeout', fakeAsync(() => { const engineRunner = new TestEngineRunner({ timeout: 50 }).request('a'); @@ -376,6 +405,27 @@ describe('OptimizedSsrEngine', () => { tick(200); expect(engineRunner.renders).toEqual(['a-0', 'a-0', 'a-1']); })); + + it('should not invalidate renders if ttl is not defined', fakeAsync(() => { + let currentDate = 100; + jest.spyOn(Date, 'now').mockImplementation(() => currentDate); + + const engineRunner = new TestEngineRunner({ + cache: true, + timeout: 200, + }).request('a'); + + tick(200); + currentDate += 200; + engineRunner.request('a'); + + tick(200); + currentDate += 200; + engineRunner.request('a'); + + tick(200); + expect(engineRunner.renders).toEqual(['a-0', 'a-0', 'a-0']); + })); }); describe('renderKeyResolver option', () => { @@ -1206,8 +1256,8 @@ describe('OptimizedSsrEngine', () => { .mockImplementationOnce(() => mockDate); }); - afterEach(() => { - dateSpy.mockReset(); + afterAll(() => { + dateSpy.mockRestore(); }); it('should use the default server logger, if custom logger is not specified', () => { diff --git a/core-libs/setup/ssr/optimized-engine/optimized-ssr-engine.ts b/core-libs/setup/ssr/optimized-engine/optimized-ssr-engine.ts index 0d5b22b53aa..6d3ec10595d 100644 --- a/core-libs/setup/ssr/optimized-engine/optimized-ssr-engine.ts +++ b/core-libs/setup/ssr/optimized-engine/optimized-ssr-engine.ts @@ -45,7 +45,7 @@ export type SsrCallbackFn = ( */ export class OptimizedSsrEngine { protected currentConcurrency = 0; - protected renderingCache = new RenderingCache(this.ssrOptions); + protected renderingCache: RenderingCache; private logger: ExpressServerLogger; private templateCache = new Map(); @@ -81,6 +81,7 @@ export class OptimizedSsrEngine { throw new Error('`SsrOptimizationOptions.logger` is not defined'); } this.logger = this.ssrOptions?.logger; + this.renderingCache = new RenderingCache(this.ssrOptions); this.logOptions(); } diff --git a/core-libs/setup/tsconfig.spec.json b/core-libs/setup/tsconfig.spec.json index a63f9b6c460..290c6e0060a 100644 --- a/core-libs/setup/tsconfig.spec.json +++ b/core-libs/setup/tsconfig.spec.json @@ -549,6 +549,7 @@ "../../integration-libs/cdp/customer-ticketing/public_api" ], "@spartacus/cdp": ["../../integration-libs/cdp/public_api"], + "@spartacus/cds/assets": ["../../integration-libs/cds/assets/public_api"], "@spartacus/cds": ["../../integration-libs/cds/public_api"], "@spartacus/digital-payments/assets": [ "../../integration-libs/digital-payments/assets/public_api" diff --git a/feature-libs/asm/assets/translations/en/asm.json b/feature-libs/asm/assets/translations/en/asm.json index b9fe1ccfd6c..e32e231cd99 100644 --- a/feature-libs/asm/assets/translations/en/asm.json +++ b/feature-libs/asm/assets/translations/en/asm.json @@ -27,11 +27,21 @@ "searchTerm": { "label": "Customer Name/Email Address" }, + "searchCustomer": { + "label": "Search by name or email address" + }, + "searchOrder": { + "label": "Search by full order ID" + }, "submit": "Start Session", "startEmulation": "Start Emulation", "noMatch": "No customer found.", "noMatchResult": "This account cannot be found.", - "createCustomer": "Create New Customer" + "noCustomerMatchResult": "No matching customer found.", + "noOrderMatchResult": "Search by full order ID.", + "createCustomer": "Create New Customer", + "customer": "Customer", + "orderID": "Order ID" }, "createCustomerForm": { "title": "Create New Customer", @@ -74,8 +84,11 @@ "order": "Order", "view": "360 View", "activeCart": "Active Cart", + "viewActiveCart": "View Active Cart", "orders": "Orders", - "customer360": "Customer 360°" + "viewOrders": "View Orders", + "customer360": "Customer 360°", + "viewCustomer360": "View Customer 360°" }, "tableSort": { "sortBy": "Sort by", diff --git a/feature-libs/asm/components/asm-components.module.ts b/feature-libs/asm/components/asm-components.module.ts index 21548afbf9a..4860f252938 100644 --- a/feature-libs/asm/components/asm-components.module.ts +++ b/feature-libs/asm/components/asm-components.module.ts @@ -8,7 +8,11 @@ import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { NgSelectModule } from '@ng-select/ng-select'; -import { I18nModule, provideDefaultConfig } from '@spartacus/core'; +import { + FeaturesConfigModule, + I18nModule, + provideDefaultConfig, +} from '@spartacus/core'; import { FormErrorsModule, IconModule, @@ -58,6 +62,7 @@ import { DotSpinnerComponent } from './dot-spinner/dot-spinner.component'; SortingModule, PaginationModule, MessageComponentModule, + FeaturesConfigModule, ], declarations: [ AsmBindCartDialogComponent, diff --git a/feature-libs/asm/components/asm-create-customer-form/asm-create-customer-form.component.html b/feature-libs/asm/components/asm-create-customer-form/asm-create-customer-form.component.html index 38e9cde6b90..c407d368005 100644 --- a/feature-libs/asm/components/asm-create-customer-form/asm-create-customer-form.component.html +++ b/feature-libs/asm/components/asm-create-customer-form/asm-create-customer-form.component.html @@ -102,19 +102,13 @@