-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: Silke Grueber <s.grueber@intershop.de>
- Loading branch information
Showing
16 changed files
with
188 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/app/shared/components/basket/basket-error-message/basket-error-message.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<ng-container *ngIf="error as basketError"> | ||
<ng-container *ngIf="basketError.errors as errors"> | ||
<div *ngFor="let error of errors" [class]="cssClass" data-testing-id="basket-errors"> | ||
<strong>{{ error.message }}</strong> | ||
<ng-container *ngIf="error.causes as causes"> | ||
<p *ngFor="let cause of causes" role="alert"> | ||
<span> {{ cause.message }}</span> | ||
<span *ngIf="cause.parameters?.sku" class="product-id" | ||
><br /> | ||
<label>{{ 'product.itemNumber.label' | translate }}</label> | ||
<span itemprop="sku">{{ cause.parameters.sku }}</span> | ||
</span> | ||
</p> | ||
</ng-container> | ||
</div> | ||
</ng-container> | ||
</ng-container> |
41 changes: 41 additions & 0 deletions
41
src/app/shared/components/basket/basket-error-message/basket-error-message.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { HttpError } from 'ish-core/models/http-error/http-error.model'; | ||
|
||
import { BasketErrorMessageComponent } from './basket-error-message.component'; | ||
|
||
describe('Basket Error Message Component', () => { | ||
let component: BasketErrorMessageComponent; | ||
let fixture: ComponentFixture<BasketErrorMessageComponent>; | ||
let element: HTMLElement; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [BasketErrorMessageComponent], | ||
}).compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(BasketErrorMessageComponent); | ||
component = fixture.componentInstance; | ||
element = fixture.nativeElement; | ||
|
||
component.error = { | ||
errors: [{ message: 'main_message', causes: [{ message: 'cause_message' }] }], | ||
} as HttpError; | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(component).toBeTruthy(); | ||
expect(element).toBeTruthy(); | ||
expect(() => fixture.detectChanges()).not.toThrow(); | ||
}); | ||
|
||
it('should display the error message and cause message', () => { | ||
fixture.detectChanges(); | ||
|
||
expect(element.querySelector('div[data-testing-id=basket-errors]').textContent).toMatchInlineSnapshot( | ||
`"main_message cause_message"` | ||
); | ||
}); | ||
}); |
13 changes: 13 additions & 0 deletions
13
src/app/shared/components/basket/basket-error-message/basket-error-message.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; | ||
|
||
import { HttpError } from 'ish-core/models/http-error/http-error.model'; | ||
|
||
@Component({ | ||
selector: 'ish-basket-error-message', | ||
templateUrl: './basket-error-message.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class BasketErrorMessageComponent { | ||
@Input() error: HttpError; | ||
@Input() cssClass = 'alert alert-danger'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters