Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Customer360 main branch(CXSPA-700) #17809

Merged
merged 207 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from 205 commits
Commits
Show all changes
207 commits
Select commit Hold shift + click to select a range
939641c
asm360 overview & profile
hakwookim Aug 3, 2022
c99593a
WIP: 360 Maps tab prototype - UI and SCSS. Next commit is to mock data
justinlee01 Jul 18, 2022
fc6c25d
Adding MapData type for Map tab and using Angular directives to repre…
justinlee01 Jul 25, 2022
ff3ad3d
User can click on stores to change displayed data. Google Maps change…
justinlee01 Jul 25, 2022
20abdd1
Google Maps working fully, directing the current device from their lo…
justinlee01 Jul 25, 2022
afd8fb9
Transfering over old PrototypeComponent code to AsmCustomerMapCompone…
justinlee01 Aug 2, 2022
e4d7237
Running prettier:fix
justinlee01 Aug 2, 2022
ae0fccc
Fixing bug where selected item was not highlighted. Adding pagination…
justinlee01 Aug 2, 2022
22040ae
Created listing and table UI components
bullfroggy-sap Aug 4, 2022
7a08450
Create activity, feedback, and promotios tabs based on listing and ta…
bullfroggy-sap Aug 4, 2022
20c4d63
Add overview, profile, activity, feedback, and promotions to updated …
bullfroggy-sap Aug 4, 2022
f95d7e5
Make styles more consistent with accelerator
bullfroggy-sap Aug 4, 2022
434bf78
Use module for each tab and ui components
bullfroggy-sap Aug 5, 2022
9302439
moved 360 dialog style
hakwookim Aug 5, 2022
2b815da
add missing module
hakwookim Aug 7, 2022
6050f9a
Fix search functionality for customer coupons
bullfroggy-sap Aug 10, 2022
ec443c2
Task/update asm 360 (#16064)
justinlee01 Aug 11, 2022
9b70e85
Task: customer 360 updates (#16071)
justinlee01 Aug 25, 2022
58f1246
design update main tab, overview and profile (#16220)
kimhw0630 Oct 3, 2022
96db9fd
Task/asm 360 data layer (#16224)
justinlee01 Oct 7, 2022
35888b1
WIP: Fixing code to make the app build, but the app does not initiali…
justinlee01 Oct 13, 2022
4a65033
Reverting accidentally changed code from rebase resolve
justinlee01 Oct 14, 2022
6498ba2
WIP: Customer 360 uses LaunchDialogService
justinlee01 Oct 14, 2022
a8711b2
WIP: Instead of importing customer classes directly to AsmConfig, we …
justinlee01 Oct 14, 2022
f6e7397
fix dialog style
hakwookim Oct 14, 2022
18f3cec
fix scroll for dialog
hakwookim Oct 14, 2022
45530c9
Task/asm 360 component wrapper (#16312)
justinlee01 Oct 17, 2022
34e5043
overviw tab using exisiting services (#16316)
kimhw0630 Oct 17, 2022
92c302c
Task/asm 360 navigate event (#16317)
justinlee01 Oct 17, 2022
ed0ca0e
update overview navigate (#16319)
kimhw0630 Oct 18, 2022
c8d312a
profile update (#16340)
kimhw0630 Oct 19, 2022
b505130
Task/asm 360 data query (#16356)
justinlee01 Oct 24, 2022
24b8989
update activity tab with new sort (#16374)
kimhw0630 Oct 26, 2022
c570d5f
Merge branch 'develop' into task/asm-360-rebase-develop
justinlee01 Oct 31, 2022
2078c9c
Add license header
github-actions[bot] Oct 31, 2022
e9c6ee5
Merge branch 'develop' into task/asm-360-rebase-develop
justinlee01 Nov 16, 2022
9a239d9
Cleaning up AsmCustomer360Component: removing unnecessary HTML and cl…
justinlee01 Nov 16, 2022
4059670
ASM 360: Caching active cart and saved cart so that all tabs share th…
justinlee01 Nov 16, 2022
83f68ce
Changing style and text of Customer 360 button
justinlee01 Nov 17, 2022
55ce169
provideConfig -> provideDefaultConfig
justinlee01 Nov 17, 2022
57806b8
ProductReviews redirects to products
justinlee01 Nov 17, 2022
f24146f
Deleting old Promotions component
justinlee01 Nov 17, 2022
d21e120
Removing unnecessary code
justinlee01 Nov 17, 2022
a1d43d3
Current ASM 360 unit tests compile and pass
justinlee01 Nov 21, 2022
632a5d8
Merge remote-tracking branch 'origin' into task/asm-360-rebase-develop
justinlee01 Dec 1, 2022
b63f1e9
Unit tests for AsmCustomer360Component
justinlee01 Dec 2, 2022
ce1b7d0
Deleting unused AsmCustomerListingComponent and MapData
justinlee01 Dec 2, 2022
a80d955
Unit tests for AsmCustomerProductReviewsComponent
justinlee01 Dec 5, 2022
73fa169
Unit tests for AsmCustomerSectionComponent
justinlee01 Dec 5, 2022
d66bac0
Unit tests for Asm360Service
justinlee01 Dec 6, 2022
aa4edaf
Merge branch 'develop' into task/asm-360-rebase-develop
kimhw0630 Dec 8, 2022
d90a525
Add license header
github-actions[bot] Dec 8, 2022
b308213
Merge branch 'develop' into task/asm-360-rebase-develop
justinlee01 Jan 4, 2023
24cc75b
Add license header
github-actions[bot] Jan 4, 2023
ac4de72
Unit test for openCustomer360 method in CustomerEmulationComponent
justinlee01 Jan 4, 2023
f6ba700
Unit tests for new methods in AsmComponentService
justinlee01 Jan 4, 2023
99bbd5e
Unit tests for AsmService
justinlee01 Jan 4, 2023
7591579
Adding storefinder paths to cdc tsconfig
justinlee01 Jan 5, 2023
4c26122
Removing unneeded dependency for CustomerOverviewComponent, correctin…
justinlee01 Jan 5, 2023
0e004c8
Generating new dependencies.json for ASM
justinlee01 Jan 5, 2023
a083127
Fixing styles that violated lint rules
justinlee01 Jan 5, 2023
b4c5e00
Build storefinder earlier in build process
justinlee01 Jan 5, 2023
50fe601
Fixing integration test expectations and Sonar issues
justinlee01 Jan 5, 2023
f51bde0
Removing console.log from test and writing excluded test to be filled…
justinlee01 Jan 6, 2023
b80c449
Adding E2E test for customer 360
justinlee01 Jan 11, 2023
cdbb8ac
WIP: Removing AsmCustomerOverviewComponent and splitting it up into s…
justinlee01 Jan 13, 2023
76622e5
WIP: Separating out Active Cart in overview to its own CMS component
justinlee01 Jan 19, 2023
97267e6
Splitting out AsmCustomerSavedCartComponent from Overview and deletin…
justinlee01 Jan 20, 2023
f06971c
Add license header
github-actions[bot] Jan 20, 2023
ba7a361
Using actual OCC response and adjusting to changes in API
justinlee01 Jan 23, 2023
bb1c1a3
Updating unit tests after moving code and cleaning up translations file
justinlee01 Jan 25, 2023
2573b1a
Removing unused methods in AsmService
justinlee01 Jan 25, 2023
9898328
Updating unit tests
justinlee01 Jan 25, 2023
50a313f
Removing dependency on PopoverModule in AsmComponentsModule
justinlee01 Jan 25, 2023
658a6df
Removing unnecessary changes related to NgRx
justinlee01 Jan 25, 2023
8f3d4e0
anchor tag to button
hakwookim Jan 28, 2023
551d33c
Merge branch 'develop' into task/asm-360-rebase-develop
justinlee01 Jan 30, 2023
4170aea
accessibility for dialog and tab (#16829)
kimhw0630 Jan 30, 2023
1f9c4aa
forgot to update css for tab
hakwookim Jan 30, 2023
52209a0
some more accessibility changes (#16833)
kimhw0630 Jan 31, 2023
dda8b5f
accessibility on table sort
hakwookim Jan 31, 2023
3a35f54
Using Commands over Queries for Asm360Service (#16843)
justinlee01 Feb 2, 2023
3aa368f
after button broke rules
hakwookim Feb 2, 2023
8b8bcf2
Task/asm 360 lazy load (#16895)
justinlee01 Feb 13, 2023
c07ab8f
added accessibility for table component (#16934)
kimhw0630 Feb 24, 2023
62cd7f6
Merge remote-tracking branch 'origin/develop' into task/asm-360-rebas…
hakwookim Feb 28, 2023
dcd5a2b
Merge branch 'develop' into task/asm-360-rebase-develop
kimhw0630 Feb 28, 2023
013de6e
ran npm run config:update
hakwookim Feb 28, 2023
6be8c08
update lock file
hakwookim Feb 28, 2023
e44736d
update package-lock.json to have qs dependency
ercultimate Feb 28, 2023
6dbf890
update unit test
hakwookim Mar 1, 2023
e345b22
removed deprecated code
hakwookim Mar 3, 2023
2489c02
sonar issue & updated deprecated code
hakwookim Mar 3, 2023
b513586
Merge branch 'develop' into task/asm-360-rebase-develop
kimhw0630 Mar 3, 2023
1731ad4
removed asm360 util (#16996)
kimhw0630 Mar 6, 2023
efb589f
Merge branch 'develop' into task/asm-360-rebase-develop
kimhw0630 Mar 6, 2023
808b373
Merge remote-tracking branch 'origin/develop' into task/asm-360-rebas…
ercultimate Mar 9, 2023
38782f1
reorganize customer-360 module
ercultimate Mar 17, 2023
7ebd59d
Merge remote-tracking branch 'origin/develop' into archive/customer-3…
ercultimate Mar 20, 2023
9a7cdaa
move dialog component to customer-360 root module
ercultimate Mar 22, 2023
04a4855
update unit tests with refactored imports
ercultimate Mar 22, 2023
5c5d2c9
update config and fix cart product item component not rendering
ercultimate Mar 22, 2023
bf7ac71
remove unused providers from customer-360 root module
ercultimate Mar 22, 2023
d1be4e2
remove duplicated copyright header in customer-360
ercultimate Mar 22, 2023
2901c6f
- rename asm-customer-360 feature identifier to customer-360 feature
ercultimate Mar 22, 2023
252fbc0
fix customer-360 style module not loading
ercultimate Mar 22, 2023
f83a987
css class clean up
hakwookim Mar 22, 2023
ce82915
fix interest section and clean up
hakwookim Mar 23, 2023
2687d9e
Merge branch 'develop' into task/asm-360-rebase-develop
kimhw0630 Mar 23, 2023
97f26c6
Add license header
github-actions[bot] Mar 23, 2023
85d1d34
fix unit test
hakwookim Mar 23, 2023
5d943fe
ran npm run config:update
hakwookim Mar 23, 2023
b6981ec
fix sonar issues
hakwookim Mar 23, 2023
f74b68f
separate translation file from main ASM (#17117)
kimhw0630 Mar 23, 2023
435a04e
schematics for customer 360 (#17121)
kimhw0630 Mar 24, 2023
9c8f381
clean copy right
hakwookim Mar 24, 2023
16d9c3f
Merge branch 'develop' into task/asm-360-rebase-develop
kimhw0630 Mar 24, 2023
2c1ec2e
update schematics
hakwookim Mar 27, 2023
1d7e712
Merge branch 'develop' into task/asm-360-rebase-develop
kimhw0630 Mar 27, 2023
f1bc97c
Added feedback tab
hakwookim Mar 27, 2023
3b4f151
fix lint issue...
hakwookim Mar 28, 2023
77e138f
added Feedback tab and support interest component
hakwookim Mar 30, 2023
dbc3239
Merge branch 'develop' into task/asm-360-rebase-develop
kimhw0630 Mar 30, 2023
21fe63e
update missing dependency
hakwookim Mar 30, 2023
598f7cd
add converter for backend respone
hakwookim Mar 30, 2023
edea06d
add mock data
hakwookim Apr 1, 2023
b492bae
Add license header
github-actions[bot] Apr 1, 2023
291a8fa
update mock
hakwookim Apr 3, 2023
d829efb
Profile change to use new api
hakwookim Apr 3, 2023
c61a897
update navigate to support ticket
hakwookim Apr 4, 2023
d677969
remove unused property in review and ticket tables
hakwookim Apr 6, 2023
5ae3555
update unit test for support tickets
hakwookim Apr 7, 2023
1be9eff
updated unit test for profile tab
hakwookim Apr 10, 2023
1715807
updated support tickets unit test
hakwookim Apr 10, 2023
4c9e834
fix styling not appearing on production mode
RadhepS Apr 10, 2023
07f18c0
Task/overview active cart (#17257)
kimhw0630 Apr 12, 2023
8285dc9
feature: overview saved cart refactor (part of CXSPA-1443) (#17269)
kimhw0630 Apr 13, 2023
3b7541e
refactor: update Customer 360 activity list to comply with new OCC ap…
RadhepS Apr 17, 2023
ff79e21
update profile model and use real data (#17303)
kimhw0630 Apr 19, 2023
79bd628
fix: use store finder configuration for map (#17305)
kimhw0630 Apr 21, 2023
95d8bfe
feat: support active language and currency in customer360 (#17314)
kimhw0630 Apr 21, 2023
4b27f85
chore: update activity list to use real endpoint data
RadhepS Apr 24, 2023
96de80d
add tooltip for table component
hakwookim Apr 24, 2023
5c2594b
Merge branch 'develop' into task/asm-360-rebase-develop
kimhw0630 Apr 25, 2023
891c259
test: add e2e tests for customer360 and activity tab (#17353)
RadhepS May 1, 2023
205fbf1
chore: Add epic jira value to Activity List E2Es (#17359)
RadhepS May 1, 2023
da570ee
chore : update overview sections to use real data(CXSPA-3136) (#17343)
kimhw0630 May 4, 2023
75a957a
feat : C360 Feedback tab (CXSPA-3139) (#17382)
kimhw0630 May 8, 2023
43138af
feat : handle session timeout (CXSPA-3298) (#17397)
kimhw0630 May 11, 2023
f53d231
test: add e2e tests for customer360 overview tab (#17396)
RadhepS May 11, 2023
deeeac0
test: add e2e tests for customer360 profile tab (#17405)
RadhepS May 11, 2023
dcfc31d
feat: handle additional request parameters (CXSPA-3332) (#17407)
kimhw0630 May 11, 2023
22970ba
feat : customer360 unhappy Path handles (CXSPA-3297) (#17425)
kimhw0630 May 17, 2023
8abbe1e
feat: check configuration to enable customer360 (CXSPA-3011) (#17429)
kimhw0630 May 24, 2023
e7ce279
test: add E2E tests for feedback tab (#17426)
RadhepS May 25, 2023
63651c5
test: add customer 360 maps e2e (#17447)
RadhepS May 25, 2023
b14363f
feature: update storefinder module and cleanup (CXSPA-3463) (#17450)
kimhw0630 May 26, 2023
31010f1
clean up endpoints
hakwookim May 29, 2023
6d7708a
feat : allow configuration of text alignment in table component(CXSPA…
kimhw0630 Jun 7, 2023
da48de7
feat: additional attributes & new configurations (CXSPA-3493) (#17499)
kimhw0630 Jun 9, 2023
7ac6833
Merge remote-tracking branch 'origin/develop-6.3.x' into test/asmcust…
hakwookim Jul 2, 2023
64a9e74
fix unit test
hakwookim Jul 2, 2023
572402e
fix path problem
hakwookim Jul 2, 2023
c2d3547
fix file format
hakwookim Jul 2, 2023
896575d
git push origin -u epic/CXSPA-700
hakwookim Jul 4, 2023
60b0b20
update date format using global configuration
hakwookim Jul 4, 2023
40731c9
update build order(storefinder)
hakwookim Jul 4, 2023
17ed124
hakwookim Jul 4, 2023
f8d3f1e
reorder build
hakwookim Jul 4, 2023
27f8a52
feature flags
hakwookim Jul 5, 2023
219d02c
Merge branch 'develop-6.3.x' into epic/CXSPA-700
kimhw0630 Jul 5, 2023
28c8fdd
Merge branch 'develop-6.3.x' into epic/CXSPA-700
kimhw0630 Jul 8, 2023
92b2b1e
rollback changes
hakwookim Jul 8, 2023
ef8200e
support additional backend attribute (#17655)
kimhw0630 Jul 20, 2023
4370f73
Feat: As an assisted service agent, I want to view list of coupons pa…
i53577 Aug 9, 2023
e18ecd8
Feat: As an assisted service agent, I want to view list of customer c…
i53577 Aug 18, 2023
5c300d7
feat: As an assisted service agent, I want to view list of potential …
Melody-zhou-512 Aug 24, 2023
3a6b135
Merge remote-tracking branch 'origin/develop-6.5.x' into epic/CXSPA-700
hakwookim Aug 31, 2023
e648df3
fix tsconfig
hakwookim Aug 31, 2023
2b23120
fix schematics unit test
hakwookim Aug 31, 2023
b4b8d09
fix sonar issues on promotion table
hakwookim Sep 7, 2023
34643b8
Merge branch 'develop-6.5.x' into epic/CXSPA-700
kimhw0630 Sep 8, 2023
2097401
fixed e2e problem with ASM emulation in customer360
hakwookim Sep 13, 2023
67cf486
CXSPA-700: fix promotion tabs issue and make tests as flaky
i53577 Sep 14, 2023
956e5c5
CXSPA-700: mark accessibility tests as flaky
i53577 Sep 14, 2023
e8faae8
CXSPA-4699: complete errorMessageHeader as mockup (#17836)
i53577 Sep 15, 2023
1d186a6
feat: ASM C360 Refactor (CXSPA-4773) (#17874)
kimhw0630 Sep 26, 2023
1eef230
feat: ASM C360 Refactor: unify names(files, component, module, select…
kimhw0630 Sep 27, 2023
2e559f6
Merge branch 'develop-6.5.x' into epic/CXSPA-700
kimhw0630 Sep 27, 2023
8a71d42
tsconfig update
hakwookim Sep 27, 2023
9c06cb4
feat: ASM C360 Address comments (#17900)
kimhw0630 Oct 4, 2023
a9e12f9
Merge branch 'develop-6.5.x' into epic/CXSPA-700
kimhw0630 Oct 4, 2023
84d1826
Merge branch 'develop-6.6.x' into epic/CXSPA-700
kimhw0630 Oct 4, 2023
0f72bd6
enable customer360 e2e
hakwookim Oct 5, 2023
d13fe42
Merge branch 'develop-6.6.x' into epic/CXSPA-700
kimhw0630 Oct 5, 2023
4f65eb5
Merge branch 'develop-6.6.x' into epic/CXSPA-700
kimhw0630 Oct 5, 2023
590dc29
hakwookim Oct 5, 2023
a30d335
fix: first build Storefinder and only then Asm (#17925)
Platonn Oct 6, 2023
3ee1585
Merge branch 'develop-6.6.x' into epic/CXSPA-700
kimhw0630 Oct 6, 2023
35c2cc4
Merge branch 'develop-6.6.x' into epic/CXSPA-700
kimhw0630 Oct 6, 2023
82012bd
fix(build): typo npm:build:storefinder -> npm run build:storefinder (…
Platonn Oct 10, 2023
3d6156f
feat: rename components (classes, html selectors, filenames) and modu…
kimhw0630 Oct 11, 2023
5a44ec9
Merge branch 'develop-6.6.x' into epic/CXSPA-700
kimhw0630 Oct 11, 2023
6b95d0f
Merge branch 'develop-6.6.x' into epic/CXSPA-700
kimhw0630 Oct 12, 2023
8adf1a5
hakwookim Oct 12, 2023
5b5c270
Merge branch 'develop-6.6.x' into epic/CXSPA-700
kimhw0630 Oct 17, 2023
3b7caf3
ran npm run config:update
hakwookim Oct 17, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions core-libs/setup/tsconfig.spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,24 @@
"../../feature-libs/asm/components/public_api"
],
"@spartacus/asm/core": ["../../feature-libs/asm/core/public_api"],
"@spartacus/asm/customer-360/assets": [
"../../feature-libs/asm/customer-360/assets/public_api"
],
"@spartacus/asm/customer-360/components": [
"../../feature-libs/asm/customer-360/components/public_api"
],
"@spartacus/asm/customer-360/core": [
"../../feature-libs/asm/customer-360/core/public_api"
],
"@spartacus/asm/customer-360": [
"../../feature-libs/asm/customer-360/public_api"
],
"@spartacus/asm/customer-360/occ": [
"../../feature-libs/asm/customer-360/occ/public_api"
],
"@spartacus/asm/customer-360/root": [
"../../feature-libs/asm/customer-360/root/public_api"
],
"@spartacus/asm": ["../../feature-libs/asm/public_api"],
"@spartacus/asm/occ": ["../../feature-libs/asm/occ/public_api"],
"@spartacus/asm/root": ["../../feature-libs/asm/root/public_api"],
Expand Down
2 changes: 2 additions & 0 deletions feature-libs/asm/_index.scss
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
@import '@spartacus/styles/scss/core';
@import './styles/index';

@import './customer-360/index';
1 change: 1 addition & 0 deletions feature-libs/asm/assets/translations/en/asm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const asm = {
logout: 'Sign Out',
hideUi: 'Close ASM',
customers: 'Customers',
asmCustomer360Button: '360 Customer View',
createCustomerSuccessfullyAlert:
'The customer account has been created and the customer session has started.',
saveInactiveCartAlertInfo:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
<label class="cx-asm-uid">{{ customer?.uid }}</label>
</div>
<cx-asm-bind-cart></cx-asm-bind-cart>
<ng-container *cxFeatureLevel="'6.6'">
<button
*ngIf="isAsmCustomer360Configured && customer"
#asmCustomer360Launcher
class="cx-360-button"
(click)="openAsmCustomer360()"
>
{{ 'asm.asmCustomer360Button' | cxTranslate }}
</button>
</ng-container>
<button formcontrolname="logoutCustomer" (click)="logoutCustomer()">
{{ 'asm.endEmulation' | cxTranslate }}
</button>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,78 @@
import { DebugElement } from '@angular/core';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { I18nTestingModule, User } from '@spartacus/core';
import {
FeatureModulesService,
FeaturesConfig,
FeaturesConfigModule,
I18nTestingModule,
User,
} from '@spartacus/core';
import { LaunchDialogService, LAUNCH_CALLER } from '@spartacus/storefront';
import { UserAccountFacade } from '@spartacus/user/account/root';
import { MockFeatureLevelDirective } from 'projects/storefrontlib/shared/test/mock-feature-level-directive';
import { Observable, of } from 'rxjs';
import { BehaviorSubject, Observable, of } from 'rxjs';
import { AsmComponentService } from '../services/asm-component.service';
import { CustomerEmulationComponent } from './customer-emulation.component';

class MockUserAccountFacade implements Partial<UserAccountFacade> {
get(): Observable<User> {
return of({});
describe('CustomerEmulationComponent', () => {
class MockUserAccountFacade implements Partial<UserAccountFacade> {
get(): Observable<User> {
return of({});
}
}
}

class MockAsmComponentService {
logoutCustomer(): void {}
isCustomerEmulationSessionInProgress(): Observable<boolean> {
return of(true);
class MockAsmComponentService {
logoutCustomer(): void {}
isCustomerEmulationSessionInProgress(): Observable<boolean> {
return of(true);
}
handleAsmDialogAction(): void {}
}

const dialogClose$ = new BehaviorSubject<any>('');
class MockLaunchDialogService implements Partial<LaunchDialogService> {
openDialogAndSubscribe() {}
get dialogClose() {
return dialogClose$.asObservable();
}
}

class mockFeatureModulesService implements Partial<FeatureModulesService> {
isConfigured(): boolean {
return true;
}
resolveFeature(featureName: string): Observable<any> {
return of(featureName);
}
}
}

describe('CustomerEmulationComponent', () => {
let component: CustomerEmulationComponent;
let fixture: ComponentFixture<CustomerEmulationComponent>;
let userAccountFacade: UserAccountFacade;
let asmComponentService: AsmComponentService;
let el: DebugElement;
let featureModulesService: FeatureModulesService;

beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [I18nTestingModule],
imports: [I18nTestingModule, FeaturesConfigModule],
declarations: [CustomerEmulationComponent, MockFeatureLevelDirective],
providers: [
{
provide: FeatureModulesService,
useClass: mockFeatureModulesService,
},
{ provide: UserAccountFacade, useClass: MockUserAccountFacade },
{ provide: AsmComponentService, useClass: MockAsmComponentService },
{ provide: LaunchDialogService, useClass: MockLaunchDialogService },
{
provide: FeaturesConfig,
useValue: {
features: { level: '6.3' },
},
},
],
}).compileComponents();
})
Expand All @@ -47,6 +84,7 @@ describe('CustomerEmulationComponent', () => {
fixture.detectChanges();
userAccountFacade = TestBed.inject(UserAccountFacade);
asmComponentService = TestBed.inject(AsmComponentService);
featureModulesService = TestBed.inject(FeatureModulesService);
el = fixture.debugElement;
});

Expand Down Expand Up @@ -89,4 +127,54 @@ describe('CustomerEmulationComponent', () => {
//assert
expect(asmComponentService.logoutCustomer).toHaveBeenCalled();
});

it('should open customer 360 dialog', () => {
const launchDialogService = TestBed.inject(LaunchDialogService);

spyOn(launchDialogService, 'openDialogAndSubscribe').and.stub();

spyOn(asmComponentService, 'handleAsmDialogAction').and.stub();

component.openAsmCustomer360();

expect(launchDialogService.openDialogAndSubscribe).toHaveBeenCalledTimes(1);
const [caller, , data] = (<jasmine.Spy>(
launchDialogService.openDialogAndSubscribe
)).calls.argsFor(0);
expect(caller).toBe(LAUNCH_CALLER.ASM_CUSTOMER_360);
expect(data).toEqual({ customer: {} });

expect(asmComponentService.handleAsmDialogAction).not.toHaveBeenCalled();

dialogClose$.next({});

expect(asmComponentService.handleAsmDialogAction).toHaveBeenCalledTimes(1);
expect(asmComponentService.handleAsmDialogAction).toHaveBeenCalledWith(
{} as any
);
});

it('should display customer 360 button if asm customer360 is configured.', () => {
spyOn(featureModulesService, 'isConfigured').and.returnValue(true);
spyOn(userAccountFacade, 'get').and.returnValue(
of({ uid: '[email protected]', name: 'Test User' })
);
component.ngOnInit();
fixture.detectChanges();

expect(component.isAsmCustomer360Configured).toBeTruthy();
expect(el.query(By.css('.cx-360-button'))).toBeTruthy();
});

it('should not display customer 360 button if asm customer360 is not configured.', () => {
spyOn(featureModulesService, 'isConfigured').and.returnValue(false);
spyOn(userAccountFacade, 'get').and.returnValue(
of({ uid: '[email protected]', name: 'Test User' })
);
component.ngOnInit();
fixture.detectChanges();

expect(component.isAsmCustomer360Configured).toBeFalsy();
expect(el.query(By.css('.cx-360-button'))).toBeFalsy();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,20 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { Component, OnDestroy, OnInit } from '@angular/core';
import { User } from '@spartacus/core';
import {
Component,
ElementRef,
OnDestroy,
OnInit,
Optional,
ViewChild,
} from '@angular/core';
import { AsmDialogActionEvent } from '@spartacus/asm/customer-360/root';
import { FeatureModulesService, User } from '@spartacus/core';
import { LaunchDialogService, LAUNCH_CALLER } from '@spartacus/storefront';
import { UserAccountFacade } from '@spartacus/user/account/root';
import { Observable, Subscription } from 'rxjs';
import { BehaviorSubject, Observable, Subscription } from 'rxjs';
import { filter } from 'rxjs/operators';
import { AsmComponentService } from '../services/asm-component.service';

@Component({
Expand All @@ -17,14 +27,47 @@ import { AsmComponentService } from '../services/asm-component.service';
export class CustomerEmulationComponent implements OnInit, OnDestroy {
customer: User;
isCustomerEmulationSessionInProgress$: Observable<boolean>;

isAsmCustomer360Configured: boolean | undefined = false;
isAsmCustomer360Loaded$ = new BehaviorSubject<boolean>(false);

@ViewChild('asmCustomer360Launcher')
asmCustomer360LauncherElement: ElementRef;

protected subscription = new Subscription();

constructor(
asmComponentService: AsmComponentService,
userAccountFacade: UserAccountFacade,
// eslint-disable-next-line @typescript-eslint/unified-signatures
launchDialogService: LaunchDialogService,
featureModules: FeatureModulesService
);
/**
* @deprecated since 7.0
*/
constructor(
asmComponentService: AsmComponentService,
userAccountFacade: UserAccountFacade
);
constructor(
protected asmComponentService: AsmComponentService,
protected userAccountFacade: UserAccountFacade
protected userAccountFacade: UserAccountFacade,
// TODO(CXSPA-3090): Remove optional flag in 7.0
@Optional() protected launchDialogService?: LaunchDialogService,
@Optional() protected featureModules?: FeatureModulesService
) {}

ngOnInit() {
this.isAsmCustomer360Configured =
this.featureModules?.isConfigured('asmCustomer360');
if (this.isAsmCustomer360Configured) {
// trigger lazy loading of the Customer 360 feature:
this.featureModules?.resolveFeature('asmCustomer360').subscribe(() => {
this.isAsmCustomer360Loaded$.next(true);
});
}

this.subscription.add(
this.userAccountFacade.get().subscribe((user) => {
if (user) {
Expand All @@ -40,6 +83,29 @@ export class CustomerEmulationComponent implements OnInit, OnDestroy {
this.asmComponentService.logoutCustomer();
}

openAsmCustomer360() {
this.subscription.add(
this.isAsmCustomer360Loaded$
.pipe(filter((isReady) => Boolean(isReady)))
.subscribe(() => {
const data = { customer: this.customer };
this.launchDialogService?.openDialogAndSubscribe(
LAUNCH_CALLER.ASM_CUSTOMER_360,
this.asmCustomer360LauncherElement,
data
);

this.subscription.add(
this.launchDialogService?.dialogClose
.pipe(filter((result) => Boolean(result)))
.subscribe((event: AsmDialogActionEvent) => {
this.asmComponentService.handleAsmDialogAction(event);
})
);
})
);
}

ngOnDestroy(): void {
this.subscription.unsubscribe();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
AsmDeepLinkService,
AsmEnablerService,
} from '@spartacus/asm/root';
import { AsmDialogActionType } from '@spartacus/asm/customer-360/root';
import { AuthService, WindowRef, RoutingService } from '@spartacus/core';
import { Observable, of } from 'rxjs';
import { take } from 'rxjs/operators';
Expand Down Expand Up @@ -61,16 +62,16 @@ class MockAsmDeepLinkService implements Partial<AsmDeepLinkService> {
}
}

class MockRoutingService implements Partial<RoutingService> {
go = () => Promise.resolve(true);
}

class MockAsmEnablerService implements Partial<AsmEnablerService> {
isEmulateInURL(): boolean {
return true;
}
}

class MockRoutingService implements Partial<RoutingService> {
go = () => Promise.resolve(true);
}

describe('AsmComponentService', () => {
let authService: AuthService;
let csAgentAuthService: CsAgentAuthService;
Expand All @@ -86,6 +87,7 @@ describe('AsmComponentService', () => {
{ provice: AsmDeepLinkService, useClass: MockAsmDeepLinkService },
{ provide: RoutingService, useClass: MockRoutingService },
{ provide: AsmEnablerService, useClass: MockAsmEnablerService },
{ provide: RoutingService, useClass: MockRoutingService },
],
});

Expand Down Expand Up @@ -183,4 +185,20 @@ describe('AsmComponentService', () => {
});
});
});

describe('customer 360()', () => {
it('should handle dialog actions', () => {
const routingService = TestBed.inject(RoutingService);
spyOn(routingService, 'go').and.stub();

asmComponentService.handleAsmDialogAction({
actionType: AsmDialogActionType.NAVIGATE,
route: '/',
selectedUser: {},
});

expect(routingService.go).toHaveBeenCalledTimes(1);
expect(routingService.go).toHaveBeenCalledWith('/');
});
});
});
Loading