Skip to content

Commit

Permalink
Merge branch 'feature/GH-11637-pdp' of https://github.com/SAP/spartacus
Browse files Browse the repository at this point in the history
… into feature/GH-11637-pdp
  • Loading branch information
Zeyber committed Jul 8, 2024
2 parents 1ef8b9c + 5745744 commit eca74ee
Show file tree
Hide file tree
Showing 747 changed files with 15,919 additions and 9,931 deletions.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
sonar-project.properties
sub-folder/
.pipeline/
tmp/**
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"singleQuote": true
"singleQuote": true,
"trailingComma": "es5"
}
24 changes: 17 additions & 7 deletions ci-scripts/publish-sample-data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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

Expand All @@ -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"
9 changes: 7 additions & 2 deletions ci-scripts/release-packer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -49,6 +52,8 @@ function pack {

if [[ $1 == 'configure' ]]; then
configure_project
elif [[ $1 == 'build' ]]; then
build_libs
else
clear_root
pack "$1"
Expand Down
10 changes: 5 additions & 5 deletions core-libs/setup/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand Down
54 changes: 52 additions & 2 deletions core-libs/setup/ssr/optimized-engine/optimized-ssr-engine.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ describe('OptimizedSsrEngine', () => {
});
});
});

describe('logOptions', () => {
let dateSpy: jest.SpyInstance;

Expand All @@ -151,6 +152,10 @@ describe('OptimizedSsrEngine', () => {
dateSpy.mockReset();
});

afterAll(() => {
dateSpy.mockRestore();
});

it('should log the provided options', () => {
new TestEngineRunner({
timeout: 50,
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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', () => {
Expand Down
3 changes: 2 additions & 1 deletion core-libs/setup/ssr/optimized-engine/optimized-ssr-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string>();

Expand Down Expand Up @@ -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();
}

Expand Down
17 changes: 15 additions & 2 deletions feature-libs/asm/assets/translations/en/asm.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
7 changes: 6 additions & 1 deletion feature-libs/asm/components/asm-components.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -58,6 +62,7 @@ import { DotSpinnerComponent } from './dot-spinner/dot-spinner.component';
SortingModule,
PaginationModule,
MessageComponentModule,
FeaturesConfigModule,
],
declarations: [
AsmBindCartDialogComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,13 @@ <h2 class="title modal-title">
<div class="modal-footer">
<button
type="submit"
class="
btn
cx-asm-create-customer-btn cx-asm-create-customer-btn-create
"
class="btn cx-asm-create-customer-btn cx-asm-create-customer-btn-create"
>
{{ 'asm.createCustomerForm.createAccount' | cxTranslate }}
</button>
<button
type="button"
class="
btn
cx-asm-create-customer-btn cx-asm-create-customer-btn-cancel
"
class="btn cx-asm-create-customer-btn cx-asm-create-customer-btn-cancel"
(click)="closeModal('Cancel click')"
>
{{ 'asm.createCustomerForm.cancel' | cxTranslate }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,29 +111,27 @@ describe('AsmCreateCustomerFormComponent', () => {
let launchDialogService: LaunchDialogService;
let asmCreateCustomerFacade: AsmCreateCustomerFacade;

beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [I18nTestingModule],
declarations: [
AsmCreateCustomerFormComponent,
MockCxIconComponent,
MockKeyboadFocusDirective,
],
providers: [
{ provide: LaunchDialogService, useClass: MockLaunchDialogService },
{
provide: AsmCreateCustomerFacade,
useClass: MockAsmCreateCustomerFacade,
},
],
schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
}).compileComponents();

launchDialogService = TestBed.inject(LaunchDialogService);
asmCreateCustomerFacade = TestBed.inject(AsmCreateCustomerFacade);
})
);
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [I18nTestingModule],
declarations: [
AsmCreateCustomerFormComponent,
MockCxIconComponent,
MockKeyboadFocusDirective,
],
providers: [
{ provide: LaunchDialogService, useClass: MockLaunchDialogService },
{
provide: AsmCreateCustomerFacade,
useClass: MockAsmCreateCustomerFacade,
},
],
schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
}).compileComponents();

launchDialogService = TestBed.inject(LaunchDialogService);
asmCreateCustomerFacade = TestBed.inject(AsmCreateCustomerFacade);
}));

beforeEach(() => {
fixture = TestBed.createComponent(AsmCreateCustomerFormComponent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
<ng-template #showCustomerSelection>
<cx-customer-selection
*ngIf="notCollapsed"
(submitEvent)="startCustomerEmulationSession($event)"
(submitEvent)="startCustomerEmulationSession($event, $event.parameters)"
></cx-customer-selection>
</ng-template>
</ng-container>
Expand Down
Loading

0 comments on commit eca74ee

Please sign in to comment.