Skip to content

Commit 4b477e4

Browse files
authored
Merge pull request #1151 from equinor/fix/rte-onimageupload
fix/rte-onimageupload
2 parents 3ea8455 + 37a39f9 commit 4b477e4

6 files changed

Lines changed: 325 additions & 317 deletions

File tree

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Base
2-
FROM imbios/bun-node:22-alpine AS base
2+
FROM oven/bun:1.2-alpine AS base
33
WORKDIR /app
44
COPY package.json ./
55
COPY bun.lock ./

bun.lock

Lines changed: 298 additions & 288 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@
5858
"@faker-js/faker": "^9.6.0",
5959
"@storybook/addon-coverage": "^2.0.0",
6060
"@storybook/addon-designs": "^10.0.2",
61-
"@storybook/addon-docs": "^9.1.1",
62-
"@storybook/addon-links": "^9.1.1",
63-
"@storybook/react-vite": "^9.1.1",
61+
"@storybook/addon-docs": "^9.1.10",
62+
"@storybook/addon-links": "^9.1.10",
63+
"@storybook/react-vite": "^9.1.10",
6464
"@tanstack/react-query": "^5.67.2",
6565
"@testing-library/dom": "^10.4.0",
6666
"@testing-library/jest-dom": "^6.6.3",
@@ -96,7 +96,7 @@
9696
"react-dom": "^19.0.0",
9797
"resize-observer-polyfill": "^1.5.1",
9898
"resolve-tspaths": "^0.8.23",
99-
"storybook": "^9.1.1",
99+
"storybook": "^9.1.10",
100100
"tsdown": "^0.14.2",
101101
"typescript": "^5.8.2",
102102
"typescript-eslint": "^8.26.1",

public/mockServiceWorker.js

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
* - Please do NOT modify this file.
88
*/
99

10-
const PACKAGE_VERSION = '2.11.1'
11-
const INTEGRITY_CHECKSUM = 'f5825c521429caf22a4dd13b66e243af'
10+
const PACKAGE_VERSION = '2.11.3'
11+
const INTEGRITY_CHECKSUM = '4db4a41e972cec1b64cc569c66952d82'
1212
const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
1313
const activeClientIds = new Set()
1414

@@ -71,11 +71,6 @@ addEventListener('message', async function (event) {
7171
break
7272
}
7373

74-
case 'MOCK_DEACTIVATE': {
75-
activeClientIds.delete(clientId)
76-
break
77-
}
78-
7974
case 'CLIENT_CLOSED': {
8075
activeClientIds.delete(clientId)
8176

@@ -94,6 +89,8 @@ addEventListener('message', async function (event) {
9489
})
9590

9691
addEventListener('fetch', function (event) {
92+
const requestInterceptedAt = Date.now()
93+
9794
// Bypass navigation requests.
9895
if (event.request.mode === 'navigate') {
9996
return
@@ -110,23 +107,29 @@ addEventListener('fetch', function (event) {
110107

111108
// Bypass all requests when there are no active clients.
112109
// Prevents the self-unregistered worked from handling requests
113-
// after it's been deleted (still remains active until the next reload).
110+
// after it's been terminated (still remains active until the next reload).
114111
if (activeClientIds.size === 0) {
115112
return
116113
}
117114

118115
const requestId = crypto.randomUUID()
119-
event.respondWith(handleRequest(event, requestId))
116+
event.respondWith(handleRequest(event, requestId, requestInterceptedAt))
120117
})
121118

122119
/**
123120
* @param {FetchEvent} event
124121
* @param {string} requestId
122+
* @param {number} requestInterceptedAt
125123
*/
126-
async function handleRequest(event, requestId) {
124+
async function handleRequest(event, requestId, requestInterceptedAt) {
127125
const client = await resolveMainClient(event)
128126
const requestCloneForEvents = event.request.clone()
129-
const response = await getResponse(event, client, requestId)
127+
const response = await getResponse(
128+
event,
129+
client,
130+
requestId,
131+
requestInterceptedAt,
132+
)
130133

131134
// Send back the response clone for the "response:*" life-cycle events.
132135
// Ensure MSW is active and ready to handle the message, otherwise
@@ -204,7 +207,7 @@ async function resolveMainClient(event) {
204207
* @param {string} requestId
205208
* @returns {Promise<Response>}
206209
*/
207-
async function getResponse(event, client, requestId) {
210+
async function getResponse(event, client, requestId, requestInterceptedAt) {
208211
// Clone the request because it might've been already used
209212
// (i.e. its body has been read and sent to the client).
210213
const requestClone = event.request.clone()
@@ -255,6 +258,7 @@ async function getResponse(event, client, requestId) {
255258
type: 'REQUEST',
256259
payload: {
257260
id: requestId,
261+
interceptedAt: requestInterceptedAt,
258262
...serializedRequest,
259263
},
260264
},

src/molecules/RichTextEditor/RichTextEditor.test.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ function fakeProps(withImage = false): RichTextEditorProps {
1717
value: `<p>${faker.animal.fish()}</p>`,
1818
onChange: vi.fn(),
1919
onImageUpload: withImage ? vi.fn() : undefined,
20+
onImageRemove: withImage ? vi.fn() : undefined,
2021
};
2122
}
2223

@@ -94,6 +95,9 @@ test('Calls onImageUpload as expected', async () => {
9495
// Wait for tip tap to initialize
9596
await new Promise((resolve) => setTimeout(resolve, 1000));
9697

98+
expect(props.onImageRemove).not.toHaveBeenCalled();
99+
expect(props.onImageUpload).not.toHaveBeenCalled();
100+
97101
const uploadInput = container.querySelector('input') as HTMLElement;
98102

99103
const fakeFile = new File(
@@ -103,7 +107,7 @@ test('Calls onImageUpload as expected', async () => {
103107
);
104108
await user.upload(uploadInput, fakeFile);
105109

106-
expect(props.onImageUpload).toHaveBeenCalledWith(fakeFile);
110+
expect(props.onImageUpload).toHaveBeenCalledExactlyOnceWith(fakeFile);
107111
});
108112

109113
test('Open file dialog', async () => {

src/molecules/Waves/Waves.tsx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import { FC, useEffect, useRef, useState } from 'react';
33
import { Container } from './Waves.styles';
44
import { WaveStatic } from './WaveStatic';
55

6-
import { useScroll } from 'framer-motion';
7-
86
export interface WavesProps {
97
gradientColors?: string[];
108
}
@@ -13,9 +11,6 @@ export const Waves: FC<WavesProps> = ({ gradientColors }) => {
1311
const containerRef = useRef<HTMLDivElement | null>(null);
1412
const [width, setWidth] = useState(containerRef.current?.clientWidth ?? 0);
1513
const [height, setHeight] = useState(containerRef.current?.clientHeight ?? 0);
16-
const { scrollY } = useScroll({
17-
container: { current: document.getElementById('content') },
18-
});
1914

2015
const handleSetRef = (element: HTMLDivElement | null) => {
2116
containerRef.current = element;
@@ -43,12 +38,7 @@ export const Waves: FC<WavesProps> = ({ gradientColors }) => {
4338
}, []);
4439

4540
return (
46-
<Container
47-
ref={handleSetRef}
48-
style={{
49-
top: scrollY,
50-
}}
51-
>
41+
<Container ref={handleSetRef}>
5242
<WaveStatic
5343
height={height}
5444
width={width}

0 commit comments

Comments
 (0)