Skip to content

Commit

Permalink
Pipeline fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Matejk00 committed Sep 17, 2024
1 parent 153ec98 commit 72ac43a
Show file tree
Hide file tree
Showing 21 changed files with 101 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import { TestBed } from '@angular/core/testing';
import { of } from 'rxjs';

import { BaseSiteService, StringTemplate } from '@spartacus/core';
import { OpfApiConfig } from '@spartacus/opf/base/opf-api';
import { OpfConfig } from '@spartacus/opf/base/root';
import { OpfApiConfig, OpfConfig } from '@spartacus/opf/base/root';
import { OpfEndpointsService } from './opf-endpoints.service';

describe('OpfEndpointsService', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import {
DynamicAttributes,
StringTemplate,
} from '@spartacus/core';
import { OpfApiConfig } from '@spartacus/opf/base/opf-api';
import { OpfConfig } from '@spartacus/opf/base/root';

import { OpfApiConfig, OpfConfig } from '@spartacus/opf/base/root';

@Injectable({
providedIn: 'root',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { OpfApiConfig } from './opf-api.config';
import { OpfApiConfig } from '@spartacus/opf/base/root';

export const defaultOpfApiBaseConfig: OpfApiConfig = {
backend: {
Expand Down
2 changes: 0 additions & 2 deletions integration-libs/opf/base/opf-api/model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@
* SPDX-License-Identifier: Apache-2.0
*/

export * from './opf-api-backend.model';
export * from './opf-api-base-endpoints.model';
export * from './opf-api-endpoint.model';
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { OpfApiEndpoint } from './opf-api-endpoint.model';
import { OpfApiEndpoint } from '@spartacus/opf/base/root';

export interface OpfApiEndpoints {
/**
* Endpoint to get active payment configurations
*/
getActiveConfigurations?: string | OpfApiEndpoint;
declare module '@spartacus/opf/base/root' {
interface OpfApiEndpoints {
/**
* Endpoint to get active payment configurations
*/
getActiveConfigurations?: string | OpfApiEndpoint;
}
}
1 change: 0 additions & 1 deletion integration-libs/opf/base/opf-api/public_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
* SPDX-License-Identifier: Apache-2.0
*/

export * from './config/index';
export * from './model/index';
export * from './opf-api-base.module';
1 change: 1 addition & 0 deletions integration-libs/opf/base/root/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@

export * from './constants';
export * from './default-opf-config';
export * from './opf-api-config';
export * from './opf-config';
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { Injectable } from '@angular/core';
import { Config } from '@spartacus/core';
import { OpfApiBackendConfig } from '../model';
import { OpfApiBackendConfig } from '../model/opf-api-backend-config.model';

@Injectable({
providedIn: 'root',
Expand Down
3 changes: 3 additions & 0 deletions integration-libs/opf/base/root/model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
*/

import './augmented-core.model';
export * from './opf-api-backend-config.model';
export * from './opf-api-endpoint.model';
export * from './opf-api-endpoints.model';
export * from './opf-base.model';
export * from './opf-error-dialog.model';
export * from './opf-metadata-store.model';
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { OpfApiEndpoints } from './opf-api-base-endpoints.model';
import { OpfApiEndpoints } from './opf-api-endpoints.model';

export interface OpfApiBackendConfig {
opfApi?: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
* SPDX-License-Identifier: Apache-2.0
*/

export * from './opf-api.config';
export interface OpfApiEndpoints {}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class OpfCheckoutBillingAddressFormService {
protected checkoutPaymentService: CheckoutPaymentFacade,
protected activeCartService: ActiveCartFacade,
protected globalMessageService: GlobalMessageService,
protected opfService: OpfCheckoutPaymentWrapperService
protected opfCheckoutPaymentWrapperService: OpfCheckoutPaymentWrapperService
) {}

getCountries(): Observable<Country[]> {
Expand Down Expand Up @@ -135,7 +135,7 @@ export class OpfCheckoutBillingAddressFormService {
this.billingAddressId = billingAddress.id;

this.billingAddressSub.next(billingAddress);
this.opfService.reloadPaymentMode();
this.opfCheckoutPaymentWrapperService.reloadPaymentMode();
}
}),
catchError((error: HttpErrorModel) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ export class OpfCheckoutPaymentWrapperService {
});

constructor(
protected opfPaymentService: OpfPaymentFacade,
protected opfPaymentFacade: OpfPaymentFacade,
protected opfResourceLoaderService: OpfResourceLoaderService,
protected userIdService: UserIdService,
protected activeCartService: ActiveCartFacade,
protected routingService: RoutingService,
protected globalMessageService: GlobalMessageService,
protected orderFacade: OrderFacade,
protected opfMetadataStoreService: OpfMetadataStoreService,
protected cartAccessCodeService: CartAccessCodeFacade
protected cartAccessCodeFacade: CartAccessCodeFacade
) {}

protected executeScriptFromHtml(html: string): void {
Expand Down Expand Up @@ -112,13 +112,13 @@ export class OpfCheckoutPaymentWrapperService {
),
switchMap(([userId, cartId]: [string, string]) => {
this.activeCartId = cartId;
return this.cartAccessCodeService.getCartAccessCode(userId, cartId);
return this.cartAccessCodeFacade.getCartAccessCode(userId, cartId);
}),
filter((response) => Boolean(response?.accessCode)),
map(({ accessCode: otpKey }) =>
this.setPaymentInitiationConfig(otpKey, paymentOptionId)
),
switchMap((params) => this.opfPaymentService.initiatePayment(params)),
switchMap((params) => this.opfPaymentFacade.initiatePayment(params)),
tap((paymentOptionConfig: PaymentSessionData | Error) => {
if (!(paymentOptionConfig instanceof Error)) {
this.storePaymentSessionId(paymentOptionConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { OpfApiConfig } from '@spartacus/opf/base/opf-api';
import { OpfApiConfig } from '@spartacus/opf/base/root';

export const defaultOpfApiCtaConfig: OpfApiConfig = {
backend: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { OpfApiEndpoint } from '@spartacus/opf/base/opf-api';
import { OpfApiEndpoint } from '@spartacus/opf/base/root';

declare module '@spartacus/opf/base/opf-api' {
declare module '@spartacus/opf/base/root' {
interface OpfApiEndpoints {
/**
* Endpoint to get CTA (Call To Action) Scripts
Expand Down
4 changes: 2 additions & 2 deletions integration-libs/opf/cta/root/opf-cta-root.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { NgModule } from '@angular/core';
import { CmsConfig, provideDefaultConfigFactory } from '@spartacus/core';
import { OPF_CTA_FEATURE } from './feature-name';

export function defaultOpfBaseCmsComponentsConfig(): CmsConfig {
export function defaultOpfCtaCmsComponentsConfig(): CmsConfig {
const config: CmsConfig = {
featureModules: {
[OPF_CTA_FEATURE]: {
Expand All @@ -20,6 +20,6 @@ export function defaultOpfBaseCmsComponentsConfig(): CmsConfig {
}

@NgModule({
providers: [provideDefaultConfigFactory(defaultOpfBaseCmsComponentsConfig)],
providers: [provideDefaultConfigFactory(defaultOpfCtaCmsComponentsConfig)],
})
export class OpfCtaRootModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { OpfApiConfig } from '@spartacus/opf/base/opf-api';
import { OpfApiConfig } from '@spartacus/opf/base/root';

export const defaultOpfApiPaymentConfig: OpfApiConfig = {
backend: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { OpfApiEndpoint } from '@spartacus/opf/base/opf-api';
import { OpfApiEndpoint } from '@spartacus/opf/base/root';

declare module '@spartacus/opf/base/opf-api' {
declare module '@spartacus/opf/base/root' {
interface OpfApiEndpoints {
/**
* Endpoint to verify a response from PSP for Full Page Redirect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,32 @@ describe('OpfPaymentVerificationComponent', () => {
let component: OpfPaymentVerificationComponent;
let fixture: ComponentFixture<OpfPaymentVerificationComponent>;
let routeMock: jasmine.SpyObj<ActivatedRoute>;
let paymentServiceMock: jasmine.SpyObj<OpfPaymentVerificationService>;
let opfPaymentVerificationServiceMock: jasmine.SpyObj<OpfPaymentVerificationService>;

beforeEach(() => {
routeMock = jasmine.createSpyObj('ActivatedRoute', [], {
snapshot: { queryParamMap: new Map() },
});
paymentServiceMock = jasmine.createSpyObj('OpfPaymentVerificationService', [
'checkIfProcessingCartIdExist',
'verifyResultUrl',
'goToPage',
'displayError',
'removeResourcesAndGlobalFunctions',
'runHostedFieldsPattern',
'runHostedPagePattern',
]);
opfPaymentVerificationServiceMock = jasmine.createSpyObj(
'OpfPaymentVerificationService',
[
'checkIfProcessingCartIdExist',
'verifyResultUrl',
'goToPage',
'displayError',
'removeResourcesAndGlobalFunctions',
'runHostedFieldsPattern',
'runHostedPagePattern',
]
);

TestBed.configureTestingModule({
declarations: [OpfPaymentVerificationComponent, MockSpinnerComponent],
providers: [
{ provide: ActivatedRoute, useValue: routeMock },
{
provide: OpfPaymentVerificationService,
useValue: paymentServiceMock,
useValue: opfPaymentVerificationServiceMock,
},
],
});
Expand All @@ -59,11 +62,11 @@ describe('OpfPaymentVerificationComponent', () => {

describe('ngOnInit', () => {
it('should call checkIfProcessingCartIdExist', () => {
paymentServiceMock.verifyResultUrl.and.returnValue(of());
opfPaymentVerificationServiceMock.verifyResultUrl.and.returnValue(of());

component.ngOnInit();
expect(
paymentServiceMock.checkIfProcessingCartIdExist
opfPaymentVerificationServiceMock.checkIfProcessingCartIdExist
).toHaveBeenCalled();
});

Expand All @@ -81,19 +84,24 @@ describe('OpfPaymentVerificationComponent', () => {
afterRedirectScriptFlag: mockAfterRedirectScriptFlag,
};

paymentServiceMock.verifyResultUrl.and.returnValue(of(mockVerifyResult));
paymentServiceMock.runHostedFieldsPattern.and.returnValue(of(true));
paymentServiceMock.runHostedPagePattern.and.returnValue(of(true));
opfPaymentVerificationServiceMock.verifyResultUrl.and.returnValue(
of(mockVerifyResult)
);
opfPaymentVerificationServiceMock.runHostedFieldsPattern.and.returnValue(
of(true)
);
opfPaymentVerificationServiceMock.runHostedPagePattern.and.returnValue(
of(true)
);

component.ngOnInit();

expect(paymentServiceMock.verifyResultUrl).toHaveBeenCalledWith(
routeMock
);
expect(paymentServiceMock.runHostedPagePattern).toHaveBeenCalledWith(
mockPaymentSessionId,
mockResponseMap
);
expect(
opfPaymentVerificationServiceMock.verifyResultUrl
).toHaveBeenCalledWith(routeMock);
expect(
opfPaymentVerificationServiceMock.runHostedPagePattern
).toHaveBeenCalledWith(mockPaymentSessionId, mockResponseMap);
});

it('should handle error scenario', () => {
Expand All @@ -105,8 +113,10 @@ describe('OpfPaymentVerificationComponent', () => {
afterRedirectScriptFlag: 'false',
};

paymentServiceMock.verifyResultUrl.and.returnValue(of(mockVerifyResult));
paymentServiceMock.runHostedPagePattern.and.returnValue(
opfPaymentVerificationServiceMock.verifyResultUrl.and.returnValue(
of(mockVerifyResult)
);
opfPaymentVerificationServiceMock.runHostedPagePattern.and.returnValue(
throwError(mockError)
);

Expand All @@ -124,8 +134,12 @@ describe('OpfPaymentVerificationComponent', () => {
afterRedirectScriptFlag: 'false',
};

paymentServiceMock.verifyResultUrl.and.returnValue(of(mockVerifyResult));
paymentServiceMock.runHostedPagePattern.and.returnValue(of(false));
opfPaymentVerificationServiceMock.verifyResultUrl.and.returnValue(
of(mockVerifyResult)
);
opfPaymentVerificationServiceMock.runHostedPagePattern.and.returnValue(
of(false)
);

spyOn(component, 'onError');

Expand All @@ -141,14 +155,20 @@ describe('OpfPaymentVerificationComponent', () => {
afterRedirectScriptFlag: 'true',
};

paymentServiceMock.verifyResultUrl.and.returnValue(
opfPaymentVerificationServiceMock.verifyResultUrl.and.returnValue(
of(mockVerifyResultWithFlag)
);
paymentServiceMock.runHostedFieldsPattern.and.returnValue(of(true));
opfPaymentVerificationServiceMock.runHostedFieldsPattern.and.returnValue(
of(true)
);
component.ngOnInit();

expect(paymentServiceMock.runHostedFieldsPattern).toHaveBeenCalled();
expect(paymentServiceMock.runHostedPagePattern).not.toHaveBeenCalled();
expect(
opfPaymentVerificationServiceMock.runHostedFieldsPattern
).toHaveBeenCalled();
expect(
opfPaymentVerificationServiceMock.runHostedPagePattern
).not.toHaveBeenCalled();
});
});

Expand All @@ -158,8 +178,10 @@ describe('OpfPaymentVerificationComponent', () => {

component.onError(mockError);

expect(paymentServiceMock.displayError).toHaveBeenCalledWith(mockError);
expect(paymentServiceMock.goToPage).toHaveBeenCalledWith(
expect(
opfPaymentVerificationServiceMock.displayError
).toHaveBeenCalledWith(mockError);
expect(opfPaymentVerificationServiceMock.goToPage).toHaveBeenCalledWith(
OpfPage.CHECKOUT_REVIEW_PAGE
);
});
Expand All @@ -173,16 +195,18 @@ describe('OpfPaymentVerificationComponent', () => {
afterRedirectScriptFlag: 'true',
};

paymentServiceMock.verifyResultUrl.and.returnValue(
opfPaymentVerificationServiceMock.verifyResultUrl.and.returnValue(
of(mockVerifyResultWithFlag)
);
paymentServiceMock.runHostedFieldsPattern.and.returnValue(of(true));
opfPaymentVerificationServiceMock.runHostedFieldsPattern.and.returnValue(
of(true)
);
component.ngOnInit();

component.ngOnDestroy();

expect(
paymentServiceMock.removeResourcesAndGlobalFunctions
opfPaymentVerificationServiceMock.removeResourcesAndGlobalFunctions
).toHaveBeenCalled();
});
});
Expand Down
Loading

0 comments on commit 72ac43a

Please sign in to comment.