Skip to content

Commit eca79aa

Browse files
committed
Merge branch 'develop' into coordinate-tracker
2 parents 63aba97 + 8bbb2ad commit eca79aa

File tree

17 files changed

+16351
-22753
lines changed

17 files changed

+16351
-22753
lines changed

.babelrc

+14
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,20 @@
6262
}
6363
]
6464
]
65+
},
66+
"test": {
67+
"presets": [
68+
"@babel/preset-env",
69+
[
70+
"@babel/preset-react",
71+
{
72+
"runtime": "automatic"
73+
}
74+
]
75+
],
76+
"plugins": [
77+
"babel-plugin-styled-components"
78+
]
6579
}
6680
},
6781
"plugins": [

client/modules/IDE/components/Header/__snapshots__/Nav.unit.test.jsx.snap

+6-6
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ exports[`Nav renders dashboard version for mobile 1`] = `
211211
-ms-flex-direction: column;
212212
flex-direction: column;
213213
gap: 0.16666666666666666rem;
214-
box-shadow: rgba(60,64,67,0.3) 0px 1px 2px 0px, rgba(60,64,67,0.15) 0px 1px 3px 1px;
214+
box-shadow: rgba(60,64,67,0.3) 0px 1px 2px 0px,rgba(60,64,67,0.15) 0px 1px 3px 1px;
215215
min-width: 10rem;
216216
border-radius: 0.16666666666666666rem;
217217
}
@@ -324,7 +324,7 @@ exports[`Nav renders dashboard version for mobile 1`] = `
324324
>
325325
<test-file-stub
326326
aria-hidden="true"
327-
classname="sc-fujyAs cSTVlM"
327+
classname="icons__StyledIcon-sc-xmer15-0 dStXqm"
328328
focusable="false"
329329
/>
330330
</button>
@@ -340,7 +340,7 @@ exports[`Nav renders dashboard version for mobile 1`] = `
340340
>
341341
<test-file-stub
342342
aria-hidden="true"
343-
classname="sc-iqAclL iOZiVo"
343+
classname="icons__StyledIcon-sc-xmer15-0 dStXqm"
344344
focusable="false"
345345
/>
346346
</button>
@@ -912,7 +912,7 @@ exports[`Nav renders editor version for mobile 1`] = `
912912
-ms-flex-direction: column;
913913
flex-direction: column;
914914
gap: 0.16666666666666666rem;
915-
box-shadow: rgba(60,64,67,0.3) 0px 1px 2px 0px, rgba(60,64,67,0.15) 0px 1px 3px 1px;
915+
box-shadow: rgba(60,64,67,0.3) 0px 1px 2px 0px,rgba(60,64,67,0.15) 0px 1px 3px 1px;
916916
min-width: 10rem;
917917
border-radius: 0.16666666666666666rem;
918918
}
@@ -1025,7 +1025,7 @@ exports[`Nav renders editor version for mobile 1`] = `
10251025
>
10261026
<test-file-stub
10271027
aria-hidden="true"
1028-
classname="sc-fujyAs cSTVlM"
1028+
classname="icons__StyledIcon-sc-xmer15-0 dStXqm"
10291029
focusable="false"
10301030
/>
10311031
</button>
@@ -1041,7 +1041,7 @@ exports[`Nav renders editor version for mobile 1`] = `
10411041
>
10421042
<test-file-stub
10431043
aria-hidden="true"
1044-
classname="sc-iqAclL iOZiVo"
1044+
classname="icons__StyledIcon-sc-xmer15-0 dStXqm"
10451045
focusable="false"
10461046
/>
10471047
</button>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// resolveUtils.unit.test.jsx
2+
3+
import resolvePathsForElementsWithAttribute from '../../../../../server/utils/resolveUtils';
4+
import { resolvePathToFile } from '../../../../../server/utils/filePath';
5+
6+
// Mock the dependencies
7+
jest.mock('../../../../../server/utils/filePath', () => ({
8+
resolvePathToFile: jest.fn()
9+
}));
10+
11+
jest.mock('../../../../../server/utils/fileUtils', () => ({
12+
MEDIA_FILE_REGEX: /\.(png|jpg|jpeg|gif|svg)$/i
13+
}));
14+
15+
describe('resolvePathsForElementsWithAttribute', () => {
16+
let mockSketchDoc;
17+
let mockFiles;
18+
19+
beforeEach(() => {
20+
jest.clearAllMocks();
21+
22+
// Create a mock DOM environment
23+
mockSketchDoc = document.implementation.createHTMLDocument();
24+
mockFiles = {
25+
'image.png': { url: 'https://example.com/image.png' },
26+
'missing.jpg': { url: null }
27+
};
28+
29+
resolvePathToFile.mockImplementation((fileName, files) => files[fileName]);
30+
});
31+
32+
it('should update the attribute when the file is resolved successfully', () => {
33+
const element = mockSketchDoc.createElement('img');
34+
element.setAttribute('src', 'image.png');
35+
mockSketchDoc.body.appendChild(element);
36+
37+
resolvePathsForElementsWithAttribute('src', mockSketchDoc, mockFiles);
38+
39+
expect(element.getAttribute('src')).toBe('https://example.com/image.png');
40+
});
41+
42+
it('should not update the attribute when the file resolution fails', () => {
43+
const element = mockSketchDoc.createElement('img');
44+
element.setAttribute('src', 'missing.jpg');
45+
mockSketchDoc.body.appendChild(element);
46+
47+
resolvePathsForElementsWithAttribute('src', mockSketchDoc, mockFiles);
48+
49+
expect(element.getAttribute('src')).toBe('missing.jpg');
50+
});
51+
52+
it('should not update the attribute when the value does not match MEDIA_FILE_REGEX', () => {
53+
const element = mockSketchDoc.createElement('img');
54+
element.setAttribute('src', 'document.pdf');
55+
mockSketchDoc.body.appendChild(element);
56+
57+
resolvePathsForElementsWithAttribute('src', mockSketchDoc, mockFiles);
58+
59+
expect(element.getAttribute('src')).toBe('document.pdf');
60+
});
61+
62+
it('should do nothing when no elements with the specified attribute are found', () => {
63+
resolvePathsForElementsWithAttribute('src', mockSketchDoc, mockFiles);
64+
65+
expect(mockSketchDoc.querySelectorAll('[src]').length).toBe(0);
66+
});
67+
});

