Skip to content

Commit

Permalink
rename components (classes, html selectors, filenames) and modules
Browse files Browse the repository at this point in the history
  • Loading branch information
hakwookim committed Oct 6, 2023
1 parent 3ee1585 commit 71f1879
Show file tree
Hide file tree
Showing 105 changed files with 911 additions and 822 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* SPDX-License-Identifier: Apache-2.0
*/

export const customer360 = {
customer360: {
export const asmCustomer360 = {
asmCustomer360: {
alertErrorMessage:
'The information cannot be be loaded. Please try again later or contact your system administrator.',
errorMessageHeader: 'Oops! Something went wrong',
Expand Down
4 changes: 2 additions & 2 deletions feature-libs/asm/customer-360/assets/translations/en/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { customer360 } from './customer-360';
import { asmCustomer360 } from './asm-customer-360';

export const en = {
customer360,
asmCustomer360,
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<button
class="cx-customer-360-product-item-media link"
class="cx-asm-customer-360-product-item-media link"
[attr.aria-label]="product?.name"
(click)="selectProduct.emit(product)"
>
Expand All @@ -9,37 +9,37 @@
[alt]="product?.name ?? ''"
></cx-media>
</button>
<div class="cx-customer-360-product-item-content">
<div class="cx-asm-customer-360-product-item-content">
<button
[attr.aria-label]="product?.name"
(click)="selectProduct.emit(product)"
class="cx-customer-360-product-item-name link"
class="cx-asm-customer-360-product-item-name link"
>
<span title="{{ product?.name }}">{{ product?.name }}</span>
</button>
<ng-container *ngIf="isOrderEntry; else notOrderEntryTemplate">
<div class="cx-customer-360-product-item-code">
<div class="cx-asm-customer-360-product-item-code">
{{ product?.code }}
</div>
<div class="cx-customer-360-product-item-quantity" *ngIf="quantity">
<div class="cx-asm-customer-360-product-item-quantity" *ngIf="quantity">
{{
'customer360.productItem.quantity' | cxTranslate: { count: quantity }
'asmCustomer360.productItem.quantity' | cxTranslate: { count: quantity }
}}
</div>
<div class="cx-customer-360-product-item-price">
<div class="cx-asm-customer-360-product-item-price">
{{
'customer360.productItem.itemPrice'
'asmCustomer360.productItem.itemPrice'
| cxTranslate
: { price: product?.basePrice ?? product?.price?.formattedValue }
}}
</div>
</ng-container>
<ng-template #notOrderEntryTemplate>
<div
class="cx-customer-360-product-item-out-of-stock"
class="cx-asm-customer-360-product-item-out-of-stock"
*ngIf="product.stock?.stockLevelStatus === 'outOfStock'"
>
{{ 'customer360.productItem.outOfStock' | cxTranslate }}
{{ 'asmCustomer360.productItem.outOfStock' | cxTranslate }}
</div>
</ng-template>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { I18nTestingModule, ImageType, Product } from '@spartacus/core';
import { FocusConfig, ICON_TYPE } from '@spartacus/storefront';

import { By } from '@angular/platform-browser';
import { Customer360ProductItemComponent } from './customer-360-product-item.component';
import { AsmCustomer360ProductItemComponent } from './asm-customer-360-product-item.component';

@Component({
template: '',
Expand Down Expand Up @@ -67,15 +67,15 @@ describe('Customer360ProductItemComponent', () => {
@Input() type: ICON_TYPE;
}

let component: Customer360ProductItemComponent;
let fixture: ComponentFixture<Customer360ProductItemComponent>;
let component: AsmCustomer360ProductItemComponent;
let fixture: ComponentFixture<AsmCustomer360ProductItemComponent>;
let el: DebugElement;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [I18nTestingModule],
declarations: [
Customer360ProductItemComponent,
AsmCustomer360ProductItemComponent,
MockTranslatePipe,
MockCxIconComponent,
MockMediaComponent,
Expand All @@ -84,7 +84,7 @@ describe('Customer360ProductItemComponent', () => {
});

beforeEach(() => {
fixture = TestBed.createComponent(Customer360ProductItemComponent);
fixture = TestBed.createComponent(AsmCustomer360ProductItemComponent);
component = fixture.componentInstance;
el = fixture.debugElement;
});
Expand All @@ -102,17 +102,25 @@ describe('Customer360ProductItemComponent', () => {

fixture.detectChanges();

const productLink = el.query(By.css('.cx-customer-360-product-item-name'));
const productLink = el.query(
By.css('.cx-asm-customer-360-product-item-name')
);

expect(el.query(By.css('.cx-customer-360-product-item-name'))).toBeTruthy();
expect(
el.query(By.css('.cx-asm-customer-360-product-item-name'))
).toBeTruthy();

expect(el.query(By.css('.cx-customer-360-product-item-code'))).toBeFalsy();
expect(
el.query(By.css('.cx-asm-customer-360-product-item-code'))
).toBeFalsy();

expect(
el.query(By.css('.cx-customer-360-product-item-quantity'))
el.query(By.css('.cx-asm-customer-360-product-item-quantity'))
).toBeFalsy();

expect(el.query(By.css('.cx-customer-360-product-item-price'))).toBeFalsy();
expect(
el.query(By.css('.cx-asm-customer-360-product-item-price'))
).toBeFalsy();

productLink.nativeElement.click();
expect(component.selectProduct.emit).toHaveBeenCalledWith(mockProduct);
Expand All @@ -127,18 +135,24 @@ describe('Customer360ProductItemComponent', () => {

fixture.detectChanges();

const productLink = el.query(By.css('.cx-customer-360-product-item-name'));
const productLink = el.query(
By.css('.cx-asm-customer-360-product-item-name')
);

expect(el.query(By.css('.cx-customer-360-product-item-name'))).toBeTruthy();
expect(
el.query(By.css('.cx-asm-customer-360-product-item-name'))
).toBeTruthy();

expect(el.query(By.css('.cx-customer-360-product-item-code'))).toBeTruthy();
expect(
el.query(By.css('.cx-asm-customer-360-product-item-code'))
).toBeTruthy();

expect(
el.query(By.css('.cx-customer-360-product-item-quantity'))
el.query(By.css('.cx-asm-customer-360-product-item-quantity'))
).toBeTruthy();

expect(
el.query(By.css('.cx-customer-360-product-item-price'))
el.query(By.css('.cx-asm-customer-360-product-item-price'))
).toBeTruthy();

productLink.nativeElement.click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import {
Output,
} from '@angular/core';
import { Product } from '@spartacus/core';
import { ProductItem } from '../customer-360-product-listing/product-item.model';
import { ProductItem } from '../asm-customer-360-product-listing/product-item.model';

@Component({
selector: 'cx-customer-360-product-item',
templateUrl: './customer-360-product-item.component.html',
selector: 'cx-asm-customer-360-product-item',
templateUrl: './asm-customer-360-product-item.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class Customer360ProductItemComponent {
export class AsmCustomer360ProductItemComponent {
@Input() product: ProductItem;
@Input() quantity: number;
@Input() isOrderEntry = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { I18nModule } from '@spartacus/core';
import { MediaModule } from '@spartacus/storefront';
import { Customer360ProductItemComponent } from './customer-360-product-item.component';
import { AsmCustomer360ProductItemComponent } from './asm-customer-360-product-item.component';

@NgModule({
imports: [CommonModule, MediaModule, I18nModule],
declarations: [Customer360ProductItemComponent],
exports: [Customer360ProductItemComponent],
declarations: [AsmCustomer360ProductItemComponent],
exports: [AsmCustomer360ProductItemComponent],
})
export class Customer360ProductItemModule {}
export class AsmCustomer360ProductItemModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
[class.show-more]="showMore"
>
<ng-container *ngFor="let product of products; let i = index">
<cx-customer-360-product-item
<cx-asm-customer-360-product-item
*ngIf="showMore || i < numberofColumns"
[product]="product"
[quantity]="product?.quantity"
(selectProduct)="selectProduct.emit($event)"
></cx-customer-360-product-item>
></cx-asm-customer-360-product-item>
</ng-container>
</div>
<ng-container *ngIf="products.length > numberofColumns">
Expand All @@ -39,11 +39,11 @@
(click)="toggleShowMore()"
>
<span *ngIf="!showMore; else showLess">{{
'customer360.productListing.showMore' | cxTranslate
'asmCustomer360.productListing.showMore' | cxTranslate
}}</span>
<ng-template #showLess>
<span *ngIf="showMore">{{
'customer360.productListing.showLess' | cxTranslate
'asmCustomer360.productListing.showLess' | cxTranslate
}}</span>
</ng-template>
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import { I18nTestingModule, Product } from '@spartacus/core';
import { BREAKPOINT, BreakpointService } from '@spartacus/storefront';
import { BehaviorSubject, Observable } from 'rxjs';

import { Customer360ProductListingComponent } from './customer-360-product-listing.component';
import { AsmCustomer360ProductListingComponent } from './asm-customer-360-product-listing.component';
import { ProductItem } from './product-item.model';

describe('Customer360ProductListingComponent', () => {
let component: Customer360ProductListingComponent;
let fixture: ComponentFixture<Customer360ProductListingComponent>;
let component: AsmCustomer360ProductListingComponent;
let fixture: ComponentFixture<AsmCustomer360ProductListingComponent>;
let el: DebugElement;

let componentTest: AsmCustomerProductListingComponentTest;
Expand All @@ -28,7 +28,8 @@ describe('Customer360ProductListingComponent', () => {

@Component({
template: '',
selector: '[cx-customer-360-product-item], cx-customer-360-product-item',
selector:
'[cx-asm-customer-360-product-item], cx-asm-customer-360-product-item',
})
class MockAsmProductItemComponent {
@Input() product: Product;
Expand All @@ -41,15 +42,15 @@ describe('Customer360ProductListingComponent', () => {
// eslint-disable-next-line @angular-eslint/component-selector
selector: 'asm-customer-product-listing-component-test',
template: `
<cx-customer-360-product-listing
<cx-asm-customer-360-product-listing
[headerInactive]="headerInactive"
[headerTemplate]="headerTemplate"
[products]="products"
[headerText]="headerText"
(clickHeader)="clickHeaderSpy.push(undefined)"
(selectProduct)="selectProductSpy.push($event)"
>
</cx-customer-360-product-listing>
</cx-asm-customer-360-product-listing>
<ng-template #headerTemplate>
<div id="product-listing-header-template"></div>
Expand All @@ -58,8 +59,8 @@ describe('Customer360ProductListingComponent', () => {
})
// eslint-disable-next-line @angular-eslint/component-class-suffix
class AsmCustomerProductListingComponentTest {
@ViewChild(Customer360ProductListingComponent)
componentRef: Customer360ProductListingComponent;
@ViewChild(AsmCustomer360ProductListingComponent)
componentRef: AsmCustomer360ProductListingComponent;

@Input()
headerInactive: boolean;
Expand All @@ -85,7 +86,7 @@ describe('Customer360ProductListingComponent', () => {
await TestBed.configureTestingModule({
imports: [I18nTestingModule],
declarations: [
Customer360ProductListingComponent,
AsmCustomer360ProductListingComponent,
MockAsmProductItemComponent,
AsmCustomerProductListingComponentTest,
],
Expand All @@ -99,7 +100,7 @@ describe('Customer360ProductListingComponent', () => {
});

function createComponent(): void {
fixture = TestBed.createComponent(Customer360ProductListingComponent);
fixture = TestBed.createComponent(AsmCustomer360ProductListingComponent);
component = fixture.componentInstance;

component.products = [
Expand Down Expand Up @@ -148,7 +149,9 @@ describe('Customer360ProductListingComponent', () => {
createComponent();

fixture.detectChanges();
expect(el.queryAll(By.css('cx-customer-360-product-item')).length).toBe(2);
expect(el.queryAll(By.css('cx-asm-customer-360-product-item')).length).toBe(
2
);
});

it('should render a header', () => {
Expand All @@ -168,7 +171,9 @@ describe('Customer360ProductListingComponent', () => {

fixture.detectChanges();

expect(el.queryAll(By.css('cx-customer-360-product-item')).length).toBe(2);
expect(el.queryAll(By.css('cx-asm-customer-360-product-item')).length).toBe(
2
);
});

it('should show more products if not all are shown', () => {
Expand All @@ -178,21 +183,27 @@ describe('Customer360ProductListingComponent', () => {

fixture.detectChanges();

expect(el.queryAll(By.css('cx-customer-360-product-item')).length).toBe(1);
expect(el.queryAll(By.css('cx-asm-customer-360-product-item')).length).toBe(
1
);

const showHideButton = el.query(By.css('.show-hide-button'));

showHideButton.nativeElement.click();

fixture.detectChanges();

expect(el.queryAll(By.css('cx-customer-360-product-item')).length).toBe(2);
expect(el.queryAll(By.css('cx-asm-customer-360-product-item')).length).toBe(
2
);

showHideButton.nativeElement.click();

fixture.detectChanges();

expect(el.queryAll(By.css('cx-customer-360-product-item')).length).toBe(1);
expect(el.queryAll(By.css('cx-asm-customer-360-product-item')).length).toBe(
1
);
});

it('should show a text explaining that there are no items to render', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ import { map } from 'rxjs/operators';
import { ProductItem } from './product-item.model';

@Component({
selector: 'cx-customer-360-product-listing',
templateUrl: './customer-360-product-listing.component.html',
selector: 'cx-asm-customer-360-product-listing',
templateUrl: './asm-customer-360-product-listing.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class Customer360ProductListingComponent implements OnInit {
export class AsmCustomer360ProductListingComponent implements OnInit {
@Input()
emptyResultDescription: string;

Expand Down
Loading

0 comments on commit 71f1879

Please sign in to comment.