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

[DRAFT]: useUiNotification #5369

Closed
wants to merge 105 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
51a088e
Merge pull request #4947 from DivanteLtd/next
filrak Oct 2, 2020
06167fa
Merge pull request #5010 from DivanteLtd/next
filrak Oct 13, 2020
73f923d
update docs
filrak Oct 29, 2020
ee5ef24
Merge branch 'docs-next' of https://github.com/DivanteLtd/vue-storefr…
filrak Oct 29, 2020
a2f6cb6
Merge branch 'release/next' of https://github.com/DivanteLtd/vue-stor…
filrak Oct 30, 2020
03b7306
Merge remote-tracking branch 'vsf/next' into release/next
filrak Oct 30, 2020
0973791
docs update
filrak Nov 7, 2020
f834230
Merge branch 'release/next' into docs-next
filrak Nov 7, 2020
fb0b74e
reorder
filrak Nov 7, 2020
36c3688
update docs
filrak Nov 7, 2020
062f0ff
correct api design philosophy
filrak Nov 9, 2020
ff4b552
update api design philosophy
filrak Nov 9, 2020
957b343
Merge pull request #5236 from DivanteLtd/next
filrak Nov 21, 2020
4eaad6c
Merge pull request #5262 from DivanteLtd/next
filrak Nov 28, 2020
806e41c
UPDATE REVIEWS
filrak Nov 28, 2020
5edebee
Merge pull request #9 from DivanteLtd/next
lukaszjedrasik Dec 3, 2020
f9faf39
Merge pull request #11 from DivanteLtd/next
lukaszjedrasik Dec 3, 2020
e17312e
Merge pull request #12 from DivanteLtd/next
lukaszjedrasik Dec 5, 2020
c0ee890
Merge pull request #13 from DivanteLtd/next
lukaszjedrasik Dec 7, 2020
d0ddadb
feat: homepage
justyna-13 Dec 9, 2020
d58acc7
Merge branch 'next' into designs-part2-home
justyna-13 Dec 9, 2020
11d3624
Merge pull request #14 from DivanteLtd/next
lukaszjedrasik Dec 9, 2020
014c92a
fix: cr fixes
justyna-13 Dec 11, 2020
af7f51e
Merge pull request #15 from DivanteLtd/next
lukaszjedrasik Dec 12, 2020
e39d173
add mega menu
lukaszjedrasik Dec 3, 2020
04b0d51
mock for boilerplate and test case for onlyParents
lukaszjedrasik Dec 3, 2020
00e2ff7
Missing v-if
lukaszjedrasik Dec 4, 2020
05e365e
change png to webp
lukaszjedrasik Dec 5, 2020
5af54d0
fixes from cr
lukaszjedrasik Dec 5, 2020
54fc158
customQuery for Ct
lukaszjedrasik Dec 5, 2020
4388a55
remove unused import
lukaszjedrasik Dec 5, 2020
e1dcc1a
fixes from cr
lukaszjedrasik Dec 12, 2020
ebc667d
Added lodash.debounce
lukaszjedrasik Dec 12, 2020
9fb757b
fixes from cr
lukaszjedrasik Dec 12, 2020
9d9e4a1
Merge remote-tracking branch 'origin/next' into docs-next
andrzejewsky Dec 14, 2020
9e1b6ab
docs for netlify
andrzejewsky Dec 14, 2020
a379d28
docs for netlify
andrzejewsky Dec 14, 2020
fb12342
docs for netlify
andrzejewsky Dec 14, 2020
2dba420
docs for netlify
andrzejewsky Dec 14, 2020
fe31588
fix: cr
lukaszjedrasik Dec 19, 2020
19015b6
fix: hovered naming
lukaszjedrasik Dec 21, 2020
6ccff6b
chore: resolved conflict
lukaszjedrasik Dec 27, 2020
edb4cf5
Merge branch 'next' into mega-menu-in-app-header
lukaszjedrasik Dec 27, 2020
cf9f8b7
chore: search update
lukaszjedrasik Dec 27, 2020
e9dad20
chore: fixes from CR
lukaszjedrasik Dec 27, 2020
4f0401e
theme docs and minor polishments
filrak Dec 30, 2020
7ef8b9a
Update packages/core/docs/README.md
filrak Jan 4, 2021
be1fb4f
Update packages/core/docs/README.md
filrak Jan 4, 2021
40a5a14
Update packages/core/docs/guide/internationalization.md
filrak Jan 4, 2021
7704ba6
Update packages/core/docs/guide/internationalization.md
filrak Jan 4, 2021
5abf392
Update packages/core/docs/guide/theme.md
filrak Jan 4, 2021
5c3cc22
Update packages/core/docs/guide/internationalization.md
filrak Jan 4, 2021
a81abb8
Update packages/core/docs/README.md
filrak Jan 4, 2021
ebb083d
Update packages/core/docs/general/key-concepts.md
filrak Jan 4, 2021
f347c97
Update packages/core/docs/README.md
filrak Jan 4, 2021
4de0e14
i18n
filrak Jan 4, 2021
99b28dd
Merge branch 'docs-updates' of https://github.com/DivanteLtd/vue-stor…
filrak Jan 4, 2021
0cccfa8
fix: conflict resolved
justyna-13 Jan 4, 2021
fcbac55
wip: useUiNotification
lukaszjedrasik Jan 5, 2021
f9e413b
chore: changelog updated
lukaszjedrasik Jan 5, 2021
f116968
Merge pull request #5307 from justyna-13/designs-part2-home
filrak Jan 5, 2021
f947ada
Merge pull request #5283 from lukaszjedrasik/mega-menu-in-app-header
filrak Jan 5, 2021
d4c0c3a
Revert "Next: Mega menu in app header"
andrzejewsky Jan 5, 2021
bde1e74
Merge pull request #5371 from vuestorefront/revert-5283-mega-menu-in-…
filrak Jan 5, 2021
d40696f
fix adding to cart
andrzejewsky Jan 6, 2021
b34669c
fix adding to cart
andrzejewsky Jan 6, 2021
574e37e
Merge pull request #5375 from vuestorefront/fix-adding-to-cart
filrak Jan 7, 2021
3a704d5
cr updates
filrak Jan 7, 2021
b7cf712
Merge pull request #5360 from vuestorefront/docs-updates
filrak Jan 7, 2021
aa9ce64
chore: api update
lukaszjedrasik Jan 7, 2021
d5839dd
chore: api update
lukaszjedrasik Jan 7, 2021
b335f66
chore: api update
lukaszjedrasik Jan 7, 2021
0e65521
chore: new error handling in the cart factory
Dec 22, 2020
c03b4a6
refactor: using finally block
Dec 22, 2020
b03a123
refactor: composable errors type
Dec 22, 2020
d5fdc89
fix: cart clear error inside special condition
Dec 22, 2020
12fe1d0
chore: useCategoryFactory error handling
Dec 22, 2020
665bf24
chore: useContentFactory error handling
Dec 22, 2020
17617a9
chore: use Facet, Product & Review Factory error handling
Dec 22, 2020
73d193c
chore: use Shipping & Billing Factory error handling
Dec 22, 2020
6b4726c
chore: use User Factory error handling
Dec 22, 2020
dd62970
chore: use Wishlist & User Orders Factory error handling
Dec 22, 2020
64e04fe
fix: unit tests for core factories with new error handling
Dec 22, 2020
a69a854
refactor: more cart tests
Dec 23, 2020
f469805
refactor: tests for new errors handling
Dec 23, 2020
bcea726
refactor: got rid of useless expect
Dec 23, 2020
a00bc49
refactor: wishlist tests for new changes
Dec 23, 2020
4b025e4
chore: typed error refs for cart, category and content
Dec 28, 2020
7fb2d17
chore: typed erro refs for rest of core factories
Dec 28, 2020
1b646ca
fix: wishlist unit test
Dec 28, 2020
ccc11c8
chore: changelog
Dec 28, 2020
c6bdf9c
chore: working on docs
Dec 29, 2020
bcfb459
refactor: doc update
Dec 30, 2020
0805dac
refactor: got rid of `Composable` parts from error types
Jan 7, 2021
c74e047
refactor: doc update
Jan 7, 2021
b012400
Update packages/core/docs/general/error-handling.md
filrak Jan 7, 2021
a287cee
Merge pull request #5346 from vuestorefront/error-handling
filrak Jan 7, 2021
d8bd197
Merge remote-tracking branch 'vsf/next' into docs-next
filrak Jan 7, 2021
34aef79
minor polishments
filrak Jan 7, 2021
a7fd035
Merge pull request #5381 from vuestorefront/docs-next
filrak Jan 7, 2021
8cb46e4
wip: useUiNotification
lukaszjedrasik Jan 5, 2021
39552cd
chore: api update
lukaszjedrasik Jan 7, 2021
5185a46
chore: api update
lukaszjedrasik Jan 7, 2021
1873560
chore: api update
lukaszjedrasik Jan 7, 2021
5cf3628
Merge remote-tracking branch 'origin/use-ui-notification' into use-ui…
lukaszjedrasik Jan 7, 2021
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
Binary file modified packages/boilerplate/theme/static/homepage/google.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 0 additions & 2 deletions packages/commercetools/theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
},
"dependencies": {
"@nuxtjs/pwa": "^3.2.2",
"@nuxtjs/style-resources": "^1.0.0",
"@storefront-ui/vue": "0.9.2",
"@vue-storefront/commercetools": "^1.0.1-rc.1",
"@vue-storefront/nuxt": "^2.1.1-rc.1",
Expand All @@ -30,7 +29,6 @@
},
"devDependencies": {
"@nuxt/types": "^0.7.9",
"@nuxt/typescript-build": "^2.0.0",
"@vue/test-utils": "^1.0.0-beta.27",
"babel-jest": "^24.1.0",
"jest": "^24.1.0",
Expand Down
Binary file modified packages/commercetools/theme/static/homepage/google.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
98 changes: 98 additions & 0 deletions packages/core/core/__tests__/factories/useCartFactory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ function createComposable() {
useCart = useCartFactory<any, any, any, any>(params);
}

const factoryParams = {
addItem: jest.fn(() => null),
removeItem: jest.fn(),
updateItemQty: jest.fn(),
load: jest.fn(),
clear: jest.fn(),
applyCoupon: jest.fn(),
removeCoupon: jest.fn(),
isOnCart: jest.fn()
};

const useCartMock = useCartFactory(factoryParams);

describe('[CORE - factories] useCartFactory', () => {
beforeEach(() => {
jest.clearAllMocks();
Expand Down Expand Up @@ -80,6 +93,18 @@ describe('[CORE - factories] useCartFactory', () => {
expect(params.load).toHaveBeenCalled();
expect(cart.value).toEqual({ id: 'mocked_cart' });
});

it('should set error if factory method throwed', async () => {
const err = new Error('zxczxcx');
factoryParams.load.mockImplementationOnce(() => {
throw err;
});
const { load, error } = useCartMock();

await load();

expect(error.value.load).toBe(err);
});
});

describe('addItem', () => {
Expand All @@ -93,6 +118,18 @@ describe('[CORE - factories] useCartFactory', () => {
});
expect(cart.value).toEqual({ id: 'mocked_added_cart' });
});

it('should set error if factory method throwed', async () => {
const err = new Error('zxczxcx');
factoryParams.addItem.mockImplementationOnce(() => {
throw err;
});
const { addItem, error } = useCartMock();

await addItem({ product: { id: 'productId' }, quantity: 1 });

expect(error.value.addItem).toBe(err);
});
});

describe('removeItem', () => {
Expand All @@ -105,6 +142,18 @@ describe('[CORE - factories] useCartFactory', () => {
});
expect(cart.value).toEqual({ id: 'mocked_removed_cart' });
});

it('should set error if factory method throwed', async () => {
const err = new Error('zxczxcx');
factoryParams.removeItem.mockImplementationOnce(() => {
throw err;
});
const { removeItem, error } = useCartMock();

await removeItem({ product: { id: 'productId' } });

expect(error.value.removeItem).toBe(err);
});
});

