-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(gatsby-plugin-image): Fix handling of sizes prop in SSR (#28835)
* fix(gatsby-plugin-image): Fix handling of sizes prop in SSR * Update tests * Update tests * Fix types * Update e2e tests * Update e2e-tests/gatsby-static-image/src/pages/constrained.js Co-authored-by: LB <[email protected]> * Add test for size override Co-authored-by: gatsbybot <[email protected]> Co-authored-by: LB <[email protected]> (cherry picked from commit a135c50)
- Loading branch information
Showing
8 changed files
with
77 additions
and
31 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
e2e-tests/gatsby-static-image/cypress/integration/constrained.js
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
describe(`constrained`, () => { | ||
beforeEach(() => { | ||
cy.visit(`/constrained`).waitForRouteChange() | ||
}) | ||
|
||
it(`renders a spacer svg`, () => { | ||
cy.getTestElement(`image-constrained`) | ||
.find(`img[role=presentation]`) | ||
.should(`have.attr`, `src`) | ||
.and(`match`, /svg\+xml/) | ||
}) | ||
|
||
it(`includes sizes attribute with default width`, () => { | ||
cy.getTestElement(`image-constrained`) | ||
.find(`[data-main-image]`) | ||
.should(`have.attr`, `sizes`) | ||
.and(`equal`, `(min-width: 4015px) 4015px, 100vw`) | ||
}) | ||
|
||
it(`includes sizes attribute with specified width`, () => { | ||
cy.getTestElement(`image-constrained-limit`) | ||
.find(`[data-main-image]`) | ||
.should(`have.attr`, `sizes`) | ||
.and(`equal`, `(min-width: 500px) 500px, 100vw`) | ||
}) | ||
|
||
it(`overrides sizes`, () => { | ||
cy.getTestElement(`image-constrained-override`) | ||
.find(`[data-main-image]`) | ||
.should(`have.attr`, `sizes`) | ||
.and(`equal`, `100vw`) | ||
}) | ||
}) |
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
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