Skip to content

Commit

Permalink
refactor: use server setting for message-to-merchant checkout field
Browse files Browse the repository at this point in the history
  • Loading branch information
dhhyi committed Nov 29, 2023
1 parent 657f559 commit 8bc8ac4
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 19 deletions.
1 change: 0 additions & 1 deletion docs/concepts/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ Of course, the ICM server must supply appropriate REST resources to leverage fun
| **B2B Features** | |
| businessCustomerRegistration | Create business customers on registration |
| costCenters | Cost center feature |
| messageToMerchant | Write a message to the merchant at checkout |
| orderTemplates | Order template feature |
| punchout | Punchout feature |
| quickorder | Quick order page and direct add to cart input |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ <h1>

<h2>{{ 'approval.detailspage.order_details.heading' | translate }}</h2>

<div *ishFeature="'messageToMerchant'">
<div *ngIf="'shipping.messageToMerchant' | ishServerSetting">
<!-- MessageToMerchant-->
<ish-basket-merchant-message-view [data]="requisition"></ish-basket-merchant-message-view>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
import { TranslateModule } from '@ngx-translate/core';
import { MockComponent, MockDirective } from 'ng-mocks';
import { MockComponent, MockDirective, MockPipe } from 'ng-mocks';
import { of } from 'rxjs';
import { instance, mock, when } from 'ts-mockito';