describe('updateItemQty', () => {
Expand All @@ -130,6 +179,18 @@ describe('[CORE - factories] useCartFactory', () => {
});
expect(cart.value).toEqual({ id: 'mocked_updated_quantity_cart' });
});

it('should set error if factory method throwed', async () => {
const err = new Error('zxczxcx');
factoryParams.updateItemQty.mockImplementationOnce(() => {
throw err;
});
const { updateItemQty, error } = useCartMock();

await updateItemQty({ product: { id: 'productId' }, quantity: 1 });

expect(error.value.updateItemQty).toBe(err);
});
});

describe('clear', () => {
Expand All @@ -139,6 +200,18 @@ describe('[CORE - factories] useCartFactory', () => {
expect(params.clear).toHaveBeenCalledWith({ context: null }, { currentCart: null });
expect(cart.value).toEqual({ id: 'mocked_cleared_cart' });
});

it('should set error if factory method throwed', async () => {
const err = new Error('zxczxcx');
factoryParams.clear.mockImplementationOnce(() => {
throw err;
});
const { clear, error } = useCartMock();

await clear();

expect(error.value.clear).toBe(err);
});
});

describe('applyCoupon', () => {
Expand All @@ -151,6 +224,18 @@ describe('[CORE - factories] useCartFactory', () => {
});
expect(cart.value).toEqual({ id: 'mocked_apply_coupon_cart' });
});

