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

Shipping Rates Pre-Fetch #385

Merged
merged 100 commits into from
Mar 30, 2019
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
9a8ce26
start on shipping manager refactor
walmat Mar 11, 2019
7eee340
added action/reducers
walmat Mar 11, 2019
a0867f6
more state changes + UI updates
walmat Mar 12, 2019
d525c9e
progress on shipping rates
walmat Mar 13, 2019
6d2515d
state progress
walmat Mar 13, 2019
1d235aa
small state changes
walmat Mar 14, 2019
3637b22
small changes to settings actions
walmat Mar 14, 2019
2e30975
small changes
walmat Mar 14, 2019
4b0feb3
pr changes
walmat Mar 14, 2019
f6883a3
pr changes
walmat Mar 14, 2019
5202249
Update packages/frontend/src/state/reducers/profiles/profileReducer.js
walmat Mar 14, 2019
683857e
Update packages/frontend/src/state/reducers/profiles/profileReducer.js
walmat Mar 14, 2019
82fc926
rm unnecessary error state declaration
walmat Mar 14, 2019
810f256
filter names and rate input autofilled based on selection done
walmat Mar 14, 2019
c04f6b6
small fixes
walmat Mar 15, 2019
6cae615
Update packages/frontend/src/profiles/shippingRates.jsx
pr1sm Mar 15, 2019
02f4125
Update packages/frontend/src/profiles/shippingRates.jsx
pr1sm Mar 15, 2019
d47bb30
pr changes
walmat Mar 15, 2019
cd8f532
some layout changes + delete/clear buttons
walmat Mar 15, 2019
7c712ce
added delete rate action, needs work still
walmat Mar 15, 2019
544a4fa
fixed delete rate action/reducer
walmat Mar 15, 2019
728a6be
rm unnecessary id field
walmat Mar 15, 2019
4c42180
attach settings middleware for other fields
walmat Mar 16, 2019
4e78d1e
added webhook regex and errors map
walmat Mar 16, 2019
9807332
fixed product validator error mapping
walmat Mar 16, 2019
e530903
Store the selected shipping rate
pr1sm Mar 16, 2019
a830d89
Refactor Run Loop to a single function
pr1sm Mar 16, 2019
aebfaf1
Add Shipping Rates Runner
pr1sm Mar 16, 2019
b056139
Fix lint
pr1sm Mar 16, 2019
6132b1e
small css tweaks with cursor:pointer
walmat Mar 16, 2019
b7ae208
Generalize Runner Type Tag
pr1sm Mar 16, 2019
aae2051
progress on settings middleware
walmat Mar 16, 2019
5a9d59b
separated middleware, added more action chains for fetching shipping …
walmat Mar 16, 2019
ee16712
fixed rates proptypes
walmat Mar 16, 2019
21f1486
small naming fix
walmat Mar 16, 2019
dc776cd
Update Naming
pr1sm Mar 18, 2019
4b22d60
Add Support for Starting the ShippingRatesRunner
pr1sm Mar 18, 2019
a92cf7c
Move Runners to a Separate Folder
pr1sm Mar 18, 2019
37a66a1
Export Task Runner Types
pr1sm Mar 18, 2019
9a7e062
Fix Run Loop Bug
pr1sm Mar 18, 2019
0410ffc
Update Task Status when emitting message
pr1sm Mar 18, 2019
e1ac79a
Switch to use end runner states instead of generic Stopped
pr1sm Mar 18, 2019
9d25553
Fixes to existing test failures
walmat Mar 18, 2019
094c493
test progress, broke some others in the progress...
walmat Mar 19, 2019
eb179da
settings actions tests
walmat Mar 19, 2019
64b323d
added shipping manager component tests
walmat Mar 19, 2019
2f674ff
pulled in srr changes
walmat Mar 20, 2019
4b1f933
rm unnecessary comments
walmat Mar 20, 2019
ebd5d25
some test fixes
walmat Mar 20, 2019
cb3165d
split out shipping reducer
walmat Mar 20, 2019
473a09e
small change
walmat Mar 20, 2019
f0c109a
revert init state for rates
walmat Mar 20, 2019
0e181c6
added migration pattern
walmat Mar 20, 2019
5609413
added random size default in preload
walmat Mar 20, 2019
6b1b811
revert type parameter
walmat Mar 21, 2019
a8a168b
fixed a lot of tests..
walmat Mar 22, 2019
aa630d3
test fixes, code coverage increase
walmat Mar 22, 2019
6c05859
fix lint, fix scss
walmat Mar 22, 2019
a9df1d4
fix lint
walmat Mar 22, 2019
f444f64
task list reducer test coverage increase
walmat Mar 22, 2019
5a8e19a
shipping rates component tests
walmat Mar 22, 2019
6f3fb44
test coverage improvements
walmat Mar 23, 2019
7ce6365
increase test coverage
walmat Mar 24, 2019
64340ca
more code coverage increased
walmat Mar 24, 2019
7056a15
bug fixes with srr
Mar 25, 2019
8b54f39
rm unused file
Mar 25, 2019
b1cb12c
test fix
Mar 25, 2019
955a801
added profile reducer
Mar 26, 2019
299f100
fixed test
Mar 26, 2019
5ecdb92
small code coverage increased
Mar 26, 2019
1e62547
small bug fix with copy task
Mar 26, 2019
93378b4
pr changes, test updates
Mar 27, 2019
caff397
Update packages/frontend/src/state/migrators/v0.2.0/index.js
pr1sm Mar 27, 2019
be93e3a
lint fix
Mar 27, 2019
648429c
filtered out shipping rate runner status messages
Mar 27, 2019
2eb9e93
task event registration handler split into multiple handlers
Mar 28, 2019
0b10c29
added selectedProfile and currentProfile reducer fixes, and implement…
Mar 28, 2019
5d97935
test fix progress
Mar 28, 2019
a20a7fe
lint fix
Mar 28, 2019
2adeb49
fix deregister function
Mar 28, 2019
b86bd96
migration changes
Mar 28, 2019
a349810
prevented srr from handling restocks
Mar 28, 2019
20073a7
Add Setup and Cleanup actions for Shipping Rates
pr1sm Mar 28, 2019
fc03def
Add Shipping Status Flag
pr1sm Mar 28, 2019
eaf2bb5
Update Settings Reducer to handle actions
pr1sm Mar 28, 2019
2202cc2
Disable Fetch Shipping Rates Button when in progress
pr1sm Mar 28, 2019
9ee42ab
styling updates, code coverage, and render bug fixes
Mar 28, 2019
1e36a0e
bug fix w/ srr skipping fetching rates step
Mar 29, 2019
c1b4ce9
added price field in
Mar 29, 2019
e570250
srr caching rates bug fixed
Mar 29, 2019
9890375
rm debug statements
Mar 29, 2019
ab42306
fixed shipping site username/password resetting bug
Mar 29, 2019
4c635fa
fixed invalid proptype error
Mar 29, 2019
9c00781
fixed graceful shutdown of srr
Mar 29, 2019
3f989b0
added some more code coverage
Mar 29, 2019
48c3b36
on stop srr
Mar 29, 2019
3a24aad
Implement Cancel feature for SRR
pr1sm Mar 29, 2019
858daba
Update Stop Shipping to Cleanup Shipping State
pr1sm Mar 29, 2019
e090ac4
Address PR Comment
pr1sm Mar 29, 2019
6c5d5b9
code coverage increased
Mar 29, 2019
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
9 changes: 8 additions & 1 deletion packages/frontend/lib/common/bridge/mainPreload.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ const _deregisterForTaskEvents = handler => {
ipcRenderer.once(IPCKeys.RequestDeregisterTaskEventHandler, (event, eventKey) => {
// Check and make sure we have a key to deregister from
if (eventKey) {
util.removeEvent(eventKey, taskEventHandler);
handlers = [];
util.removeEvent(event, taskEventHandler);
} else {
console.error('Unable to Deregister from Task Events!');
}
Expand All @@ -68,6 +68,13 @@ const _deregisterForTaskEvents = handler => {
handlers = handlers.filter(h => h !== handler);
};

/**
* Removes all listeners if the window was closed
*/
window.onbeforeunload = () => {
handlers.forEach(h => _deregisterForTaskEvents(h));
};

/**
* Sends task(s) that should be started to launcher.js
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ describe('<ShippingRates />', () => {
},
],
selectedRate: {
label: '5-7 Business Days',
value: 'shopify-UPS%20GROUND%20(5-7%20business%20days)-10.00',
name: '5-7 Business Days',
rate: 'shopify-UPS%20GROUND%20(5-7%20business%20days)-10.00',
},
},
],
Expand Down Expand Up @@ -311,8 +311,8 @@ describe('<ShippingRates />', () => {
value: 'https://kith.com',
},
rate: {
label: '5-7 Business Days',
value: 'shopify-UPS%20GROUND%20(5-7%20business%20days)-10.00',
name: '5-7 Business Days',
rate: 'shopify-UPS%20GROUND%20(5-7%20business%20days)-10.00',
},
},
},
Expand Down
43 changes: 39 additions & 4 deletions packages/frontend/src/__tests__/settings/shippingManager.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ describe('<ShippingManager />', () => {
};
const wrapper = renderShallowWithProps(customProps);
const siteSelector = wrapper.find('.settings--shipping-manager__input-group--site');
expect(siteSelector.prop('value')).toBeNull();
expect(siteSelector.prop('value')).toEqual({ label: null, value: null });
expect(siteSelector.prop('onChange')).toBeDefined();
expect(siteSelector.prop('options')).toEqual(getAllSupportedSitesSorted());

Expand Down Expand Up @@ -285,12 +285,47 @@ describe('<ShippingManager />', () => {

test('map dispatch to props should return correct structure', () => {
const dispatch = jest.fn();
const expectedAction = settingsActions.edit(SETTINGS_FIELDS.EDIT_SHIPPING_PRODUCT, '+data');
const task = {
...initialSettingsStates.shipping,
product: {
...initialSettingsStates.shipping.product,
raw: '+test',
pos_keywords: ['test'],
},
site: {
...initialSettingsStates.shipping.site,
name: 'Nebula Bots',
url: 'https://nebulabots.com',
apiKey: '6526a5b5393b6316a64853cfe091841c',
localCheckout: false,
special: false,
auth: false,
},
profile: {
...initialSettingsStates.shipping.profile,
id: 1,
profileName: 'test',
},
};

const expectedActions = [
settingsActions.edit(SETTINGS_FIELDS.EDIT_SHIPPING_PRODUCT, '+test'),
settingsActions.fetch(task),
settingsActions.clearShipping(SETTINGS_FIELDS.CLEAR_SHIPPING_FIELDS),
];

const actual = mapDispatchToProps(dispatch);
actual.onSettingsChange({
field: SETTINGS_FIELDS.EDIT_SHIPPING_PRODUCT,
value: '+data',
value: '+test',
});
actual.onFetchShippingMethods(task);
actual.onClearShippingFields(SETTINGS_FIELDS.CLEAR_SHIPPING_FIELDS);
expectedActions.forEach((action, n) => {
expect(dispatch).toHaveBeenNthCalledWith(
n + 1,
typeof action !== 'function' ? action : expect.any(Function),
);
});
expect(dispatch).toHaveBeenCalledWith(expectedAction);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ describe('task actions', () => {
});

describe('should handle copy task action', () => {
test('with valid task', async () => {
test('with valid task data', async () => {
const task = {
...initialTaskState,
product: {
Expand Down Expand Up @@ -292,7 +292,7 @@ describe('task actions', () => {
await asyncTaskTests(action, expectedActions);
});

test('with invalid task', async () => {
test('with no task', async () => {
const action = taskActions.copy(undefined);
const expectedActions = [
{
Expand Down
Loading