client/modules/Preview/EmbedFrame.jsx

+1-14
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import decomment from 'decomment';
88
import { resolvePathToFile } from '../../../server/utils/filePath';
99
import getConfig from '../../utils/getConfig';
1010
import {
11-
MEDIA_FILE_REGEX,
1211
MEDIA_FILE_QUOTED_REGEX,
1312
STRING_REGEX,
1413
PLAINTEXT_FILE_REGEX,
@@ -18,6 +17,7 @@ import {
1817
import { getAllScriptOffsets } from '../../utils/consoleUtils';
1918
import { registerFrame } from '../../utils/dispatcher';
2019
import { createBlobUrl } from './filesReducer';
20+
import resolvePathsForElementsWithAttribute from '../../../server/utils/resolveUtils';
2121

2222
let objectUrls = {};
2323
let objectPaths = {};
@@ -34,19 +34,6 @@ const Frame = styled.iframe`
3434
`}
3535
`;
3636

37-
function resolvePathsForElementsWithAttribute(attr, sketchDoc, files) {
38-
const elements = sketchDoc.querySelectorAll(`[${attr}]`);
39-
const elementsArray = Array.prototype.slice.call(elements);
40-
elementsArray.forEach((element) => {
41-
if (element.getAttribute(attr).match(MEDIA_FILE_REGEX)) {
42-
const resolvedFile = resolvePathToFile(element.getAttribute(attr), files);
43-
if (resolvedFile && resolvedFile.url) {
44-
element.setAttribute(attr, resolvedFile.url);
45-
}
46-
}
47-
});
48-
}
49-
5037
function resolveCSSLinksInString(content, files) {
5138
let newContent = content;
5239
let cssFileStrings = content.match(STRING_REGEX);

client/modules/User/components/LoginForm.jsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ function LoginForm() {
101101
)}
102102
</Field>
103103
{submitError && !modifiedSinceLastSubmit && (
104-
<span className="form-error">{submitError}</span>
104+
<span className="form-error">
105+
{t('LoginForm.Errors.invalidCredentials')}
106+
</span>
105107
)}
106108
<Button type="submit" disabled={submitting}>
107109
{t('LoginForm.Submit')}

client/modules/User/components/SignupForm.jsx

+1-5
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,14 @@ function SignupForm() {
7070
setShowConfirmPassword(!showConfirmPassword);
7171

7272
function onSubmit(formProps) {
73-
console.log("it's happening");
7473
return dispatch(validateAndSignUpUser(formProps));
7574
}
7675

7776
return (
7877
<Form
7978
fields={['username', 'email', 'password', 'confirmPassword']}
8079
validate={validateSignup}
81-
onSubmit={(values) => {
82-
console.log('Form onSubmit triggered', values);
83-
return onSubmit(values);
84-
}}
80+
onSubmit={onSubmit}
8581
>
8682
{({ handleSubmit, pristine, submitting, invalid, form }) => {
8783
formRef.current = form;

0 commit comments

Comments
 (0)