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

fix: Fix image lazy loading for Chrome in SSR mode #18761

Merged
merged 9 commits into from Apr 25, 2024
Merged

Conversation

rmch91
Copy link
Contributor

@rmch91 rmch91 commented Apr 23, 2024

This PR provides the work around for not working image lazy loading in SSR in Chrome and Safari.
Issue reported to Angular team angular/angular#55512

QA steps:

1 Scenario

  1. In media.module add
    provideDefaultConfig({ imageLoadingStrategy: ImageLoadingStrategy.LAZY } as MediaConfig) to providers

  2. npm run build:storefrontlib && npm run build && npm run build:ssr && NODE_TLS_REJECT_UNAUTHORIZED=0 npm run serve:ssr

  3. Open http://localhost:4000/electronics-spa/en/USD/Brands/Sony/c/brand_5

  4. Check network tab for images, reload page, browser should load only part of images, rest should be loaded on scroll only. Make sure that media component use picture element in html in dev tools

  5. Check Chrome, Safari, Firefox

2 Scenario

  1. In media.module add
    provideDefaultConfig({ imageLoadingStrategy: ImageLoadingStrategy.LAZY } as MediaConfig) and provideDefaultConfig({ useLegacyMediaComponent: true } as MediaConfig) to providers

  2. npm run build:storefrontlib && npm run build && npm run build:ssr && NODE_TLS_REJECT_UNAUTHORIZED=0 npm run serve:ssr

  3. Open http://localhost:4000/electronics-spa/en/USD/Brands/Sony/c/brand_5

  4. Check network tab for images, reload page, browser should load only part of images, rest should be loaded on scroll only. Make sure that media component use only img tag (without picture) in html in dev tools

  5. Check Chrome, Safari, Firefox

3 Scenario

  1. Remove provideDefaultConfig({ imageLoadingStrategy: ImageLoadingStrategy.LAZY } as MediaConfig) and provideDefaultConfig({ useLegacyMediaComponent: true } as MediaConfig) from media.module

  2. npm run build:storefrontlib && npm run build && npm run build:ssr && NODE_TLS_REJECT_UNAUTHORIZED=0 npm run serve:ssr

  3. Open http://localhost:4000/electronics-spa/en/USD/Brands/Sony/c/brand_5

  4. Check network tab for images, reload page, browser should load all images

  5. Check Chrome, Safari, Firefox

While checking SSR please make sure that page was rendered by SSR

Perform the same steps in CSR mode

Closes: https://jira.tools.sap/browse/CXSPA-6719

@rmch91 rmch91 requested a review from a team as a code owner April 23, 2024 12:19
@github-actions github-actions bot marked this pull request as draft April 23, 2024 12:20
@rmch91 rmch91 marked this pull request as ready for review April 24, 2024 13:27
Copy link

cypress bot commented Apr 24, 2024

4 flaky tests on run #43397 ↗︎

0 119 2 0 Flakiness 4

Details:

Merge 95028d4 into 0b7d289...
Project: spartacus Commit: 3f150343ed ℹ️
Status: Passed Duration: 03:51 💡
Started: Apr 25, 2024 11:56 AM Ended: Apr 25, 2024 12:00 PM
Flakiness  regression/asm/asm.emulation.core-e2e.cy.ts • 1 flaky test • B2C

View Output Video

Test Artifacts
Assisted Service Module > Customer Support Agent - Emulation > should checkout as customer Test Replay Screenshots Video
Flakiness  ssr/pages.core-e2e.cy.ts • 3 flaky tests • SSR

View Output Video

Test Artifacts
SSR > should render homepage Test Replay Screenshots Video
SSR > should render PLP Test Replay Screenshots Video
SSR > should render PDP Test Replay Screenshots Video

Review all test suite changes for PR #18761 ↗︎

@github-actions github-actions bot marked this pull request as draft April 24, 2024 14:23
@rmch91 rmch91 marked this pull request as ready for review April 25, 2024 07:09
@github-actions github-actions bot marked this pull request as draft April 25, 2024 09:30
@rmch91 rmch91 marked this pull request as ready for review April 25, 2024 10:13
@github-actions github-actions bot marked this pull request as draft April 25, 2024 11:41
Copy link
Contributor

@pawelfras pawelfras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QA done. LGTM.

@rmch91 rmch91 marked this pull request as ready for review April 25, 2024 11:47
@rmch91 rmch91 merged commit 064d237 into develop Apr 25, 2024
26 checks passed
@rmch91 rmch91 deleted the fix/CXSPA-6719 branch April 25, 2024 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants