Skip to content

Commit

Permalink
Merge branch 'develop' into tommy/virtual-browse-view
Browse files Browse the repository at this point in the history
  • Loading branch information
eug123 authored Mar 19, 2021
2 parents 1eac198 + 595c53d commit fece0ee
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Magento PWA Studio is a collection of tools that lets developers build complex P

## Useful links

[PWA Studio documentation site][documentation site] -
[PWA Studio documentation site][documentation site] -
The best place to start learning about the tools and the technologies that PWA Studio provides.
Here, you can learn PWA Studio concepts, find API reference docs, and read tutorials on how to use PWA Studio to create your own PWA storefront.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,23 @@ describe('handler', () => {
const mockArgs = {
project: 'myApp'
};
const mockContext = {
getProjectConfig: jest.fn(() => {
return Promise.resolve({
config: {
extensions: {
'validate-magento-pwa-queries': {
clients: ['apollo', 'literal'],
filesGlob: '*.graphql',
ignore: ['*.js']
}
},
schemaPath: 'unit test'
const getProjectConfig = jest.fn().mockResolvedValue({
config: {
extensions: {
'validate-magento-pwa-queries': {
clients: ['apollo', 'literal'],
filesGlob: '*.graphql',
ignore: ['*.js'],
magentoBackendEdition: 'CE',
ceFilesGlob: 'ceFilesGlob',
eeFilesGlob: 'eeFilesGlob'
}
});
}),
},
schemaPath: 'unit test'
}
});
const mockContext = {
getProjectConfig,
spinner: {
fail: jest.fn(),
start: jest.fn(),
Expand Down Expand Up @@ -227,4 +229,32 @@ describe('handler', () => {
expect(mockConsoleWarn).toHaveBeenCalled();
expect(mockProcessExit).toHaveBeenCalledWith(1);
});

test('it ignores EE files if magentoBackendEdition is CE', async () => {
await plugin.handler(mockContext, mockArgs);

expect(globSyncSpy.mock.calls[0][1].ignore).toContain('eeFilesGlob');
});

test('it ignores CE files if magentoBackendEdition is EE', async () => {
getProjectConfig.mockResolvedValueOnce({
config: {
extensions: {
'validate-magento-pwa-queries': {
clients: ['apollo', 'literal'],
filesGlob: '*.graphql',
ignore: ['*.js'],
magentoBackendEdition: 'EE',
ceFilesGlob: 'ceFilesGlob',
eeFilesGlob: 'eeFilesGlob'
}
},
schemaPath: 'unit test'
}
});

await plugin.handler(mockContext, mockArgs);

expect(globSyncSpy.mock.calls[0][1].ignore).toContain('ceFilesGlob');
});
});
15 changes: 14 additions & 1 deletion packages/graphql-cli-validate-magento-pwa-queries/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,20 @@ async function validateQueries(context, argv) {

// Get the clients and filesGlob arguments from the .graphqlconfig.
const configArgs = extensions[plugin.COMMAND];
const { clients, filesGlob, ignore } = configArgs;
const {
magentoBackendEdition,
clients,
filesGlob,
ceFilesGlob,
eeFilesGlob,
ignore
} = configArgs;

if (magentoBackendEdition === 'CE') {
ignore.push(eeFilesGlob);
} else {
ignore.push(ceFilesGlob);
}

/**
* List of files to run query validation on ignoring
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export const useGiftCards = props => {
* @property {GraphQLAST} applyCardMutation The mutation used to apply a gift card to the cart.
* @property {GraphQLAST} removeCardMutation The mutation used to remove a gift card from the cart.
*
* @see [`giftCardQueries.js`]{@link https://github.com/magento/pwa-studio/blob/develop/packages/venia-ui/lib/components/CartPage/GiftCards/giftCardQueries.js}
* @see [`giftCardQueries.ee.js`]{@link https://github.com/magento/pwa-studio/blob/develop/packages/venia-ui/lib/components/CartPage/GiftCards/giftCardQueries.js}
* for queries used in Venia
*/

Expand All @@ -192,7 +192,7 @@ export const useGiftCards = props => {
* @property {GraphQLAST} appliedCardsQuery The query used to get the gift cards currently applied to the cart.
* @property {GraphQLAST} cardBalanceQuery The query used to get the gift cards currently applied to the cart.
*
* @see [`giftCardQueries.js`]{@link https://github.com/magento/pwa-studio/blob/develop/packages/venia-ui/lib/components/CartPage/GiftCards/giftCardQueries.js}
* @see [`giftCardQueries.ee.js`]{@link https://github.com/magento/pwa-studio/blob/develop/packages/venia-ui/lib/components/CartPage/GiftCards/giftCardQueries.js}
* for queries used in Venia
*/

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { useGalleryItem } from '../useGalleryItem';
test('returns empty object', () => {
const props = useGalleryItem({});
expect(props).toEqual({});
});
3 changes: 3 additions & 0 deletions packages/peregrine/lib/talons/Gallery/useGalleryItem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const useGalleryItem = props => {
return { ...props };
};
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ test('exposes all hooks and targets', async () => {
talons.Footer.useFooter.wrapWith() wraps export "useFooter" from "Footer/useFooter.js"
talons.ForgotPassword.useForgotPassword.wrapWith() wraps export "useForgotPassword" from "ForgotPassword/useForgotPassword.js"
talons.FormError.useFormError.wrapWith() wraps export "useFormError" from "FormError/useFormError.js"
talons.Gallery.useGalleryItem.wrapWith() wraps export "useGalleryItem" from "Gallery/useGalleryItem.js"
talons.Header.useAccountMenu.wrapWith() wraps export "useAccountMenu" from "Header/useAccountMenu.js"
talons.Header.useAccountTrigger.wrapWith() wraps export "useAccountTrigger" from "Header/useAccountTrigger.js"
talons.Header.useCartTrigger.wrapWith() wraps export "useCartTrigger" from "Header/useCartTrigger.js"
Expand Down
3 changes: 3 additions & 0 deletions packages/venia-concept/.graphqlconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
"apollo",
"literal"
],
"magentoBackendEdition": "${env:MAGENTO_BACKEND_EDITION}",
"filesGlob": "../{peregrine,venia-ui,venia-concept}/{lib,src}/**/*.{js,graphql,gql}",
"ceFilesGlob": "../{peregrine,venia-ui,venia-concept}/{lib,src}/**/*.ce.js",
"eeFilesGlob": "../{peregrine,venia-ui,venia-concept}/{lib,src}/**/*.ee.js",
"ignore": [
"../venia-ui/lib/**/giftOptions.js",
"../venia-ui/lib/**/wishlistPage.gql.js",
Expand Down
15 changes: 12 additions & 3 deletions packages/venia-ui/lib/components/Gallery/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Link, resourceUrl } from '@magento/venia-drivers';
import Price from '@magento/venia-ui/lib/components/Price';
import { transparentPlaceholder } from '@magento/peregrine/lib/util/images';
import { UNCONSTRAINED_SIZE_KEY } from '@magento/peregrine/lib/talons/Image/useImage';
import { useGalleryItem } from '@magento/peregrine/lib/talons/Gallery/useGalleryItem';

import { mergeClasses } from '../../classify';
import Image from '../Image';
Expand Down Expand Up @@ -37,7 +38,7 @@ const ItemPlaceholder = ({ classes }) => (
);

const GalleryItem = props => {
const { item } = props;
const { handleLinkClick, item } = useGalleryItem(props);

const classes = mergeClasses(defaultClasses, props.classes);

Expand All @@ -50,7 +51,11 @@ const GalleryItem = props => {

return (
<div className={classes.root}>
<Link to={productLink} className={classes.images}>
<Link
onClick={handleLinkClick}
to={productLink}
className={classes.images}
>
<Image
alt={name}
classes={{
Expand All @@ -62,7 +67,11 @@ const GalleryItem = props => {
widths={IMAGE_WIDTHS}
/>
</Link>
<Link to={productLink} className={classes.name}>
<Link
onClick={handleLinkClick}
to={productLink}
className={classes.name}
>
<span>{name}</span>
</Link>
<div className={classes.price}>
Expand Down

0 comments on commit fece0ee

Please sign in to comment.