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: CXSPA-4442 New components for email and personal info #17839

Closed
wants to merge 61 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
41950b3
CXSPA-4442: 1st version
scarai-sap Sep 18, 2023
4da3f6f
Add license header
github-actions[bot] Sep 18, 2023
e0ac698
CXSPA-4442: style fixing
scarai-sap Sep 18, 2023
083ab58
CXSPA-4442: style fixing
scarai-sap Sep 18, 2023
46c06b1
Merge branch 'feature/CXSPA-4442' of https://github.com/SAP/spartacus…
scarai-sap Sep 18, 2023
9475ca6
CXSPA-4442: adding msgstrips
scarai-sap Sep 18, 2023
fe6ba12
CXSPA-4442: adding UT for msgstrips
scarai-sap Sep 18, 2023
fda4262
CXSPA-4442: adding UT for msgstrips
scarai-sap Sep 19, 2023
6e4bdc5
Merge branch 'develop-6.5.x' into feature/CXSPA-4442
scarai-sap Sep 19, 2023
7000bfb
CXSPA-4442: update code after code review
scarai-sap Sep 19, 2023
6dd8a39
CXSPA-4442: fix styling
scarai-sap Sep 19, 2023
cb980ae
Merge branch 'feature/CXSPA-4442' of https://github.com/SAP/spartacus…
scarai-sap Sep 19, 2023
f75fcec
Empty-Commit
scarai-sap Sep 19, 2023
5ccd2e1
CXSPA-4442: fix styling
scarai-sap Sep 20, 2023
e711722
Merge branch 'develop-6.5.x' into feature/CXSPA-4442
scarai-sap Sep 20, 2023
e6a3637
Merge branch 'feature/CXSPA-4442' of https://github.com/SAP/spartacus…
scarai-sap Sep 20, 2023
46097a7
update code to v2
scarai-sap Sep 21, 2023
47bd8be
CXSPA-4442: fix issue
scarai-sap Sep 21, 2023
4f7ad4e
CXSPA-4442: Create new combined component
scarai-sap Sep 21, 2023
8b5cc73
CXSPA-4442: For yarn prettier:fix
scarai-sap Sep 21, 2023
0bdf105
Add license header
github-actions[bot] Sep 21, 2023
38efa8c
CXSPA-4442: For UT
scarai-sap Sep 21, 2023
196e776
CXSPA-4442: update css
scarai-sap Sep 21, 2023
da11e24
Merge branch 'feature/CXSPA-4442' of https://github.com/SAP/spartacus…
scarai-sap Sep 21, 2023
f6a3f2e
Merge branch 'develop-6.5.x' into feature/CXSPA-4442
scarai-sap Sep 21, 2023
fab5db9
CXSPA-4442: adding padding as code reviewer suggested
scarai-sap Sep 21, 2023
14bcac0
Merge branch 'feature/CXSPA-4442' of https://github.com/SAP/spartacus…
scarai-sap Sep 21, 2023
26be22c
CXSPA-4442: adding padding as code reviewer v2
scarai-sap Sep 21, 2023
e718574
CXSPA-4442: Adjust edit button
scarai-sap Sep 21, 2023
1d75022
Merge branch 'develop-6.5.x' into feature/CXSPA-4442
scarai-sap Sep 22, 2023
311a6af
CXSPA-4442: Adjust line
scarai-sap Sep 22, 2023
5b6bef0
Merge branch 'feature/CXSPA-4442' of https://github.com/SAP/spartacus…
scarai-sap Sep 22, 2023
40bd73c
rerun pp
scarai-sap Sep 22, 2023
b0ce6ac
trigger pp again
scarai-sap Sep 22, 2023
81469df
Merge branch 'develop-6.5.x' into feature/CXSPA-4442
giancorderoortiz Oct 1, 2023
14a1af8
bug fix: CDC installation Issue (#17898)
anjana-bl Oct 5, 2023
745466c
fix: add FeaturesConfigModule to CheckoutReviewSubmitModule (#17921)
rmch91 Oct 6, 2023
61fd9cd
chore: release 6.5.1 (#17930)
kpawelczak Oct 10, 2023
4750d94
Merge branch 'develop-6.5.x' into feature/CXSPA-4442
scarai-sap Nov 21, 2023
2e75c7c
Merge branch 'develop-6.7.x' of https://github.com/SAP/spartacus into…
scarai-sap Nov 21, 2023
a2b4e84
rename v1
scarai-sap Nov 21, 2023
47b4c2a
rename v2
scarai-sap Nov 21, 2023
c3f771b
CXSPA-4442: update code with rename and test
scarai-sap Nov 21, 2023
7c02b5b
CXSPA-4442: Fix issue for i18n
scarai-sap Nov 21, 2023
7960594
CXSPA-4442: Fix issue can;'t display properly
scarai-sap Nov 22, 2023
d9081e2
CXSPA-4442: use USE_MY_ACCOUNT_V2_PROFILE and USE_MY_ACCOUNT_V2_EMAIL
scarai-sap Nov 22, 2023
29ab549
CXSPA-4442: Fix format
scarai-sap Nov 22, 2023
05c5d38
Add license header
github-actions[bot] Nov 22, 2023
7d4e7b6
CXSPA-4442: Fix format
scarai-sap Nov 22, 2023
2e1bae1
Merge branch 'feature/CXSPA-4442' of https://github.com/SAP/spartacus…
scarai-sap Nov 22, 2023
98b4323
CXSPA-4442: make feature available in lib level
scarai-sap Nov 22, 2023
9fb3bde
Merge branch 'develop-6.7.x' into feature/CXSPA-4442
scarai-sap Nov 22, 2023
487876f
test for update dependencies.json
scarai-sap Nov 22, 2023
1f86c76
CXSPA-4442: Add IT and bug fixing
scarai-sap Nov 23, 2023
110d6f4
update code with rename relocate and fix css issue
scarai-sap Nov 23, 2023
1c03474
format prettier
scarai-sap Nov 23, 2023
3e75acd
Merge branch 'develop-6.7.x' into feature/CXSPA-4442
scarai-sap Nov 24, 2023
9a71df7
CXSPA-4442: Fix typo
scarai-sap Nov 24, 2023
f9ae452
Merge branch 'develop-6.7.x' into feature/CXSPA-4442
scarai-sap Nov 27, 2023
94019a1
Fix issue reported by QA
scarai-sap Dec 4, 2023
c10d743
CXSPA-5564: fix long name and email
scarai-sap Dec 11, 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
3 changes: 2 additions & 1 deletion feature-libs/user/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

$skipComponentStyles: () !default;
$selectors: cx-login, cx-login-form, cx-register, cx-reset-password,
cx-close-account, cx-close-account-modal !default;
cx-close-account, cx-close-account-modal, cx-my-new-account-v2-profile,
cx-my-new-account-v2-email, cx-my-account-v2-combined-profile-email !default;

@each $selector in $selectors {
#{$selector} {
Expand Down
4 changes: 4 additions & 0 deletions feature-libs/user/profile/assets/translations/en/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
*/

import { userProfile } from './user-profile';
import { myAccountV2UserProfile } from './my-account-v2-user-profile.18n';
import { myAccountV2Email } from './my-account-v2-email.18n';

export const en = {
userProfile,
myAccountV2UserProfile,
myAccountV2Email,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* SPDX-FileCopyrightText: 2023 SAP Spartacus team <[email protected]>
*
* SPDX-License-Identifier: Apache-2.0
*/

export const myAccountV2Email = {
myAccountV2Email: {
myEmailAddress: 'My Email Address',
email: 'Email',
emailAddress: 'Email Address',
newEmailAddress: 'New Email Address',
confirmNewEmailAddress: 'Confirm New Email Address',
emailPlaceHolder: 'Enter email',
passwordPlaceHolder: 'Enter password',
password: 'Password',
reloginIndicator:
'You need to log in again after setting a new email address.',
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* SPDX-FileCopyrightText: 2023 SAP Spartacus team <[email protected]>
*
* SPDX-License-Identifier: Apache-2.0
*/

export const myAccountV2UserProfile = {
myAccountV2UserProfile: {
myEmailAddress: 'My Email Address',
myInformation: 'My Information',
name: 'Name',
customerId: 'CustomerId',
title: 'Title',
firstName: 'First name',
lastName: 'Last name',
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ export const userProfileTranslations: TranslationResources = {

export const userProfileTranslationChunksConfig: TranslationChunksConfig = {
userProfile: ['updateEmailForm', 'register', 'forgottenPassword'],
myAccountV2UserProfile: ['myAccountV2UserProfile'],
myAccountV2Email: ['myAccountV2Email'],
};
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-combined-profile-email.component';
export * from './my-account-v2-combined-profile-email.module';
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<div>
<hr />
<div class="row">
<div class="col combined-profile-container">
<cx-my-new-account-v2-profile></cx-my-new-account-v2-profile>
</div>
</div>
<hr />
<div class="row">
<div class="col combined-profile-container">
<cx-my-new-account-v2-email></cx-my-new-account-v2-email>
</div>
</div>
<hr />
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { MyAccountV2CombinedProfileEmailComponent } from './my-account-v2-combined-profile-email.component';

describe('MyProfileV2EmailComponent', () => {
let fixture: ComponentFixture<MyAccountV2CombinedProfileEmailComponent>;
let component: MyAccountV2CombinedProfileEmailComponent;

beforeEach(() => {
fixture = TestBed.createComponent(MyAccountV2CombinedProfileEmailComponent);
component = fixture.componentInstance;
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* SPDX-FileCopyrightText: 2023 SAP Spartacus team <[email protected]>
*
* SPDX-License-Identifier: Apache-2.0
*/

import { Component } from '@angular/core';
@Component({
selector: 'cx-my-account-v2-combined-profile-email ',
templateUrl: './my-account-v2-combined-profile-email.component.html',
})
export class MyAccountV2CombinedProfileEmailComponent {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* 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 { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
import { NgSelectModule } from '@ng-select/ng-select';
import {
AuthGuard,
CmsConfig,
GlobalMessageService,
I18nModule,
provideDefaultConfig,
UrlModule,
} from '@spartacus/core';
import {
FormErrorsModule,
SpinnerModule,
NgSelectA11yModule,
MessageComponentModule,
PageSlotModule,
} from '@spartacus/storefront';
import { UserProfileFacade } from '@spartacus/user/profile/root';
import { MyAccountV2CombinedProfileEmailComponent } from './my-account-v2-combined-profile-email.component';
import { MyAccountV2ProfileComponentService } from '../user-profile';
import { MyAccountV2EmailComponentService } from '../email';
import { UpdateProfileModule } from '../../update-profile';
import { UpdateEmailModule } from '../../update-email';

@NgModule({
imports: [
CommonModule,
FormsModule,
ReactiveFormsModule,
SpinnerModule,
I18nModule,
FormErrorsModule,
RouterModule,
UrlModule,
NgSelectModule,
NgSelectA11yModule,
MessageComponentModule,
PageSlotModule,
UpdateProfileModule,
UpdateEmailModule,
],
providers: [
provideDefaultConfig(<CmsConfig>{
cmsComponents: {
MyAccountV2CombinedProfileEmailComponent: {
component: MyAccountV2CombinedProfileEmailComponent,
guards: [AuthGuard],
providers: [
{
provide: MyAccountV2CombinedProfileEmailComponent,
useClass: MyAccountV2CombinedProfileEmailComponent,
deps: [UserProfileFacade, GlobalMessageService],
},
MyAccountV2EmailComponentService,
MyAccountV2ProfileComponentService,
],
},
},
}),
],
declarations: [MyAccountV2CombinedProfileEmailComponent],
exports: [MyAccountV2CombinedProfileEmailComponent],
})
export class NewCombinedProfileModule {}
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-email-component.service';
export * from './my-account-v2-email.component';
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
import { TestBed, waitForAsync } from '@angular/core/testing';
import { AbstractControl, ReactiveFormsModule } from '@angular/forms';
import {
AuthRedirectService,
AuthService,
GlobalMessageService,
GlobalMessageType,
I18nTestingModule,
RoutingService,
} from '@spartacus/core';
import { FormErrorsModule } from '@spartacus/storefront';
import { UserEmailFacade } from '@spartacus/user/profile/root';
import { of } from 'rxjs';
import { MyAccountV2EmailComponentService } from './my-account-v2-email-component.service';
import createSpy = jasmine.createSpy;
class MockUserEmailService implements Partial<UserEmailFacade> {
update = createSpy().and.returnValue(of({}));
}
class MockAuthService {
coreLogout = createSpy().and.returnValue(Promise.resolve());
}
class MockRoutingService {
go = createSpy().and.stub();
getUrl = createSpy().and.returnValue('');
}
class MockGlobalMessageService {
add = createSpy().and.stub();
}

class MockAuthRedirectService implements Partial<AuthRedirectService> {
setRedirectUrl = createSpy('setRedirectUrl');
}

describe('MyAccountV2EmailComponentService', () => {
let service: MyAccountV2EmailComponentService;
let userService: UserEmailFacade;
let authService: AuthService;
let routingService: RoutingService;
let globalMessageService: GlobalMessageService;
let newUid: AbstractControl;
let confirmNewUid: AbstractControl;
let password: AbstractControl;
let authRedirectService: AuthRedirectService;

beforeEach(() => {
TestBed.configureTestingModule({
imports: [ReactiveFormsModule, I18nTestingModule, FormErrorsModule],
providers: [
MyAccountV2EmailComponentService,
{
provide: RoutingService,
useClass: MockRoutingService,
},
{
provide: GlobalMessageService,
useClass: MockGlobalMessageService,
},
{
provide: UserEmailFacade,
useClass: MockUserEmailService,
},
{
provide: AuthService,
useClass: MockAuthService,
},
{
provide: AuthRedirectService,
useClass: MockAuthRedirectService,
},
],
}).compileComponents();
});

beforeEach(() => {
service = TestBed.inject(MyAccountV2EmailComponentService);

routingService = TestBed.inject(RoutingService);
authService = TestBed.inject(AuthService);
userService = TestBed.inject(UserEmailFacade);
globalMessageService = TestBed.inject(GlobalMessageService);
authRedirectService = TestBed.inject(AuthRedirectService);

newUid = service.form.controls.email;
confirmNewUid = service.form.controls.confirmEmail;
password = service.form.controls.password;
});

it('should create', () => {
expect(service).toBeTruthy();
});

describe('isUpdating$', () => {
it('should return true', () => {
service['busy$'].next(true);
let result;
service.isUpdating$.subscribe((value) => (result = value)).unsubscribe();
expect(result).toBeTrue();
expect(service.form.disabled).toBeTrue();
});

it('should return false', () => {
service['busy$'].next(false);
let result;
service.isUpdating$.subscribe((value) => (result = value)).unsubscribe();
expect(result).toBeFalse;
expect(service.form.disabled).toBeFalse();
});
});

describe('save', () => {
describe('success', () => {
beforeEach(() => {
newUid.setValue('[email protected]');
confirmNewUid.setValue('[email protected]');
password.setValue('Qwe123!');
});

it('should save valid email', () => {
service.save();
expect(userService.update).toHaveBeenCalledWith(
'Qwe123!',
'[email protected]'
);
});

it('should show message', () => {
service.save();
expect(globalMessageService.add).toHaveBeenCalledWith(
{
key: 'updateEmailForm.emailUpdateSuccess',
params: { newUid: '[email protected]' },
},
GlobalMessageType.MSG_TYPE_CONFIRMATION
);
});

it('should logout', () => {
service.save();
expect(authService.coreLogout).toHaveBeenCalled();
});

it(
'should reroute to the login page',
waitForAsync(() => {
service.save();
authService.coreLogout().then(() => {
expect(routingService.go).toHaveBeenCalledWith(
{ cxRoute: 'login' },
{
state: {
newUid: '[email protected]',
},
}
);
});
})
);

it('reset form', () => {
spyOn(service.form, 'reset').and.callThrough();
service.save();
expect(service.form.reset).toHaveBeenCalled();
});

it(
'should set the redirect url to the home page before navigating to the login page',
waitForAsync(() => {
service.save();
expect(authRedirectService.setRedirectUrl).toHaveBeenCalledWith(
routingService.getUrl({ cxRoute: 'home' })
);
authService.coreLogout().then(() => {
expect(authRedirectService.setRedirectUrl).toHaveBeenCalledBefore(
routingService.go
);
});
})
);
});

describe('error', () => {
it('should not save invalid email', () => {
confirmNewUid.setValue('[email protected]');
service.save();
expect(userService.update).not.toHaveBeenCalled();
expect(globalMessageService.add).not.toHaveBeenCalled();
expect(authService.coreLogout).not.toHaveBeenCalled();
expect(routingService.go).not.toHaveBeenCalled();
});
});
});
});
Loading
Loading