-
Notifications
You must be signed in to change notification settings - Fork 683
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
Generate optimized Image URLs using configuration from GraphQL #1267
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
24ac85c
- Generate optimized URLs using new GraphQL query result
tjwiebell daa853c
Remove obsolete media path variables
tjwiebell 8bbf106
Merge branch 'develop' into feature/graphql-media-urls
supernova-at 6b2c410
Merge branch 'develop' into feature/graphql-media-urls
supernova-at a21e8da
Address feedback
tjwiebell 1d2bde8
Merge branch 'develop' into feature/graphql-media-urls
supernova-at 60012fa
Merge branch 'develop' into feature/graphql-media-urls
dpatil-magento 1642d47
Merge branch 'develop' into feature/graphql-media-urls
dpatil-magento File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,18 +30,12 @@ test('prepends media path for product images', () => { | |
expect(makeUrl(relativePath, { type: 'image-product' })).toBe( | ||
`${productBase}${relativePath}?${defaultParams}` | ||
); | ||
expect(makeUrl(absoluteUrls[2], { type: 'image-product' })).toBe( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test changes all related to removed functionality. See https://github.com/magento-research/pwa-studio/pull/1267/files#r287155267 |
||
'https://example.com/media/catalog/product/baz.png?auto=webp&format=pjpg' | ||
); | ||
}); | ||
|
||
test('prepends media path for relative category images', () => { | ||
expect(makeUrl(relativePath, { type: 'image-category' })).toBe( | ||
`${categoryBase}${relativePath}?${defaultParams}` | ||
); | ||
expect(makeUrl(absoluteUrls[2], { type: 'image-category' })).toBe( | ||
'https://example.com/media/catalog/category/baz.png?auto=webp&format=pjpg' | ||
); | ||
}); | ||
|
||
test("doesn't prepend media path if it's already included", () => { | ||
|
@@ -52,12 +46,12 @@ test("doesn't prepend media path if it's already included", () => { | |
).toBeTruthy(); | ||
}); | ||
|
||
test('rewrites absolute url when width is provided', () => { | ||
test('appends opt params to absolute url when width is provided', () => { | ||
const width = 100; | ||
const raw = absoluteUrls[2]; | ||
|
||
expect(makeUrl(raw, { type: 'image-product', width })).toBe( | ||
`https://example.com${productBase}/baz.png?auto=webp&format=pjpg&width=100` | ||
`https://example.com/baz.png?auto=webp&format=pjpg&width=100` | ||
); | ||
}); | ||
|
||
|
@@ -73,7 +67,7 @@ test('removes absolute origin if configured to', () => { | |
jest.resetModules(); | ||
const width = 100; | ||
const htmlTag = document.querySelector('html'); | ||
htmlTag.setAttribute('data-backend', 'https://cdn.origin:8000/'); | ||
htmlTag.setAttribute('data-media-backend', 'https://cdn.origin:8000/'); | ||
htmlTag.setAttribute('data-image-optimizing-origin', 'onboard'); | ||
const makeUrlAbs = require('../makeUrl').default; | ||
expect( | ||
|
@@ -88,7 +82,7 @@ test('prepends absolute origin if configured to', () => { | |
jest.resetModules(); | ||
const width = 100; | ||
const htmlTag = document.querySelector('html'); | ||
htmlTag.setAttribute('data-backend', 'https://cdn.origin:9000/'); | ||
htmlTag.setAttribute('data-media-backend', 'https://cdn.origin:9000/'); | ||
htmlTag.setAttribute('data-image-optimizing-origin', 'backend'); | ||
const makeUrlAbs = require('../makeUrl').default; | ||
expect( | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we dropping support for these entirely? If so I think that means this has to be a major version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes and yes!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would argue this isn't a major, and is fully backwards compatible for developers that were previously using them. To resolve the docroot bug, you would prefix these values with
/pub
, and update the proxy pattern invenia-upward.yml
to'^/(graphql|rest|pub/media)(/|$)'
.An upgrade makes them obsolete, but nothing breaks. I could see it going both ways, if upward config or environment variables are considered API (ie. you used them in your custom app code).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If nothing breaks I'm okay with that then. I think the next version is already going to be a major so it may be moot anyway.