-
Notifications
You must be signed in to change notification settings - Fork 393
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add terms and conditions message alert
Closes: CXSPA-3171
- Loading branch information
Showing
17 changed files
with
182 additions
and
3 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
8 changes: 8 additions & 0 deletions
8
integration-libs/opf/checkout/components/opf-checkout-terms-and-conditions-alert/index.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,8 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 SAP Spartacus team <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
export * from './opf-checkout-terms-and-conditions-alert.component'; | ||
export * from './opf-checkout-terms-and-conditions-alert.module'; |
13 changes: 13 additions & 0 deletions
13
...heckout-terms-and-conditions-alert/opf-checkout-terms-and-conditions-alert.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,13 @@ | ||
<div *ngIf="isVisible" class="cx-opf-checkout-terms-and-conditions-alert"> | ||
<div class="alert alert-info"> | ||
<span class="alert-icon"> | ||
<cx-icon [type]="iconTypes.INFO"></cx-icon> | ||
</span> | ||
<span class="message"> | ||
{{ 'opf.checkout.checkTermsAndConditionsFirst' | cxTranslate }}</span | ||
> | ||
<button class="close" type="button" (click)="close()"> | ||
<cx-icon [type]="iconTypes.CLOSE"></cx-icon> | ||
</button> | ||
</div> | ||
</div> |
71 changes: 71 additions & 0 deletions
71
...kout-terms-and-conditions-alert/opf-checkout-terms-and-conditions-alert.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,71 @@ | ||
import { Component, Input, Pipe, PipeTransform } from '@angular/core'; | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { OpfCheckoutTermsAndConditionsAlertComponent } from './opf-checkout-terms-and-conditions-alert.component'; | ||
|
||
@Component({ | ||
selector: 'cx-icon', | ||
template: '<ng-content></ng-content>', | ||
}) | ||
class MockIconComponent { | ||
@Input() type: string; | ||
} | ||
|
||
@Pipe({ | ||
name: 'cxTranslate', | ||
}) | ||
class MockTranslatePipe implements PipeTransform { | ||
transform(): any {} | ||
} | ||
|
||
const alertSelector = '.cx-opf-checkout-terms-and-conditions-alert'; | ||
|
||
describe('OpfCheckoutTermsAndConditionsAlertComponent', () => { | ||
let fixture: ComponentFixture<OpfCheckoutTermsAndConditionsAlertComponent>; | ||
let component: OpfCheckoutTermsAndConditionsAlertComponent; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ | ||
OpfCheckoutTermsAndConditionsAlertComponent, | ||
MockIconComponent, | ||
MockTranslatePipe, | ||
], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent( | ||
OpfCheckoutTermsAndConditionsAlertComponent | ||
); | ||
component = fixture.componentInstance; | ||
}); | ||
|
||
it('should create the component', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
it('should render component if isVisible is set to true', () => { | ||
component.isVisible = true; | ||
fixture.detectChanges(); | ||
const alertElement = fixture.nativeElement.querySelector(alertSelector); | ||
|
||
expect(alertElement).toBeTruthy(); | ||
}); | ||
|
||
it('should not render component if isVisible is set to false', () => { | ||
component.isVisible = false; | ||
fixture.detectChanges(); | ||
const alertElement = fixture.nativeElement.querySelector(alertSelector); | ||
|
||
expect(alertElement).toBeNull(); | ||
}); | ||
|
||
it('should set isVisible to false, if close method is called', () => { | ||
component.isVisible = true; | ||
fixture.detectChanges(); | ||
const alertElement = fixture.nativeElement.querySelector(alertSelector); | ||
|
||
expect(alertElement).toBeTruthy(); | ||
|
||
component.close(); | ||
expect(component.isVisible).toBeFalsy(); | ||
}); | ||
}); |
23 changes: 23 additions & 0 deletions
23
...-checkout-terms-and-conditions-alert/opf-checkout-terms-and-conditions-alert.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,23 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 SAP Spartacus team <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; | ||
import { ICON_TYPE } from '@spartacus/storefront'; | ||
|
||
@Component({ | ||
selector: 'cx-opf-checkout-terms-and-conditions-alert', | ||
templateUrl: './opf-checkout-terms-and-conditions-alert.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class OpfCheckoutTermsAndConditionsAlertComponent { | ||
iconTypes = ICON_TYPE; | ||
|
||
@Input() isVisible: boolean; | ||
|
||
close() { | ||
this.isVisible = false; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...opf-checkout-terms-and-conditions-alert/opf-checkout-terms-and-conditions-alert.module.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,18 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 SAP Spartacus team <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { CommonModule } from '@angular/common'; | ||
import { NgModule } from '@angular/core'; | ||
import { I18nModule } from '@spartacus/core'; | ||
import { IconModule } from '@spartacus/storefront'; | ||
import { OpfCheckoutTermsAndConditionsAlertComponent } from './opf-checkout-terms-and-conditions-alert.component'; | ||
|
||
@NgModule({ | ||
declarations: [OpfCheckoutTermsAndConditionsAlertComponent], | ||
exports: [OpfCheckoutTermsAndConditionsAlertComponent], | ||
imports: [CommonModule, I18nModule, IconModule], | ||
}) | ||
export class OpfCheckoutTermsAndConditionsAlertModule {} |
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
15 changes: 15 additions & 0 deletions
15
...gration-libs/opf/checkout/styles/components/_opf-checkout-terms-and-conditions-alert.scss
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,15 @@ | ||
%cx-opf-checkout-terms-and-conditions-alert { | ||
.alert { | ||
.close { | ||
top: var(--cx-top, 50%); | ||
right: 1.5rem; | ||
margin-top: -12px; | ||
&:before { | ||
margin: 0; | ||
} | ||
} | ||
.message { | ||
padding: 10px 0; | ||
} | ||
} | ||
} |