diff --git a/code/frameworks/nextjs/template/stories/Image.stories.jsx b/code/frameworks/nextjs/template/stories/Image.stories.jsx index e11cc228b0d6..46ef28363830 100644 --- a/code/frameworks/nextjs/template/stories/Image.stories.jsx +++ b/code/frameworks/nextjs/template/stories/Image.stories.jsx @@ -61,6 +61,10 @@ export const Lazy = { width: 50, height: 50, }, + parameters: { + // ignoring in Chromatic to avoid inconsistent snapshots since the image is sometimes not loaded in time + chromatic: { disableSnapshot: true }, + }, decorators: [ (Story) => ( <> @@ -69,30 +73,13 @@ export const Lazy = { ), ], - loaders: [ - async () => { - // make sure we start at the top to test the scrolling into view functionality every time the story renders - // eslint-disable-next-line no-undef - window.scrollTo({ top: 0 }); - await new Promise((res) => { - setTimeout(res, 16); - }); - return {}; - }, - ], - play: async ({ canvasElement, step }) => { - await step('scroll image into view', () => { - canvasElement.scrollIntoView(false); - }); - await step('wait for images to load', async () => { - await waitFor(waitForImagesToLoad); - }); - }, }; export const Eager = { ...Lazy, parameters: { + // ignoring in Chromatic to avoid inconsistent snapshots since the image is sometimes not loaded in time + chromatic: { disableSnapshot: true }, nextjs: { image: { loading: 'eager', @@ -100,19 +87,3 @@ export const Eager = { }, }, }; - -async function waitForImagesToLoad() { - // eslint-disable-next-line no-undef - const images = Array.from(document.getElementsByTagName('img')); - - await Promise.all( - images.map((image) => { - if (image.complete) { - return Promise.resolve(); - } - return new Promise((resolve) => { - image.addEventListener('load', resolve); - }); - }) - ); -} diff --git a/code/frameworks/nextjs/template/stories_nextjs-default-js/ImageLegacy.stories.jsx b/code/frameworks/nextjs/template/stories_nextjs-default-js/ImageLegacy.stories.jsx index d3c1a2accbb2..b8a781499bd1 100644 --- a/code/frameworks/nextjs/template/stories_nextjs-default-js/ImageLegacy.stories.jsx +++ b/code/frameworks/nextjs/template/stories_nextjs-default-js/ImageLegacy.stories.jsx @@ -28,4 +28,9 @@ export const BlurredAbsolutePlaceholder = { 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCA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CoziGKxqWV8IMNp4kP2aC+oB0TMFvhGxDQHQfIPhDrilwKOm/YCZASAHfgBABQjr3f7CyAkA0cPB03AQULRhKd4xAIjzHymo2Gp7gN0FAMAVOoA2fPz03a9ssh/RM7Iz8QKIzYF9HyB0XEZ1xJ4DzNoDOAfAslhDDTyjDfv8A2AcBeCiu/jBHQEgxnYW6Kp6BlCVAkQM8VnieF2Xyr0ivXy+XvsCzKOihwNHCCryw8HrQXVB8dgFeRfAVQiXjMbIIgXINQYB2H7Kf5wF/2Ar7h0AgKKGuAP4zOjhzlkLbpcRXKRZhNUjxG6HIQDOjN47gCn4+fWW3xVS9urPESEEwwHMo9IhAGxS2ISiA1iEnQOoA4hXRAwItp7WzL9Ow18ESJaw/ar4NgeOR49cAHCAnaH8swBhv+6CBGjeBSxEOUAI7HyKHkD4O9xKb3/feQouAI4uLBciHRRHmgbfA7h/xFc9AngNBADthvii1sMOiPwDAFeyt6s7FSFS4PmnA1v0vQvqDqQKAAPE/weAUuEgsj8c+H11Twdw/AKANXA82EDr5cJBEEzB3oI4Mb0AdR3nNw8vQnegWuvqAABwJFJEBwDgNdA7IOs3gL0LhuJdwBY8c4BfNnDdVgooHiOqn/b7JoSW/QODjTHXhU7hMQAAAABJRU5ErkJggg==', placeholder: 'blur', }, + parameters: { + // ignoring in Chromatic to avoid inconsistent snapshots + // given that the switch from blur to image is quite fast + chromatic: { disableSnapshot: true }, + }, };