Skip to content

Commit 6c7c90c

Browse files
authored
Stabilize MImage/MVideoBodyView snapshots (#33289)
* Stabilize MImage/MVideoBodyView snapshots * add to global * Use vite/client for imports * fixup
1 parent 0201a7e commit 6c7c90c

6 files changed

Lines changed: 14 additions & 22 deletions

File tree

packages/shared-components/src/@types/global.d.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,3 @@ declare module "*.md?raw" {
1313
const content: string;
1414
export default content;
1515
}
16-
17-
// For importing PNGs for use in testing
18-
declare module "*.png" {
19-
const content: string;
20-
export default content;
21-
}

packages/shared-components/src/room/timeline/event-tile/body/MImageBodyView/ImageBodyView.stories.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ import {
1818
type ImageBodyViewActions,
1919
type ImageBodyViewSnapshot,
2020
} from "./ImageBodyView";
21-
22-
const imageSrc = new URL("../../../../../../static/image-body/install-spinner.png", import.meta.url).href;
23-
const thumbnailSrc = new URL("../../../../../../static/image-body/install-spinner.png", import.meta.url).href;
24-
const animatedGifSrc = new URL("../../../../../../static/image-body/install-spinner.gif", import.meta.url).href;
21+
import imageSrc from "../../../../../../static/image-body/install-spinner.png";
22+
import thumbnailSrc from "../../../../../../static/image-body/install-spinner.png";
23+
import animatedGifSrc from "../../../../../../static/image-body/install-spinner.gif";
2524
const demoBlurhash = "LEHV6nWB2yk8pyo0adR*.7kCMdnj";
2625
const imageBodyViewStateOptions = [ImageBodyViewState.ERROR, ImageBodyViewState.HIDDEN, ImageBodyViewState.READY];
2726
const imageBodyViewPlaceholderOptions = [

packages/shared-components/src/room/timeline/event-tile/body/MImageBodyView/__snapshots__/ImageBodyView.test.tsx.snap

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ exports[`ImageBodyView > matches snapshot for animated-preview story 1`] = `
77
>
88
<a
99
class="ImageBodyView-module_link"
10-
href="http://localhost:63315/static/image-body/install-spinner.gif"
10+
href="/static/image-body/install-spinner.gif"
1111
>
1212
<div
1313
class="ImageBodyView-module_thumbnailContainer"
@@ -19,7 +19,7 @@ exports[`ImageBodyView > matches snapshot for animated-preview story 1`] = `
1919
<img
2020
alt="Element logo"
2121
class="ImageBodyView-module_image"
22-
src="http://localhost:63315/static/image-body/install-spinner.png"
22+
src="/static/image-body/install-spinner.png"
2323
/>
2424
<p
2525
class="ImageBodyView-module_gifLabel"
@@ -43,7 +43,7 @@ exports[`ImageBodyView > matches snapshot for default story 1`] = `
4343
>
4444
<a
4545
class="ImageBodyView-module_link"
46-
href="http://localhost:63315/static/image-body/install-spinner.png"
46+
href="/static/image-body/install-spinner.png"
4747
>
4848
<div
4949
class="ImageBodyView-module_thumbnailContainer"
@@ -55,7 +55,7 @@ exports[`ImageBodyView > matches snapshot for default story 1`] = `
5555
<img
5656
alt="Element logo"
5757
class="ImageBodyView-module_image"
58-
src="http://localhost:63315/static/image-body/install-spinner.png"
58+
src="/static/image-body/install-spinner.png"
5959
/>
6060
</div>
6161
</div>
@@ -147,7 +147,7 @@ exports[`ImageBodyView > matches snapshot for loading-with-blurhash story 1`] =
147147
>
148148
<a
149149
class="ImageBodyView-module_link"
150-
href="http://localhost:63315/static/image-body/install-spinner.png"
150+
href="/static/image-body/install-spinner.png"
151151
>
152152
<div
153153
class="ImageBodyView-module_thumbnailContainer"
@@ -173,7 +173,7 @@ exports[`ImageBodyView > matches snapshot for loading-with-blurhash story 1`] =
173173
<img
174174
alt="Element logo"
175175
class="ImageBodyView-module_image"
176-
src="http://localhost:63315/static/image-body/install-spinner.png"
176+
src="/static/image-body/install-spinner.png"
177177
/>
178178
</div>
179179
</div>
@@ -192,7 +192,7 @@ exports[`ImageBodyView > matches snapshot for loading-with-spinner story 1`] = `
192192
>
193193
<a
194194
class="ImageBodyView-module_link"
195-
href="http://localhost:63315/static/image-body/install-spinner.png"
195+
href="/static/image-body/install-spinner.png"
196196
>
197197
<div
198198
class="ImageBodyView-module_thumbnailContainer"
@@ -225,7 +225,7 @@ exports[`ImageBodyView > matches snapshot for loading-with-spinner story 1`] = `
225225
<img
226226
alt="Element logo"
227227
class="ImageBodyView-module_image"
228-
src="http://localhost:63315/static/image-body/install-spinner.png"
228+
src="/static/image-body/install-spinner.png"
229229
/>
230230
</div>
231231
</div>

packages/shared-components/src/room/timeline/event-tile/body/MVideoBodyView/VideoBodyView.stories.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ import {
1717
} from "./VideoBodyView";
1818
import { useMockedViewModel } from "../../../../../core/viewmodel/useMockedViewModel";
1919
import { withViewDocs } from "../../../../../../.storybook/withViewDocs";
20-
21-
const demoVideo = new URL("../../../../../../static/videoBodyDemo.webm", import.meta.url).href;
20+
import demoVideo from "../../../../../../static/videoBodyDemo.webm";
2221

2322
type VideoBodyViewProps = VideoBodyViewSnapshot &
2423
VideoBodyViewActions & {

packages/shared-components/src/room/timeline/event-tile/body/MVideoBodyView/__snapshots__/VideoBodyView.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ exports[`VideoBodyView > matches snapshot for ready story 1`] = `
7979
crossorigin="anonymous"
8080
poster="/static/element.png"
8181
preload="none"
82-
src="http://localhost:63315/static/videoBodyDemo.webm"
82+
src="/static/videoBodyDemo.webm"
8383
/>
8484
</div>
8585
<div>

packages/shared-components/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"declaration": true,
1515
"jsx": "react",
1616
"lib": ["es2022", "es2024.promise", "dom", "dom.iterable"],
17-
"types": ["storybook-addon-vis/matcher"],
17+
"types": ["vite/client", "storybook-addon-vis/matcher"],
1818
"strict": true,
1919
"paths": {
2020
"@test-utils": ["./src/test/utils/index"]

0 commit comments

Comments
 (0)