import { AuthorizationToggleDirective } from 'ish-core/directives/authorization-toggle.directive';
import { FeatureToggleModule } from 'ish-core/feature-toggle.module';
import { ServerSettingPipe } from 'ish-core/pipes/server-setting.pipe';
import { findAllCustomElements } from 'ish-core/utils/dev/html-query-utils';
import { AddressComponent } from 'ish-shared/components/address/address/address.component';
import { BasketCostSummaryComponent } from 'ish-shared/components/basket/basket-cost-summary/basket-cost-summary.component';
Expand All @@ -34,7 +34,7 @@ describe('Requisition Detail Page Component', () => {
context = mock(RequisitionContextFacade);

await TestBed.configureTestingModule({
imports: [FeatureToggleModule.forTesting('messageToMerchant'), RouterTestingModule, TranslateModule.forRoot()],
imports: [RouterTestingModule, TranslateModule.forRoot()],
declarations: [
MockComponent(AddressComponent),
MockComponent(BasketCostSummaryComponent),
Expand All @@ -47,6 +47,7 @@ describe('Requisition Detail Page Component', () => {
MockComponent(RequisitionRejectDialogComponent),
MockComponent(RequisitionSummaryComponent),
MockDirective(AuthorizationToggleDirective),
MockPipe(ServerSettingPipe, path => path === 'shipping.messageToMerchant'),
RequisitionDetailPageComponent,
],
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ <h1>{{ 'account.orderdetails.heading.default' | translate }}</h1>
</ish-info-box>
</div>

<ng-container *ishFeature="'messageToMerchant'">
<ng-container *ngIf="'shipping.messageToMerchant' | ishServerSetting">
<!-- MessageToMerchant-->
<ish-basket-merchant-message-view [data]="order"></ish-basket-merchant-message-view>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { MockComponent, MockPipe } from 'ng-mocks';

import { FeatureToggleModule } from 'ish-core/feature-toggle.module';
import { DatePipe } from 'ish-core/pipes/date.pipe';
import { ServerSettingPipe } from 'ish-core/pipes/server-setting.pipe';
import { BasketMockData } from 'ish-core/utils/dev/basket-mock-data';
import { AddressComponent } from 'ish-shared/components/address/address/address.component';
import { BasketCostSummaryComponent } from 'ish-shared/components/basket/basket-cost-summary/basket-cost-summary.component';
Expand Down Expand Up @@ -32,8 +33,9 @@ describe('Account Order Component', () => {
MockComponent(InfoBoxComponent),
MockComponent(LineItemListComponent),
MockPipe(DatePipe),
MockPipe(ServerSettingPipe, path => path === 'shipping.messageToMerchant'),
],
imports: [FeatureToggleModule.forTesting('messageToMerchant'), TranslateModule.forRoot()],
imports: [FeatureToggleModule.forTesting(), TranslateModule.forRoot()],
}).compileComponents();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- header as content -->
<ng-content></ng-content>

<ng-container *ishFeature="'messageToMerchant'">
<ng-container *ngIf="'shipping.messageToMerchant' | ishServerSetting">
<!-- MessageToMerchant-->
<ish-basket-merchant-message-view [data]="order"></ish-basket-merchant-message-view>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
import { TranslateModule } from '@ngx-translate/core';
import { MockComponent } from 'ng-mocks';
import { MockComponent, MockPipe } from 'ng-mocks';

import { FeatureToggleModule } from 'ish-core/feature-toggle.module';
import { ServerSettingPipe } from 'ish-core/pipes/server-setting.pipe';
import { BasketMockData } from 'ish-core/utils/dev/basket-mock-data';
import { findAllCustomElements } from 'ish-core/utils/dev/html-query-utils';
import { AddressComponent } from 'ish-shared/components/address/address/address.component';
Expand Down Expand Up @@ -31,8 +32,9 @@ describe('Checkout Receipt Component', () => {
MockComponent(FaIconComponent),
MockComponent(InfoBoxComponent),
MockComponent(LineItemListComponent),
MockPipe(ServerSettingPipe, path => path === 'shipping.messageToMerchant'),
],
imports: [FeatureToggleModule.forTesting('messageToMerchant'), TranslateModule.forRoot()],
imports: [FeatureToggleModule.forTesting(), TranslateModule.forRoot()],
}).compileComponents();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h1 class="d-flex flex-wrap align-items-baseline">
</div>
<ish-basket-approval-info *ngIf="basket.approval" [approval]="basket.approval"></ish-basket-approval-info>

<ng-container *ishFeature="'messageToMerchant'">
<ng-container *ngIf="'shipping.messageToMerchant' | ishServerSetting">
<!-- MessageToMerchant-->
<ish-basket-merchant-message-view
[data]="basket"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ReactiveFormsModule, UntypedFormGroup } from '@angular/forms';
import { FormlyModule } from '@ngx-formly/core';
import { TranslateModule } from '@ngx-translate/core';
import { MockComponent, MockDirective } from 'ng-mocks';
import { MockComponent, MockDirective, MockPipe } from 'ng-mocks';
import { spy, verify } from 'ts-mockito';

import { ServerHtmlDirective } from 'ish-core/directives/server-html.directive';
import { FeatureToggleModule } from 'ish-core/feature-toggle.module';
import { BasketApproval } from 'ish-core/models/basket-approval/basket-approval.model';
import { ServerSettingPipe } from 'ish-core/pipes/server-setting.pipe';
import { makeHttpError } from 'ish-core/utils/dev/api-service-utils';
import { BasketMockData } from 'ish-core/utils/dev/basket-mock-data';
import { findAllCustomElements } from 'ish-core/utils/dev/html-query-utils';
Expand Down Expand Up @@ -47,9 +48,10 @@ describe('Checkout Review Component', () => {
MockComponent(LineItemListComponent),
MockComponent(ModalDialogLinkComponent),
MockDirective(ServerHtmlDirective),
MockPipe(ServerSettingPipe, path => path === 'shipping.messageToMerchant'),
],
imports: [
FeatureToggleModule.forTesting('messageToMerchant'),
FeatureToggleModule.forTesting(),
FormlyModule.forRoot({
types: [{ name: 'ish-checkout-review-tac-field', component: CheckoutReviewTacFieldComponent }],
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ <h3>{{ 'checkout.shipping_method.selection.heading' | translate }}</h3>
<ish-basket-order-reference [basket]="basket$ | async"></ish-basket-order-reference>
</ng-container>

<ng-container *ishFeature="'messageToMerchant'">
<ng-container *ngIf="'shipping.messageToMerchant' | ishServerSetting">
<ish-basket-merchant-message [basket]="basket$ | async"></ish-basket-merchant-message>
</ng-container>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
import { TranslateModule } from '@ngx-translate/core';
import { MockComponent, MockDirective } from 'ng-mocks';
import { MockComponent, MockDirective, MockPipe } from 'ng-mocks';
import { of } from 'rxjs';
import { anything, instance, mock, verify, when } from 'ts-mockito';

import { ServerHtmlDirective } from 'ish-core/directives/server-html.directive';
import { AccountFacade } from 'ish-core/facades/account.facade';
import { CheckoutFacade } from 'ish-core/facades/checkout.facade';
import { FeatureToggleModule } from 'ish-core/feature-toggle.module';
import { ServerSettingPipe } from 'ish-core/pipes/server-setting.pipe';
import { makeHttpError } from 'ish-core/utils/dev/api-service-utils';
import { BasketMockData } from 'ish-core/utils/dev/basket-mock-data';
import { BasketAddressSummaryComponent } from 'ish-shared/components/basket/basket-address-summary/basket-address-summary.component';
Expand Down Expand Up @@ -39,8 +39,9 @@ describe('Checkout Shipping Page Component', () => {
MockComponent(CheckoutShippingComponent),
MockComponent(ErrorMessageComponent),
MockDirective(ServerHtmlDirective),
MockPipe(ServerSettingPipe, path => path === 'shipping.messageToMerchant'),
],
imports: [FeatureToggleModule.forTesting('messageToMerchant'), TranslateModule.forRoot()],
imports: [TranslateModule.forRoot()],
providers: [
{ provide: AccountFacade, useFactory: () => instance(mock(AccountFacade)) },
{ provide: CheckoutFacade, useFactory: () => instance(checkoutFacade) },
Expand Down
1 change: 0 additions & 1 deletion src/environments/environment.b2b.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export const environment: Environment = {
'businessCustomerRegistration',
'costCenters',
'maps',
'messageToMerchant',
'punchout',
'quickorder',
'quoting',
Expand Down
1 change: 0 additions & 1 deletion src/environments/environment.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export interface Environment {
/* B2B features */
| 'businessCustomerRegistration'
| 'costCenters'
| 'messageToMerchant'
| 'quoting'
| 'quickorder'
| 'orderTemplates'
Expand Down

0 comments on commit 8bc8ac4

Please sign in to comment.