-
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.
feat: punchout functionality - user management, basket transmission, …
…functions routing (OCI Punchout) (#490) - a B2B user with administration rights can manage OCI Punchot users in the My Account section - a punchout user will see reduced functionality when browsing the storefront - transfer a basket as OCI punchout order to the given punchout system (HOOK_URL) - handle punchout functions (LOGIN, DETAILS, VALIDATE, SEARCH) through a dedicated punchout route - 'punchout' needs to be enabled via feature toggle Co-authored-by: Stefan Hauke <s.hauke@intershop.de>
- Loading branch information
Showing
79 changed files
with
2,628 additions
and
104 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
27 changes: 27 additions & 0 deletions
27
e2e/cypress/integration/pages/account/punchout-create.page.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,27 @@ | ||
import { fillFormField } from '../../framework'; | ||
|
||
declare interface PunchoutUserCreateForm { | ||
login: string; | ||
password: string; | ||
passwordConfirmation: string; | ||
} | ||
|
||
export class PunchoutCreatePage { | ||
readonly tag = 'ish-account-punchout-create-page'; | ||
|
||
private submitButton = () => cy.get('[data-testing-id="create-punchout-user-submit"]'); | ||
|
||
fillForm(content: PunchoutUserCreateForm) { | ||
Object.keys(content) | ||
.filter(key => content[key] !== undefined) | ||
.forEach((key: keyof PunchoutUserCreateForm) => { | ||
fillFormField(this.tag, key, content[key]); | ||
}); | ||
|
||
return this; | ||
} | ||
|
||
submit() { | ||
this.submitButton().click(); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
e2e/cypress/integration/pages/account/punchout-edit.page.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,19 @@ | ||
import { waitLoadingEnd } from '../../framework'; | ||
|
||
export class PunchoutEditPage { | ||
readonly tag = 'ish-account-punchout-details-page'; | ||
|
||
private submitButton = () => cy.get('[data-testing-id="update-punchout-user-submit"]'); | ||
|
||
editActiveFlag(active: boolean) { | ||
cy.get('[data-testing-id="active"]').uncheck(); | ||
if (active) { | ||
cy.get('[data-testing-id="active"]').check(); | ||
} | ||
} | ||
|
||
submit() { | ||
this.submitButton().click(); | ||
waitLoadingEnd(1000); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
e2e/cypress/integration/pages/account/punchout-overview.page.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,38 @@ | ||
import { waitLoadingEnd } from '../../framework'; | ||
import { BreadcrumbModule } from '../breadcrumb.module'; | ||
import { HeaderModule } from '../header.module'; | ||
|
||
export class PunchoutOverviewPage { | ||
readonly tag = 'ish-account-punchout-page'; | ||
|
||
readonly header = new HeaderModule(); | ||
readonly breadcrumb = new BreadcrumbModule(); | ||
|
||
get userList() { | ||
return cy.get('div[data-testing-id="user-list"]'); | ||
} | ||
|
||
get emptyList() { | ||
return cy.get(this.tag).find('[data-testing-id="empty-user-list"]'); | ||
} | ||
|
||
get successMessage() { | ||
return { | ||
message: cy.get('#toast-container').find('.toast-message'), | ||
}; | ||
} | ||
|
||
addUser() { | ||
cy.get('button[data-testing-id="add-user-button"]').click(); | ||
} | ||
|
||
editUser(login: string) { | ||
cy.get(this.tag).contains('div.list-item-row', login).find('[data-testing-id="edit-user"]').click(); | ||
} | ||
|
||
deleteUser(login: string) { | ||
cy.get(this.tag).contains('div.list-item-row', login).find('[data-testing-id="delete-user"]').click(); | ||
cy.get('[data-testing-id="confirm"]', { timeout: 2000 }).click(); | ||
waitLoadingEnd(2000); | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
e2e/cypress/integration/specs/extras/punchout-management.b2b.e2e-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,67 @@ | ||
import { at } from '../../framework'; | ||
import { createB2BUserViaREST } from '../../framework/b2b-user'; | ||
import { LoginPage } from '../../pages/account/login.page'; | ||
import { PunchoutCreatePage } from '../../pages/account/punchout-create.page'; | ||
import { PunchoutEditPage } from '../../pages/account/punchout-edit.page'; | ||
import { PunchoutOverviewPage } from '../../pages/account/punchout-overview.page'; | ||
import { sensibleDefaults } from '../../pages/account/registration.page'; | ||
|
||
const _ = { | ||
user: { | ||
login: `test${new Date().getTime()}@testcity.de`, | ||
...sensibleDefaults, | ||
}, | ||
ociUser: { | ||
login: `punchoutuser${new Date().getTime()}@test.intershop.de`, | ||
password: 'Intershop00!', | ||
}, | ||
}; | ||
|
||
describe('Punchout MyAccount Functionality', () => { | ||
before(() => { | ||
createB2BUserViaREST(_.user); | ||
}); | ||
|
||
it('should start punchout management by logging in', () => { | ||
LoginPage.navigateTo('/account/punchout'); | ||
at(LoginPage, page => { | ||
page.fillForm(_.user.login, _.user.password); | ||
page.submit().its('response.statusCode').should('equal', 200); | ||
}); | ||
at(PunchoutOverviewPage, page => { | ||
page.emptyList.should('be.visible'); | ||
}); | ||
}); | ||
|
||
it('admin user creates a punchout user', () => { | ||
at(PunchoutOverviewPage, page => page.addUser()); | ||
at(PunchoutCreatePage, page => { | ||
page.fillForm({ ..._.ociUser, passwordConfirmation: _.ociUser.password }); | ||
page.submit(); | ||
}); | ||
at(PunchoutOverviewPage, page => { | ||
page.userList.should('contain', `${_.ociUser.login}`); | ||
page.userList.should('not.contain', `Inactive`); | ||
page.successMessage.message.should('contain', 'created'); | ||
}); | ||
}); | ||
|
||
it('admin user sets a punchout user inactive', () => { | ||
at(PunchoutOverviewPage, page => page.editUser(_.ociUser.login)); | ||
at(PunchoutEditPage, page => { | ||
page.editActiveFlag(false); | ||
page.submit(); | ||
}); | ||
at(PunchoutOverviewPage, page => { | ||
page.userList.should('contain', `Inactive`); | ||
}); | ||
}); | ||
|
||
it('admin user deletes a punchout user', () => { | ||
at(PunchoutOverviewPage, page => { | ||
page.deleteUser(_.ociUser.login); | ||
page.userList.should('not.exist'); | ||
page.emptyList.should('be.visible'); | ||
}); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*/**/*.* |
20 changes: 20 additions & 0 deletions
20
src/app/extensions/punchout/exports/punchout-exports.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,20 @@ | ||
import { NgModule } from '@angular/core'; | ||
|
||
import { FeatureToggleModule } from 'ish-core/feature-toggle.module'; | ||
import { LAZY_FEATURE_MODULE } from 'ish-core/utils/module-loader/module-loader.service'; | ||
|
||
import { LazyPunchoutTransferBasketComponent } from './lazy-punchout-transfer-basket/lazy-punchout-transfer-basket.component'; | ||
|
||
@NgModule({ | ||
imports: [FeatureToggleModule], | ||
providers: [ | ||
{ | ||
provide: LAZY_FEATURE_MODULE, | ||
useValue: { feature: 'punchout', location: import('../store/punchout-store.module') }, | ||
multi: true, | ||
}, | ||
], | ||
declarations: [LazyPunchoutTransferBasketComponent], | ||
exports: [LazyPunchoutTransferBasketComponent], | ||
}) | ||
export class PunchoutExportsModule {} |
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,46 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { Store, select } from '@ngrx/store'; | ||
|
||
import { PunchoutUser } from '../models/punchout-user/punchout-user.model'; | ||
import { transferPunchoutBasket } from '../store/punchout-functions'; | ||
import { | ||
addPunchoutUser, | ||
deletePunchoutUser, | ||
getPunchoutError, | ||
getPunchoutLoading, | ||
getPunchoutUsers, | ||
getSelectedPunchoutUser, | ||
loadPunchoutUsers, | ||
updatePunchoutUser, | ||
} from '../store/punchout-users'; | ||
|
||
// tslint:disable:member-ordering | ||
@Injectable({ providedIn: 'root' }) | ||
export class PunchoutFacade { | ||
constructor(private store: Store) {} | ||
|
||
punchoutLoading$ = this.store.pipe(select(getPunchoutLoading)); | ||
punchoutError$ = this.store.pipe(select(getPunchoutError)); | ||
|
||
punchoutUsers$() { | ||
this.store.dispatch(loadPunchoutUsers()); | ||
return this.store.pipe(select(getPunchoutUsers)); | ||
} | ||
selectedPunchoutUser$ = this.store.pipe(select(getSelectedPunchoutUser)); | ||
|
||
addPunchoutUser(user: PunchoutUser) { | ||
this.store.dispatch(addPunchoutUser({ user })); | ||
} | ||
|
||
updatePunchoutUser(user: PunchoutUser) { | ||
this.store.dispatch(updatePunchoutUser({ user })); | ||
} | ||
|
||
deletePunchoutUser(login: string) { | ||
this.store.dispatch(deletePunchoutUser({ login })); | ||
} | ||
|
||
transferBasket() { | ||
this.store.dispatch(transferPunchoutBasket()); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/app/extensions/punchout/models/punchout-user/punchout-user.model.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,7 @@ | ||
export interface PunchoutUser { | ||
id: string; | ||
email: string; | ||
login?: string; | ||
password?: string; | ||
active: boolean; | ||
} |
Oops, something went wrong.