Skip to content

Commit

Permalink
rebase payments update (#558)
Browse files Browse the repository at this point in the history
* rebase payments update

* update imports
  • Loading branch information
aChanEP authored and shaunmaharaj committed Jan 13, 2020
1 parent 84df846 commit b1b573a
Show file tree
Hide file tree
Showing 38 changed files with 1,584 additions and 490 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ _site
build
dist


.vscode

# misc
.DS_Store
.env.local
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,11 @@ import fetchMock from 'fetch-mock/es5/client';
import fetchGeoDataResponse from './MockHttpResponses/GET/fetchGeoData_response.json';
import fetchAddressFormResponse from './MockHttpResponses/GET/fetchAddressForm_response.json';
import fetchAddressDataResponse from './MockHttpResponses/GET/fetchAddressData_response.json';
import loginResponse from '../CommonMockHttpResponses/login_response.json';
import submitAddressResponse from './MockHttpResponses/POST/submitAddress_response.json';
import { mockAnonLoginResponse } from '../utils/MockLogins';

fetchMock.config.fallbackToNetwork = true;

function mockLoginResponse(mockObj) {
mockObj.post(
'/cortex/oauth2/tokens',
loginResponse,
);
}

function mockCountriesResponse(mockObj) {
mockObj.get(
/* eslint-disable max-len */
Expand Down Expand Up @@ -81,15 +74,20 @@ function mockSubmitAddressResponseFailureResponse(mockObj) {
}

function mockCommonAddressFormResponses(mockObj) {
mockLoginResponse(mockObj);
mockAnonLoginResponse(mockObj);
mockCountriesResponse(mockObj);
mockAddressFormResponse(mockObj);
mockAddressDataResponse(mockObj);
}

export default function mockAddressFormSubmit() {
export function mockAddressFormSubmitSuccess() {
fetchMock.restore();
mockCommonAddressFormResponses(fetchMock);
mockSubmitAddressResponseSuccessResponse(fetchMock);
}

export function mockAddressFormSubmitFailure() {
fetchMock.restore();
mockCommonAddressFormResponses(fetchMock);
mockSubmitAddressResponseFailureResponse(fetchMock);
}
44 changes: 22 additions & 22 deletions src/components/src/AddressForm/addressform.main.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
*
*/
import React from 'react';
import Readme from './README.md';
import { object, text } from '@storybook/addon-knobs/react';
import { storiesOf } from '@storybook/react';
import mockAddressFormSubmitSuccess from './addressform.main.api.mocks';
import { textToFunc } from "../../../../storybook/utils/storybookUtils"
import { object, text } from "@storybook/addon-knobs/react";
import { textToFunc } from '../../../../storybook/utils/storybookUtils';
import Readme from './README.md';
import { mockAddressFormSubmitSuccess, mockAddressFormSubmitFailure } from './addressform.main.api.mocks';

import AddressFormMain from './addressform.main';

Expand All @@ -40,26 +40,26 @@ storiesOf('Components|AddressFormMain', module)
const addressData = {
address: '/addresses/vestri_b2c',
};
let onCloseModalFuncText = text('onCloseModal','() => {alert("onCloseModal invoked")}');
let fetchDataFuncText = text('fetchData','() => {alert("fetchData invoked")}');
return <AddressFormMain
addressData={object('addressData', addressData)}
onCloseModal={()=>textToFunc(onCloseModalFuncText)}
fetchData={()=>textToFunc(fetchDataFuncText)}
/>
const onCloseModalFuncText = text('onCloseModal', '() => {alert("onCloseModal invoked")}');
const fetchDataFuncText = text('fetchData', '() => {alert("fetchData invoked")}');

return <AddressFormMain
addressData={object('addressData', addressData)}
onCloseModal={() => textToFunc(onCloseModalFuncText)}
fetchData={() => textToFunc(fetchDataFuncText)}
/>;
})
.add('AddressFormMain on save failure', () => {
mockAddressFormSubmitSuccess();
mockAddressFormSubmitFailure();
const addressData = {
address: '/an/incorrect/save/address/link',
address: '/addresses/vestri_b2c',
};
let onCloseModalFuncText = text('onCloseModal','() => {alert("onCloseModal invoked")}');
let fetchDataFuncText = text('fetchData','() => {alert("fetchData invoked")}');
return <AddressFormMain
addressData={object('addressData', addressData)}
onCloseModal={()=>textToFunc(onCloseModalFuncText)}
fetchData={()=>textToFunc(fetchDataFuncText)}
/>
const onCloseModalFuncText = text('onCloseModal', '() => {alert("onCloseModal invoked")}');
const fetchDataFuncText = text('fetchData', '() => {alert("fetchData invoked")}');

return <AddressFormMain
addressData={object('addressData', addressData)}
onCloseModal={() => textToFunc(onCloseModalFuncText)}
fetchData={() => textToFunc(fetchDataFuncText)}
/>;
});
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,17 @@
*/
import fetchMock from 'fetch-mock/es5/client';
import itemLookupMultiCartResponse from '../CommonMockHttpResponses/itemLookupMultiCart_response.json';
import loginResponse from '../CommonMockHttpResponses/login_response.json';
import { mockAnonLoginResponse } from '../utils/MockLogins';

function mockMultiCartResponse(mockObj) {
mockObj.get(
'/cortex/?zoom=carts,carts:element,defaultcart,defaultcart:additemstocartform',
/(.*)\/?zoom=carts,carts:element,defaultcart,defaultcart:additemstocartform/,
itemLookupMultiCartResponse,
);
}

function mockLoginResponse(mockObj) {
mockObj.post(
'/cortex/oauth2/tokens',
loginResponse,
);
}

export function mockProductDisplayItemMainMultiCart() {
export default function mockProductDisplayItemMainMultiCart() {
fetchMock.restore();
mockLoginResponse(fetchMock);
mockAnonLoginResponse(fetchMock);
mockMultiCartResponse(fetchMock);
}
50 changes: 25 additions & 25 deletions src/components/src/AppHeader/appheader.main.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import React from 'react';
import Readme from './README.md';
import { storiesOf } from '@storybook/react';
import { MemoryRouter } from 'react-router';
import { object, text, boolean } from "@storybook/addon-knobs/react";
import { textToFunc } from "../../../../storybook/utils/storybookUtils"
import { object, text, boolean } from '@storybook/addon-knobs/react';
import { textToFunc } from '../../../../storybook/utils/storybookUtils';
import AppHeaderMain from './appheader.main';
import { mockProductDisplayItemMainMultiCart } from './appheader.main.api.mocks.js';
import mockProductDisplayItemMainMultiCart from './appheader.main.api.mocks';

const appHeaderLinks = {
mainPage: '',
Expand Down Expand Up @@ -58,33 +58,33 @@ storiesOf('Components|AppHeaderMain', module)
.add('AppHeaderMain', () => {
mockProductDisplayItemMainMultiCart();

// All AppHeaderMain Callbacks inputted from storybook knobs UI.
let onSearchPageFuncText = text('onSearchPage','() => {alert("onSearchPage invoked")}');
let redirectToMainPageFuncText = text('redirectToMainPage','() => {alert("redirectToMainPage invoked")}');
let handleResetPasswordFuncText = text('handleResetPassword','() => {alert("handleResetPassword invoked")}');
let onCurrencyChangeFuncText = text('onCurrencyChange','() => {alert("onCurrencyChange invoked")}');
let onLocaleChangeFuncText = text('onLocaleChange','() => {alert("onLocaleChange invoked")}');
let onContinueCartFuncText = text('onContinueCart','() => {alert("onContinueCart invoked")}');
let onGoBackFuncText = text('onGoBack','() => {alert("onGoBack invoked")}');

const onSearchPageFuncText = text('onSearchPage', '() => {alert("onSearchPage invoked")}');
const redirectToMainPageFuncText = text('redirectToMainPage', '() => {alert("redirectToMainPage invoked")}');
const handleResetPasswordFuncText = text('handleResetPassword', '() => {alert("handleResetPassword invoked")}');
const onCurrencyChangeFuncText = text('onCurrencyChange', '() => {alert("onCurrencyChange invoked")}');
const onLocaleChangeFuncText = text('onLocaleChange', '() => {alert("onLocaleChange invoked")}');
const onContinueCartFuncText = text('onContinueCart','() => {alert("onContinueCart invoked")}');
const onGoBackFuncText = text('onGoBack', '() => {alert("onGoBack invoked")}');

return (
<MemoryRouter initialEntries={['/']}>
<AppHeaderMain
onSearchPage={()=>textToFunc(onSearchPageFuncText)}
redirectToMainPage={()=>textToFunc(redirectToMainPageFuncText)}
handleResetPassword={()=>textToFunc(handleResetPasswordFuncText)}
onCurrencyChange={()=>textToFunc(onCurrencyChangeFuncText)}
onLocaleChange={()=>textToFunc(onLocaleChangeFuncText)}
onContinueCart={()=>textToFunc(onContinueCartFuncText)}
onGoBack={()=>textToFunc(onGoBackFuncText)}
<AppHeaderMain
onSearchPage={() => textToFunc(onSearchPageFuncText)}
redirectToMainPage={() => textToFunc(redirectToMainPageFuncText)}
handleResetPassword={() => textToFunc(handleResetPasswordFuncText)}
onCurrencyChange={() => textToFunc(onCurrencyChangeFuncText)}
onLocaleChange={() => textToFunc(onLocaleChangeFuncText)}
onContinueCart={() => textToFunc(onContinueCartFuncText)}
onGoBack={() => textToFunc(onGoBackFuncText)}
checkedLocation={boolean('checkedLocation', false)}
isInStandaloneMode={boolean('isInStandaloneMode', false)}
locationSearchData={text('locationSearchData', '')}
appHeaderLinks={object('appHeaderLinks',appHeaderLinks)}
appHeaderLoginLinks={object('appHeaderLoonCurrencyChangeFuncTextginLinks', appHeaderLoginLinks)}
appHeaderNavigationLinks={object('appHeaderNavigationLinks', appHeaderNavigationLinks)}
appHeaderTopLinks={object('appHeaderTopLinks', appHeaderTopLinks)}
appModalLoginLinks={object('appModalLoginLinks', appModalLoginLinks)} />
appHeaderLinks={object('appHeaderLinks', appHeaderLinks)}
appHeaderLoginLinks={object('appHeaderLoonCurrencyChangeFuncTextginLinks', appHeaderLoginLinks)}
appHeaderNavigationLinks={object('appHeaderNavigationLinks', appHeaderNavigationLinks)}
appHeaderTopLinks={object('appHeaderTopLinks', appHeaderTopLinks)}
appModalLoginLinks={object('appModalLoginLinks', appModalLoginLinks)}
/>
</MemoryRouter>
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
import fetchMock from 'fetch-mock/es5/client';
import fetchNavigationDataResponse from './MockHttpResponses/navigation_data_response.json';
import loginResponse from '../CommonMockHttpResponses/login_response.json';
import loginResponse from '../CommonMockHttpResponses/anonymous_login_response.json';

function mockMultiCartResponse(mockObj) {
mockObj.get(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,8 @@
*
*/
import fetchMock from 'fetch-mock/es5/client';
import loginResponse from '../CommonMockHttpResponses/login_response.json';
import mockFetchDependantItemDataResponse from './MockHttpResponses/GET/fetchDependantItemData_response.json';

function mockLoginResponse(mockObj) {
mockObj.post(
'/cortex/oauth2/tokens',
loginResponse,
);
}
import { mockAnonLoginResponse } from '../utils/MockLogins';

function mockFetchDependantItemData(mockObj) {
mockObj.get(
Expand All @@ -38,6 +31,6 @@ function mockFetchDependantItemData(mockObj) {

export default function mockAppModalBundleConfigurationMain() {
fetchMock.restore();
mockLoginResponse(fetchMock);
mockAnonLoginResponse(fetchMock);
mockFetchDependantItemData(fetchMock);
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
import fetchMock from 'fetch-mock/es5/client';
import subAccountResponse from '../CommonMockHttpResponses/b2bSubAccountData_response.json';
import loginResponse from '../CommonMockHttpResponses/login_response.json';
import { mockAnonLoginResponse } from '../utils/MockLogins';

function mockSubAccountResponse(mockObj) {
mockObj.get(
Expand All @@ -29,15 +29,8 @@ function mockSubAccountResponse(mockObj) {
);
}

function mockLoginResponse(mockObj) {
mockObj.post(
'/cortex/oauth2/tokens',
loginResponse,
);
}

export function mockFetchSubAccount() {
export default function mockFetchSubAccount() {
fetchMock.restore();
mockLoginResponse(fetchMock);
mockAnonLoginResponse(fetchMock);
mockSubAccountResponse(fetchMock);
}
19 changes: 9 additions & 10 deletions src/components/src/B2bAccountList/b2b.accountlist.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ import React from 'react';
import Readme from './README.md';
import { storiesOf } from '@storybook/react';
import { MemoryRouter } from 'react-router';
import { object, text, boolean } from "@storybook/addon-knobs/react";
import { textToFunc } from "../../../../storybook/utils/storybookUtils"
import { object, text } from '@storybook/addon-knobs/react';
import { textToFunc } from '../../../../storybook/utils/storybookUtils';
import mockFetchSubAccount from './b2b.accountlist.api.mocks';
import B2bAccountList from './b2b.accountlist';
import SubAccountData from './HttpResponse/accountData_response.json';
import { mockFetchSubAccount } from './b2b.accountlist.api.mocks';


const accountListData = {
status: 'ENABLED',
Expand All @@ -51,16 +50,16 @@ storiesOf('Components|B2bAccountList', module)
.add('B2bAccountList', () => {
mockFetchSubAccount();

let getAccountDataFuncText = text('getAccountData','() => {alert("getAccountData invoked")}');
let getSubAccountDataFuncText = text('getSubAccountData','() => {alert("getSubAccountData invoked")}');
let handleSubAccountClickedFuncText = text('handleSubAccountClicked','() => {alert("handleSubAccountClicked invoked")}');
const getAccountDataFuncText = text('getAccountData','() => {alert("getAccountData invoked")}');
const getSubAccountDataFuncText = text('getSubAccountData','() => {alert("getSubAccountData invoked")}');
const handleSubAccountClickedFuncText = text('handleSubAccountClicked','() => {alert("handleSubAccountClicked invoked")}');

return (
<div className="account-component">
<B2bAccountList
getAccountData={()=>{textToFunc(getAccountDataFuncText)}}
getSubAccountData={()=>{textToFunc(getSubAccountDataFuncText)}}
handleAddSubAccountClicked={()=>{textToFunc(handleSubAccountClickedFuncText)}}
getAccountData={() => { textToFunc(getAccountDataFuncText); }}
getSubAccountData={() => { textToFunc(getSubAccountDataFuncText); }}
handleAddSubAccountClicked={() => { textToFunc(handleSubAccountClickedFuncText); }}
accountListData={object('accountListData', accountListData)}
accountName={text('accountName', accountName)}
registrationNumber={text('registrationNumber', registrationNumber)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ import React from 'react';
import Readme from './README.md';
import { storiesOf } from '@storybook/react';
import { MemoryRouter } from 'react-router';
import { text, object } from '@storybook/addon-knobs/react';
import { textToFunc } from '../../../../storybook/utils/storybookUtils';

import SubAccountData from '../B2bAccountList/HttpResponse/accountData_response.json';
import B2bSubAccountList from './b2b.subaccountlist';
import { mockFetchSubAccount } from '../B2bAccountList/b2b.accountlist.api.mocks';
import { text, object } from "@storybook/addon-knobs/react";
import { textToFunc } from "../../../../storybook/utils/storybookUtils"
import mockFetchSubAccount from '../B2bAccountList/b2b.accountlist.api.mocks';

const accountName = 'Accelsmart';
const registrationNumber = 'cust-00059';

Expand All @@ -44,11 +45,11 @@ storiesOf('Components|B2bSubAccountList', module)
))
.add('B2bSubAccountList', () => {
mockFetchSubAccount();
let getAccountDataFuncText = text('getAccountData','() => {alert("getAccountData invoked")}');
const getAccountDataFuncText = text('getAccountData','() => {alert("getAccountData invoked")}');

return (
<B2bSubAccountList
getAccountData={()=>{textToFunc(getAccountDataFuncText)}}
getAccountData={() => { textToFunc(getAccountDataFuncText); }}
subAccounts={object('subAccountData', SubAccountData)}
accountName={text(accountName)}
registrationNumber={text(registrationNumber)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,17 @@
*/
import fetchMock from 'fetch-mock/es5/client';
import multiCartResponse from '../CommonMockHttpResponses/itemLookupMultiCart_response.json';
import loginResponse from '../CommonMockHttpResponses/login_response.json';
import { mockAnonLoginResponse } from '../utils/MockLogins';

function mockMultiCartResponse(mockObj) {
mockObj.get(
'/cortex/?zoom=carts,carts:createcartform,carts:element,carts:element:additemstocartform,carts:element:descriptor,carts:element:total',
/(.*)?zoom=carts,carts:createcartform,carts:element,carts:element:additemstocartform,carts:element:descriptor,carts:element:total/,
multiCartResponse,
);
}

function mockLoginResponse(mockObj) {
mockObj.post(
'/cortex/oauth2/tokens',
loginResponse,
);
}

export function mockFetchMultiCart() {
export default function mockFetchMultiCart() {
fetchMock.restore();
mockLoginResponse(fetchMock);
mockAnonLoginResponse(fetchMock);
mockMultiCartResponse(fetchMock);
}
Loading

0 comments on commit b1b573a

Please sign in to comment.