it('should set error if factory method throwed', async () => {
const err = new Error('zxczxcx');
factoryParams.applyCoupon.mockImplementationOnce(() => {
throw err;
});
const { applyCoupon, error } = useCartMock();

await applyCoupon({ couponCode: 'qwerty' });

expect(error.value.applyCoupon).toBe(err);
});
});

describe('removeCoupon', () => {
Expand All @@ -165,6 +250,19 @@ describe('[CORE - factories] useCartFactory', () => {
expect(cart.value).toEqual({ id: 'mocked_removed_coupon_cart' });
});

it('should set error if factory method throwed', async () => {
const err = new Error('zxczxcx');
factoryParams.removeCoupon.mockImplementationOnce(() => {
throw err;
});
const { removeCoupon, error } = useCartMock();
const coupon = 'some-coupon-code-12321231';

await removeCoupon({ coupon });

expect(error.value.removeCoupon).toBe(err);
});

// TODO
// it('should not invoke removeCoupon method if coupon is not applied', async () => {
// });
Expand Down
18 changes: 18 additions & 0 deletions packages/core/core/__tests__/factories/useCategoryFactory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ import { UseCategory } from '../../src/types';
let useCategory: (cacheId?: string) => UseCategory<any, any>;
let params: UseCategoryFactoryParams<any, any>;

const factoryParams = {
categorySearch: jest.fn()
};

const useCategoryMock = useCategoryFactory(factoryParams);

function createComposable() {
params = {
categorySearch: jest
Expand Down Expand Up @@ -37,6 +43,18 @@ describe('[CORE - factories] useCategoryFactory', () => {
expect(params.categorySearch).toBeCalledWith({ context: null }, { someparam: 'qwerty' });
expect(categories.value).toEqual({ id: 'mocked_removed_cart' });
});

it('should set error if factory method throwed', async () => {
const err = new Error('zxczxcx');
factoryParams.categorySearch.mockImplementationOnce(() => {
throw err;
});
const { search, error } = useCategoryMock('a');

await search({ someparam: 'qwerty' });

expect(error.value.search).toBe(err);
});
});
});
});
20 changes: 19 additions & 1 deletion packages/core/core/__tests__/factories/useContentFactory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ describe('[CORE - factories] useContentFactory', () => {
useContent = useContentFactory<any, any>(params);
};

const factoryParams = {
search: jest.fn()
};

const useContentMock = useContentFactory(factoryParams);

beforeEach(() => {
jest.clearAllMocks();
createContentFactoryMock();
Expand All @@ -27,7 +33,7 @@ describe('[CORE - factories] useContentFactory', () => {

expect(content.value).toEqual([]);
expect(loading.value).toEqual(false);
expect(error.value).toEqual(null);
expect(error.value).toEqual({});
});

it('invokes content search', async () => {
Expand All @@ -38,6 +44,18 @@ describe('[CORE - factories] useContentFactory', () => {
expect(params.search).toBeCalledWith({ context: null }, searchParams);
expect(params.search).toBeCalledTimes(1);
});

it('should set error if factory method throwed', async () => {
const err = new Error('zxczxcx');
factoryParams.search.mockImplementationOnce(() => {
throw err;
});
const { search, error } = useContentMock('a');

await search({ someparam: 'qwerty' });

expect(error.value.search).toBe(err);
});
});

describe('[CORE - factories] renderContentFactory', () => {
Expand Down
18 changes: 18 additions & 0 deletions packages/core/core/__tests__/factories/useFacetFactory.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { useFacetFactory } from '../../src/factories';

const factoryParams = {
search: jest.fn()
};

const useFacetMock = useFacetFactory(factoryParams);

describe('[CORE - factories] useFacetFactory', () => {
it('creates properties', () => {
const factorySearch = () => jest.fn();
Expand All @@ -21,4 +27,16 @@ describe('[CORE - factories] useFacetFactory', () => {
expect(result.value).toEqual({ data: null, input: { param: 'test' } });
expect(loading.value).toEqual(true);
});

it('should set error if factory method throwed', async () => {
const err = new Error('zxczxcx');
factoryParams.search.mockImplementationOnce(() => {
throw err;
});
const { search, error } = useFacetMock('a');

await search({ someparam: 'qwerty' });

expect(error.value.search).toBe(err);
});
});
18 changes: 18 additions & 0 deletions packages/core/core/__tests__/factories/useProductFactory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ const useProduct: (cacheId: string) => UseProduct<any, any> = useProductFactory<
productsSearch: (context, searchParams) => Promise.resolve([{ name: 'product ' + searchParams.slug }])
});

const factoryParams = {
productsSearch: jest.fn()
};

const useProductMock = useProductFactory<any, any>(factoryParams);

describe('[CORE - factories] useProductFactory', () => {
it('creates properties', () => {
const { products, loading } = useProduct('test-product');
Expand All @@ -28,4 +34,16 @@ describe('[CORE - factories] useProductFactory', () => {

expect(products.value).toEqual([{name: 'product product-slug' }]);
});

it('should set error if factory method throwed', async () => {
const err = new Error('zxczxcx');
factoryParams.productsSearch.mockImplementationOnce(() => {
throw err;
});
const { search, error } = useProductMock('a');

await search({ someparam: 'qwerty' });

expect(error.value.search).toBe(err);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe('[CORE - factories] useReviews', () => {

expect(reviews.value).toEqual([]);
expect(loading.value).toEqual(false);
expect(error.value).toEqual(null);
expect(error.value).toEqual({});
});

it('returns reviews response', async () => {
Expand All @@ -89,7 +89,7 @@ describe('[CORE - factories] useReviews', () => {
await search({});

expect(reviews.value).toEqual(searchReviewResponse);
expect(error.value).toEqual(null);
expect(error.value).toEqual({ search: null });
});

it('can submit new review', async () => {
Expand All @@ -111,7 +111,7 @@ describe('[CORE - factories] useReviews', () => {

expect(reviews.value).toEqual([]);
expect(loading.value).toEqual(false);
expect(error.value).toEqual('Error: Couldn\'t retrieve reviews');
expect(error.value.search.toString()).toEqual('Error: Couldn\'t retrieve reviews');
});

it('returns error when submit fails', async () => {
Expand All @@ -121,6 +121,6 @@ describe('[CORE - factories] useReviews', () => {

expect(reviews.value).toEqual([]);
expect(loading.value).toEqual(false);
expect(error.value).toEqual('Error: Couldn\'t submit review');
expect(error.value.addReview.toString()).toEqual('Error: Couldn\'t submit review');
});
});
Loading