Skip to content

Commit

Permalink
feat: use ICM settings from configurations call
Browse files Browse the repository at this point in the history
  • Loading branch information
dhhyi committed Nov 29, 2023
1 parent b3f5197 commit 461ac20
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="line-item-attribute" *ngIf="editable || control.value">
<div class="line-item-attribute" *ngIf="('basket.' + key | ishServerSetting) && (editable || control.value)">
<ng-template #display>
<!-- keep-localization-pattern: ^line-item\..*\.placeholder$ -->
{{ control.value || 'line-item.' + key + '.placeholder' | translate }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ReactiveFormsModule } from '@angular/forms';
import { TranslateModule } from '@ngx-translate/core';
import { MockComponent } from 'ng-mocks';
import { MockComponent, MockPipe } from 'ng-mocks';

import { ServerSettingPipe } from 'ish-core/pipes/server-setting.pipe';
import { findAllCustomElements } from 'ish-core/utils/dev/html-query-utils';
import { InPlaceEditComponent } from 'ish-shared/components/common/in-place-edit/in-place-edit.component';

Expand All @@ -12,11 +13,18 @@ describe('Line Item Extended Content Entry Component', () => {
let component: LineItemExtendedContentEntryComponent;
let fixture: ComponentFixture<LineItemExtendedContentEntryComponent>;
let element: HTMLElement;
let settingEnabled: boolean;

beforeEach(async () => {
settingEnabled = true;

await TestBed.configureTestingModule({
imports: [ReactiveFormsModule, TranslateModule.forRoot()],
declarations: [LineItemExtendedContentEntryComponent, MockComponent(InPlaceEditComponent)],
declarations: [
LineItemExtendedContentEntryComponent,
MockComponent(InPlaceEditComponent),
MockPipe(ServerSettingPipe, () => settingEnabled),
],
}).compileComponents();
});

Expand All @@ -32,6 +40,19 @@ describe('Line Item Extended Content Entry Component', () => {
expect(() => fixture.detectChanges()).not.toThrow();
});

describe('with disabled setting', () => {
beforeEach(() => {
settingEnabled = false;
});

it('should not display', () => {
component.ngOnChanges();
fixture.detectChanges();

expect(element).toMatchInlineSnapshot(`N/A`);
});
});

describe('with line item', () => {
beforeEach(() => {
component.lineItem = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ export class LineItemExtendedContentEntryComponent implements OnChanges {
}

reset() {
this.control.setValue(this.lineItem[this.key]);
if (this.lineItem && this.key) {
this.control.setValue(this.lineItem[this.key]);
}
}

update() {
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 @@ -12,7 +12,6 @@ export const environment: Environment = {
...ENVIRONMENT_DEFAULTS.features,
'businessCustomerRegistration',
'costCenters',
'extendedLineItemContent',
'maps',
'messageToMerchant',
'punchout',
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'
| 'extendedLineItemContent'
| 'messageToMerchant'
| 'quoting'
| 'quickorder'
Expand Down

0 comments on commit 461ac20

Please sign in to comment.