Skip to content

Commit

Permalink
Merge a004277 into a496d58
Browse files Browse the repository at this point in the history
  • Loading branch information
pawelfras authored Dec 19, 2024
2 parents a496d58 + a004277 commit 631bef5
Show file tree
Hide file tree
Showing 996 changed files with 11,848 additions and 7,539 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
],
"plugins": ["deprecation", "@typescript-eslint", "@nx", "@stylistic/ts"],
"rules": {
"@angular-eslint/no-host-metadata-property": "off",
"deprecation/deprecation": "warn",
"prefer-arrow/prefer-arrow-functions": "off",
"space-before-function-paren": "off",
Expand All @@ -30,6 +29,7 @@
"no-fallthrough": "off",
"prefer-const": "off",
"@angular-eslint/use-lifecycle-interface": "error",
"@angular-eslint/prefer-standalone": "off",
"@stylistic/ts/quotes": "off",
"@stylistic/ts/member-delimiter-style": [
"error",
Expand Down
15 changes: 12 additions & 3 deletions core-libs/setup/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,18 @@ const { defaultTransformerOptions } = require('jest-preset-angular/presets');
/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */
module.exports = {
preset: 'jest-preset-angular',
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths || {}, {
prefix: '<rootDir>/',
}),
moduleNameMapper: {
...pathsToModuleNameMapper(compilerOptions.paths || {}, {
prefix: '<rootDir>/',
}),
// mapping required to use `beasties` from node modules that has proper ES module format
// instead of the version internalized by the Angular Team which file format is not supported
// by Jest.
// for more, see: https://github.com/angular/angular-cli/pull/28228
// and: https://github.com/angular/angular-cli/pull/28726
'^../third_party/beasties/index.js$':
'<rootDir>/../../node_modules/beasties',
},
setupFilesAfterEnv: ['<rootDir>/setup-jest.ts'],
transform: {
'^.+\\.(ts|js|mjs|html|svg)$': [
Expand Down
6 changes: 3 additions & 3 deletions core-libs/setup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
"tslib": "^2.6.2"
},
"peerDependencies": {
"@angular/core": "^18.2.9",
"@angular/ssr": "^18.2.9",
"@angular/core": "^19.0.3",
"@angular/ssr": "^19.0.4",
"@spartacus/cart": "2211.32.0-1",
"@spartacus/core": "2211.32.0-1",
"@spartacus/order": "2211.32.0-1",
"@spartacus/user": "2211.32.0-1"
},
"optionalDependencies": {
"@angular/platform-server": "^18.2.9",
"@angular/platform-server": "^19.0.3",
"express": "^4.21.2"
},
"publishConfig": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { CommonEngineOptions, CommonEngineRenderOptions } from '@angular/ssr';
import {
CommonEngineOptions,
CommonEngineRenderOptions,
} from '@angular/ssr/node';
import { NgSetupOptions } from '../engine/ng-express-engine';
import {
OptimizedSsrEngine,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ exports[`CxCommonEngine should handle APP_INITIALIZER errors the standard Angula

exports[`CxCommonEngine should handle errors propagated from SSR 1`] = `"test error"`;

exports[`CxCommonEngine should not override providers passed to options 1`] = `"<html data-critters-container><head></head><body><cx-token ng-version="18.2.9" ng-server-context="ssr">message:test</cx-token></body></html>"`;
exports[`CxCommonEngine should not override providers passed to options 1`] = `"<html data-beasties-container><head></head><body><cx-token ng-version="19.0.3" ng-server-context="ssr">message:test</cx-token></body></html>"`;

exports[`CxCommonEngine should return html if no errors 1`] = `"<html data-critters-container><head></head><body><cx-mock ng-version="18.2.9" ng-server-context="ssr">some template</cx-mock></body></html>"`;
exports[`CxCommonEngine should return html if no errors 1`] = `"<html data-beasties-container><head></head><body><cx-mock ng-version="19.0.3" ng-server-context="ssr">some template</cx-mock></body></html>"`;
8 changes: 7 additions & 1 deletion core-libs/setup/ssr/engine/cx-common-engine.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import { PROPAGATE_ERROR_TO_SERVER } from '../error-handling/error-response/prop
import { CxCommonEngine } from './cx-common-engine';

// Test how the CxCommonEngine handles successful server-side rendering
@Component({ selector: 'cx-mock', template: 'some template' })
@Component({
selector: 'cx-mock',
template: 'some template',
standalone: false,
})
export class SuccessComponent {}

@NgModule({
Expand All @@ -22,6 +26,7 @@ export class SuccessServerModule {}
@Component({
selector: 'cx-response',
template: ``,
standalone: false,
})
export class WithPropagatedErrorComponent {
constructor() {
Expand All @@ -43,6 +48,7 @@ export const SOME_TOKEN = new InjectionToken<string>('SOME_TOKEN');
@Component({
selector: 'cx-token',
template: `message:{{ someToken }}`,
standalone: false,
})
export class TokenComponent {
someToken = inject(SOME_TOKEN);
Expand Down
2 changes: 1 addition & 1 deletion core-libs/setup/ssr/engine/cx-common-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
CommonEngine,
CommonEngineOptions,
CommonEngineRenderOptions,
} from '@angular/ssr';
} from '@angular/ssr/node';
import { PROPAGATE_ERROR_TO_SERVER } from '../error-handling/error-response/propagate-error-to-server';

/**
Expand Down
14 changes: 12 additions & 2 deletions core-libs/setup/ssr/engine/ng-express-engine.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ import { ngExpressEngine } from './ng-express-engine';
* - https://github.com/angular/universal/blob/e798d256de5e4377b704e63d993dc56ea35df97d/modules/express-engine/spec/mock.server.module.ts
*
*/
@Component({ selector: 'cx-mock', template: 'some template' })
@Component({
selector: 'cx-mock',
template: 'some template',
standalone: false,
})
export class MockComponent {}

/**
Expand Down Expand Up @@ -57,7 +61,11 @@ export class MockServerModule {}
* - https://github.com/angular/universal/blob/e798d256de5e4377b704e63d993dc56ea35df97d/modules/express-engine/spec/mock.server.module.ts
*
*/
@Component({ selector: 'cx-request', template: `url:{{ _req.url }}` })
@Component({
selector: 'cx-request',
template: `url:{{ _req.url }}`,
standalone: false,
})
export class RequestComponent {
constructor(@Inject(REQUEST) public readonly _req: any) {}
}
Expand Down Expand Up @@ -94,6 +102,7 @@ export class RequestServerModule {}
@Component({
selector: 'cx-response',
template: `statusCode:{{ _res.statusCode }}`,
standalone: false,
})
export class ResponseComponent {
constructor(@Inject(RESPONSE) public readonly _res: any) {}
Expand Down Expand Up @@ -144,6 +153,7 @@ export const SOME_TOKEN = new InjectionToken<string>('SOME_TOKEN');
@Component({
selector: 'cx-token',
template: `message:{{ _someToken.message }}`,
standalone: false,
})
export class TokenComponent {
constructor(@Inject(SOME_TOKEN) public readonly _someToken: any) {}
Expand Down
5 changes: 4 additions & 1 deletion core-libs/setup/ssr/engine/ng-express-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
*/

import { StaticProvider } from '@angular/core';
import { CommonEngineOptions, CommonEngineRenderOptions } from '@angular/ssr';
import {
CommonEngineOptions,
CommonEngineRenderOptions,
} from '@angular/ssr/node';
import { Request, Response } from 'express';
import { REQUEST, RESPONSE } from '../tokens/express.tokens';
import { CxCommonEngine } from './cx-common-engine';
Expand Down
5 changes: 4 additions & 1 deletion core-libs/setup/ssr/optimized-engine/rendering-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ export class RenderingCache {
if (this.options?.cacheSize) {
this.renders.delete(key);
if (this.renders.size >= this.options.cacheSize) {
this.renders.delete(this.renders.keys().next().value);
const oldestKey = this.renders.keys().next().value;
if (oldestKey !== undefined) {
this.renders.delete(oldestKey);
}
}
}
// cache only if shouldCacheRenderingResult return true
Expand Down
7 changes: 6 additions & 1 deletion feature-libs/asm/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
"extends": "../../.eslintrc.json",
"ignorePatterns": ["schematics/**/*.d.ts"]
"ignorePatterns": ["schematics/**/*.d.ts"],
"overrides": [
{
"files": ["*.ts"]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {

@Pipe({
name: 'cxTranslate',
standalone: false,
})
class MockTranslatePipe implements PipeTransform {
transform(): any {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export enum BIND_CART_DIALOG_ACTION {
@Component({
selector: 'cx-asm-bind-cart-dialog',
templateUrl: './asm-bind-cart-dialog.component.html',
standalone: false,
})
export class AsmBindCartDialogComponent {
BIND_CART_ACTION = BIND_CART_DIALOG_ACTION;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import createSpy = jasmine.createSpy;
@Component({
selector: 'cx-icon',
template: '',
standalone: false,
})
class MockCxIconComponent {
@Input() type: ICON_TYPE;
Expand Down Expand Up @@ -85,6 +86,7 @@ class MockActiveCartService implements Partial<ActiveCartFacade> {

@Pipe({
name: 'cxTranslate',
standalone: false,
})
class MockTranslatePipe implements PipeTransform {
transform(): any {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import { AsmComponentService } from '../services/asm-component.service';
selector: 'cx-asm-bind-cart',
templateUrl: './asm-bind-cart.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: false,
})
export class AsmBindCartComponent implements OnInit, OnDestroy {
activeCartValidator: ValidatorFn = (control) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const duplicatedUidErrorResponse: HttpErrorModel = {
@Component({
selector: 'cx-icon',
template: '',
standalone: false,
})
class MockCxIconComponent {
@Input() type: ICON_TYPE;
Expand All @@ -99,6 +100,7 @@ class MockAsmCreateCustomerFacade implements Partial<AsmCreateCustomerFacade> {

@Directive({
selector: '[cxFocus]',
standalone: false,
})
export class MockKeyboadFocusDirective {
@Input('cxFocus') config: FocusConfig = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { CreatedCustomer } from './asm-create-customer-form.model';
@Component({
selector: 'cx-asm-create-customer-form',
templateUrl: './asm-create-customer-form.component.html',
standalone: false,
})
export class AsmCreateCustomerFormComponent {
createdCustomer: CreatedCustomer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class MockAuthService implements Partial<AuthService> {
@Component({
selector: 'cx-icon',
template: '',
standalone: false,
})
class MockCxIconComponent {
@Input() type: ICON_TYPE;
Expand Down Expand Up @@ -103,18 +104,21 @@ class MockLaunchDialogService implements Partial<LaunchDialogService> {
@Component({
selector: 'cx-asm-toggle-ui',
template: '',
standalone: false,
})
class MockAsmToggleUiComponent {}

@Component({
selector: 'cx-asm-session-timer',
template: '',
standalone: false,
})
class MockAsmSessionTimerComponent {}

@Component({
selector: 'cx-customer-selection',
template: '',
standalone: false,
})
class MockCustomerSelectionComponent {
@Output()
Expand All @@ -123,6 +127,7 @@ class MockCustomerSelectionComponent {
@Component({
selector: 'cx-csagent-login-form',
template: '',
standalone: false,
})
class MockCSAgentLoginFormComponent {
@Output()
Expand All @@ -133,6 +138,7 @@ class MockCSAgentLoginFormComponent {
@Component({
template: '',
selector: 'cx-customer-emulation',
standalone: false,
})
class MockCustomerEmulationComponent {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export const CART_TYPE_KEY: CartTypeKey = {
@Component({
selector: 'cx-asm-main-ui',
templateUrl: './asm-main-ui.component.html',
standalone: false,
})
export class AsmMainUiComponent implements OnInit, OnDestroy {
customerSupportAgentLoggedIn$: Observable<boolean>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { GlobalMessageType } from '@spartacus/core';

@Pipe({
name: 'cxTranslate',
standalone: false,
})
class MockTranslatePipe implements PipeTransform {
transform(): any {}
Expand All @@ -47,6 +48,7 @@ class MockLaunchDialogService implements Partial<LaunchDialogService> {
@Component({
selector: 'cx-message',
template: '',
standalone: false,
})
class MockCxMessageComponent {
@Input() text: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export enum SAVE_CART_DIALOG_ACTION {
@Component({
selector: 'cx-asm-save-cart-dialog',
templateUrl: './asm-save-cart-dialog.component.html',
standalone: false,
})
export class AsmSaveCartDialogComponent implements OnInit {
BIND_CART_ACTION = SAVE_CART_DIALOG_ACTION;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class MockRoutingService implements Partial<RoutingService> {

@Pipe({
name: 'formatTimer',
standalone: false,
})
class MockFormatTimerPipe implements PipeTransform {
transform() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { AsmComponentService } from '../services/asm-component.service';
@Component({
selector: 'cx-asm-session-timer',
templateUrl: './asm-session-timer.component.html',
standalone: false,
})
export class AsmSessionTimerComponent implements OnInit, OnDestroy {
protected subscriptions = new Subscription();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
name: 'formatTimer',
standalone: false,
})
export class FormatTimerPipe implements PipeTransform {
transform(totalSeconds: number): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {

@Pipe({
name: 'cxTranslate',
standalone: false,
})
class MockTranslatePipe implements PipeTransform {
transform(): any {}
Expand All @@ -46,6 +47,7 @@ class MockAsmComponentService extends AsmComponentService {
@Component({
selector: 'cx-icon',
template: '',
standalone: false,
})
class MockCxIconComponent {
@Input() type: ICON_TYPE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface SwitchCustomerData {
@Component({
selector: 'cx-asm-switch-customer-dialog',
templateUrl: './asm-switch-customer-dialog.component.html',
standalone: false,
})
export class AsmSwitchCustomerDialogComponent implements OnInit {
SWITCH_CUSTOMER_DIALOG_ACTION = SWITCH_CUSTOMER_DIALOG_ACTION;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { Subscription } from 'rxjs';
@Component({
selector: 'cx-asm-toggle-ui',
templateUrl: './asm-toggle-ui.component.html',
standalone: false,
})
export class AsmToggleUiComponent implements OnInit, OnDestroy {
protected subscription = new Subscription();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { useFeatureStyles } from '@spartacus/core';
@Component({
selector: 'cx-csagent-login-form',
templateUrl: './csagent-login-form.component.html',
standalone: false,
})
export class CSAgentLoginFormComponent implements OnInit {
csAgentLoginForm: UntypedFormGroup;
Expand Down
Loading

0 comments on commit 631bef5

Please sign in to comment.