-
Notifications
You must be signed in to change notification settings - Fork 387
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Jayashree <[email protected]> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Mohit Sisodiya <[email protected]>
- Loading branch information
1 parent
bda9b73
commit fe78d73
Showing
64 changed files
with
1,527 additions
and
11 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
16 changes: 16 additions & 0 deletions
16
feature-libs/customer-ticketing/assets/translations/en/my-account-v2-customer-ticketing.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,16 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 SAP Spartacus team <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
export const myAccountV2CustomerTicketing = { | ||
myAccountV2CustomerTicketing: { | ||
heading: 'Customer Service', | ||
showMore: 'Show More', | ||
changedOn: 'Changed On: {{value}}', | ||
ticketId: 'ID: {{value}}', | ||
subjectLabel: 'Subject', | ||
idLabel: 'Customer Service Id', | ||
}, | ||
}; |
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
feature-libs/customer-ticketing/components/my-account-v2/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 './my-account-v2-customer-ticketing.component'; | ||
export * from './my-account-v2-customer-ticketing.module'; |
82 changes: 82 additions & 0 deletions
82
...stomer-ticketing/components/my-account-v2/my-account-v2-customer-ticketing.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,82 @@ | ||
<ng-container> | ||
<div class="cx-my-account-customer-ticket-header"> | ||
<!-- HEADER --> | ||
<div | ||
class="cx-my-account-customer-ticket-heading" | ||
[attr.aria-label]="'myAccountV2CustomerTicketing.heading' | cxTranslate" | ||
> | ||
{{ 'myAccountV2CustomerTicketing.heading' | cxTranslate }} | ||
</div> | ||
|
||
<!-- SHOW MORE --> | ||
<div class="cx-my-account-customer-ticket-show-more"> | ||
<a | ||
id="show-more-requests" | ||
[attr.aria-label]=" | ||
'myAccountV2CustomerTicketing.showMore' | cxTranslate | ||
" | ||
class="btn-link cx-action-link" | ||
[routerLink]=" | ||
{ | ||
cxRoute: 'supportTickets' | ||
} | cxUrl | ||
" | ||
> | ||
{{ 'myAccountV2CustomerTicketing.showMore' | cxTranslate }} | ||
</a> | ||
</div> | ||
</div> | ||
<ng-container *ngIf="tickets$ | async as ticketList; else spinner"> | ||
<ng-container *ngIf="ticketList.tickets.length > 0; else noCustomerTickets"> | ||
<div class="cx-my-account-customer-ticket-body"> | ||
<ng-container *ngFor="let ticket of ticketList.tickets"> | ||
<div class="cx-my-account-customer-ticket-details"> | ||
<span | ||
class="cx-my-account-customer-ticket-subject" | ||
[attr.aria-label]=" | ||
'myAccountV2CustomerTicketing.subjectLabel' | cxTranslate | ||
" | ||
> | ||
{{ ticket.subject }} | ||
</span> | ||
<span class="cx-my-account-customer-ticket-details-light"> | ||
| {{ ticket.ticketCategory?.name }} | ||
</span> | ||
<span | ||
class="cx-my-account-customer-ticket-details-light" | ||
[attr.aria-label]=" | ||
'myAccountV2CustomerTicketing.idLabel' | cxTranslate | ||
" | ||
> | ||
| | ||
{{ | ||
'myAccountV2CustomerTicketing.ticketId' | ||
| cxTranslate: { value: ticket.id } | ||
}} | ||
</span> | ||
</div> | ||
<div class="cx-my-account-customer-ticket-details-light"> | ||
{{ | ||
'myAccountV2CustomerTicketing.changedOn' | ||
| cxTranslate | ||
: { value: ticket.modifiedAt | cxDate: 'd, MMMM, yyyy' } | ||
}} | ||
</div> | ||
</ng-container> | ||
</div> | ||
</ng-container> | ||
</ng-container> | ||
</ng-container> | ||
|
||
<ng-template #noCustomerTickets> | ||
<div | ||
class="cx-my-account-no-ticket" | ||
[attr.aria-label]="'customerTicketingList.noTickets' | cxTranslate" | ||
> | ||
{{ 'customerTicketingList.noTickets' | cxTranslate }} | ||
</div> | ||
</ng-template> | ||
|
||
<ng-template #spinner> | ||
<cx-spinner></cx-spinner> | ||
</ng-template> |
131 changes: 131 additions & 0 deletions
131
...mer-ticketing/components/my-account-v2/my-account-v2-customer-ticketing.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,131 @@ | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; | ||
import { By } from '@angular/platform-browser'; | ||
import { RouterTestingModule } from '@angular/router/testing'; | ||
import { | ||
I18nTestingModule, | ||
RoutingService, | ||
TranslationService, | ||
} from '@spartacus/core'; | ||
import { TicketList } from '@spartacus/customer-ticketing/root'; | ||
import { BehaviorSubject, EMPTY, Observable, of } from 'rxjs'; | ||
import { MyAccountV2CustomerTicketingComponent } from './my-account-v2-customer-ticketing.component'; | ||
|
||
const mockTicketList: TicketList = { | ||
pagination: {}, | ||
sorts: [], | ||
tickets: [ | ||
{ | ||
id: '0000001', | ||
modifiedAt: '2021-01-13T10:06:57+0000', | ||
subject: 'My drill is broken.', | ||
ticketCategory: { | ||
id: 'ENQUIRY', | ||
name: 'Enquiry', | ||
}, | ||
}, | ||
], | ||
}; | ||
|
||
@Pipe({ | ||
name: 'cxUrl', | ||
}) | ||
class MockUrlPipe implements PipeTransform { | ||
transform() {} | ||
} | ||
@Pipe({ | ||
name: 'cxTranslate', | ||
}) | ||
class MockTranslatePipe implements PipeTransform { | ||
transform(): any {} | ||
} | ||
class MockRoutingService { | ||
go() {} | ||
} | ||
|
||
class MockTranslationService { | ||
translate(): Observable<string> { | ||
return EMPTY; | ||
} | ||
} | ||
|
||
class MockcustomerTicketingFacade { | ||
getTickets( | ||
_pageSize: number, | ||
_currentPage?: number, | ||
_sort?: string | ||
): Observable<TicketList> { | ||
return mockTicketList$.asObservable(); | ||
} | ||
|
||
clearTicketList() {} | ||
} | ||
|
||
const mockTicketList$ = new BehaviorSubject<TicketList>(mockTicketList); | ||
|
||
describe('MyAccountV2CustomerTicketingComponent', () => { | ||
let component: MyAccountV2CustomerTicketingComponent; | ||
let fixture: ComponentFixture<MyAccountV2CustomerTicketingComponent>; | ||
|
||
beforeEach( | ||
waitForAsync(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [RouterTestingModule, I18nTestingModule], | ||
declarations: [ | ||
MyAccountV2CustomerTicketingComponent, | ||
MockTranslatePipe, | ||
MockUrlPipe, | ||
], | ||
providers: [ | ||
{ | ||
provide: 'CustomerTicketingFacade', | ||
useClass: MockcustomerTicketingFacade, | ||
}, | ||
{ provide: RoutingService, useClass: MockRoutingService }, | ||
{ provide: TranslationService, useClass: MockTranslationService }, | ||
], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(MyAccountV2CustomerTicketingComponent); | ||
component = fixture.componentInstance; | ||
component.tickets$ = of(mockTicketList); | ||
fixture.detectChanges(); | ||
}) | ||
); | ||
|
||
it('should be created', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
it('should display heading', () => { | ||
const heading = fixture.debugElement.query( | ||
By.css('.cx-my-account-customer-ticket-heading') | ||
); | ||
expect(heading.nativeElement).not.toBeNull(); | ||
const link = fixture.debugElement.query(By.css('#show-more-requests')); | ||
expect(link).not.toBeNull(); | ||
}); | ||
|
||
it('should show 1 return request', () => { | ||
const details = fixture.debugElement.query( | ||
By.css('.cx-my-account-customer-ticket-details') | ||
); | ||
expect(details.nativeElement).not.toBeNull(); | ||
const noTicket = fixture.debugElement.query( | ||
By.css('.cx-my-account-no-ticket') | ||
); | ||
expect(noTicket).toBeNull(); | ||
}); | ||
it('should show no return request', () => { | ||
component.tickets$ = of({ tickets: [] }); | ||
fixture.detectChanges(); | ||
const details = fixture.debugElement.query( | ||
By.css('.cx-my-account-customer-ticket-details') | ||
); | ||
expect(details).toBeNull(); | ||
const noTicket = fixture.debugElement.query( | ||
By.css('.cx-my-account-no-ticket') | ||
); | ||
expect(noTicket).not.toBeNull(); | ||
}); | ||
}); |
23 changes: 23 additions & 0 deletions
23
...customer-ticketing/components/my-account-v2/my-account-v2-customer-ticketing.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 { Component, inject } from '@angular/core'; | ||
import { | ||
CustomerTicketingFacade, | ||
TicketList, | ||
} from '@spartacus/customer-ticketing/root'; | ||
import { Observable } from 'rxjs'; | ||
|
||
@Component({ | ||
selector: 'cx-my-account-v2-customer-ticketing', | ||
templateUrl: './my-account-v2-customer-ticketing.component.html', | ||
}) | ||
export class MyAccountV2CustomerTicketingComponent { | ||
protected readonly PAGE_SIZE = 1; | ||
protected customerTicketingFacade = inject(CustomerTicketingFacade); | ||
tickets$: Observable<TicketList | undefined> = | ||
this.customerTicketingFacade.getTickets(this.PAGE_SIZE); | ||
} |
35 changes: 35 additions & 0 deletions
35
...bs/customer-ticketing/components/my-account-v2/my-account-v2-customer-ticketing.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,35 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 SAP Spartacus team <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { NgModule } from '@angular/core'; | ||
import { | ||
provideDefaultConfig, | ||
CmsConfig, | ||
AuthGuard, | ||
I18nModule, | ||
UrlModule, | ||
} from '@spartacus/core'; | ||
import { MyAccountV2CustomerTicketingComponent } from './my-account-v2-customer-ticketing.component'; | ||
import { SpinnerModule } from '@spartacus/storefront'; | ||
import { RouterModule } from '@angular/router'; | ||
import { CommonModule } from '@angular/common'; | ||
|
||
@NgModule({ | ||
declarations: [MyAccountV2CustomerTicketingComponent], | ||
exports: [MyAccountV2CustomerTicketingComponent], | ||
providers: [ | ||
provideDefaultConfig(<CmsConfig>{ | ||
cmsComponents: { | ||
MyAccountViewRequestsComponent: { | ||
component: MyAccountV2CustomerTicketingComponent, | ||
guards: [AuthGuard], | ||
}, | ||
}, | ||
}), | ||
], | ||
imports: [CommonModule, I18nModule, UrlModule, SpinnerModule, RouterModule], | ||
}) | ||
export class MyAccountV2CustomerTicketingModule {} |
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
Oops, something went wrong.