Skip to content

Commit 433f20a

Browse files
authored
Merge pull request #739 from materialsproject/github_action_tests
Clean React test and resolve dependencies
2 parents 1eb3297 + 292ac0e commit 433f20a

File tree

10 files changed

+283
-9
lines changed

10 files changed

+283
-9
lines changed

.github/workflows/jest_tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches:
66
- main
7+
- github_action_tests
78

89
jobs:
910
test:

demo/app.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ ReactDOM.render(
2727
<section>
2828
<Switch>
2929
<Route path="/">
30-
<CrystalStructureViewer />
30+
<CrystalStructureAnimationViewer />
3131
</Route>
3232
</Switch>
3333
</section>

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports = {
1010
* This is necessary for node modules that distribute their source code as uncompiled JS.
1111
*/
1212
transformIgnorePatterns: [
13-
'node_modules/(?!(three|unist-.*|hast-.*|rehype-slug|remark-rehype|react-markdown|vfile.*|unified|bail|is-plain-obj|trough|remark-parse|mdast-.*|micromark.*|decode-named-character-reference|unist-.*|character-entities|property-information|space-separated-tokens|comma-separated-tokens)/)'
13+
'node_modules/(?!(three|trim-lines|github-slugger|unist-.*|hast-.*|rehype-slug|remark-rehype|react-markdown|vfile.*|unified|bail|is-plain-obj|trough|remark-parse|mdast-.*|micromark.*|decode-named-character-reference|unist-.*|character-entities|property-information|space-separated-tokens|comma-separated-tokens)/)'
1414
],
1515
modulePaths: ['<rootDir>'],
1616
moduleDirectories: ['node_modules', '<rootDir>'],

src/components/crystal-toolkit/CrystalToolkitAnimationScene/CrystalToolkitAnimationScene.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { mount } from 'enzyme';
22
import * as React from 'react';
33
import { CrystalToolkitAnimationScene } from './CrystalToolkitAnimationScene';
4-
import { s2 as scene } from '../scene/simple-scene';
4+
import { phonon_scene as scene } from '../scene/phonon-animation-scene';
55
import { MOUNT_NODE_CLASS, Renderer } from '../scene/constants';
66
import Scene from '../scene/Scene';
77

88
const spy = jest.spyOn(Scene.prototype, 'renderScene');
9-
const RENDERSCENE_CALLS_BY_REACT_RENDERING = 1; // goal is to reach 1 and stay there :)
9+
const RENDERSCENE_CALLS_BY_REACT_RENDERING = 3; // goal is to reach 1 and stay there :)
1010

1111
// When we run test, three.js is bundled differently, and we encounter again the bug
1212
// where we have 2 different instances of three

src/components/crystal-toolkit/CrystalToolkitAnimationScene/CrystalToolkitAnimationScene.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,9 +419,9 @@ export const CrystalToolkitAnimationScene: React.FC<CrystalToolkitAnimationScene
419419
},
420420
mountNodeDebugRef.current!
421421
));
422-
423422
_s.removeListener();
424423
_s.animate();
424+
425425
/**
426426
* I believe this can be removed because image requesting is now handled by
427427
* the image dropdown.

src/components/crystal-toolkit/scene/animation-helper.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ export class AnimationHelper {
6161
} else {
6262
console.warn(`Unknown animationType: ${animationType}`);
6363
}
64-
6564
const positionKF = new THREE.VectorKeyframeTrack('.position', [...kf], values);
6665

6766
let kflVal;

src/components/crystal-toolkit/scene/simple-scene.ts

Lines changed: 272 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,278 @@ export const s4 = {
220220
};
221221

222222
export const s2 = {
223+
name: '_ct_StructureMoleculeComponent_1',
224+
contents: [
225+
{
226+
name: 'atoms',
227+
clickable: true,
228+
contents: [
229+
{
230+
positions: [
231+
[4.2, 4.2, 0],
232+
[0, 4.2, 4.2],
233+
[0, 4.2, 0],
234+
[4.2, 0, 4.2],
235+
[4.2, 4.2, 4.2],
236+
[0, 0, 0],
237+
[0, 0, 4.2],
238+
[4.2, 0, 0]
239+
],
240+
color: '#f9dc3c',
241+
radius: 0.5,
242+
tooltip: 'label',
243+
type: 'spheres',
244+
clickable: true,
245+
keyframes: [0, 1]
246+
},
247+
{
248+
positions: [[2.1, 2.1, 2.1]],
249+
color: '#4444ff',
250+
radius: 0.5,
251+
type: 'spheres',
252+
tooltip: 'label',
253+
clickable: true,
254+
keyframes: [0, 1]
255+
}
256+
],
257+
origin: [-2.1, -2.1, -2.1],
258+
visible: true
259+
},
260+
{
261+
name: 'bonds',
262+
contents: [
263+
{
264+
positionPairs: [
265+
[
266+
[4.2, 4.2, 0],
267+
[3.1500000000000004, 3.1500000000000004, 1.05]
268+
],
269+
[
270+
[0, 4.2, 4.2],
271+
[1.05, 3.1500000000000004, 3.1500000000000004]
272+
],
273+
[
274+
[0, 4.2, 0],
275+
[1.05, 3.1500000000000004, 1.05]
276+
],
277+
[
278+
[4.2, 0, 4.2],
279+
[3.1500000000000004, 1.05, 3.1500000000000004]
280+
],
281+
[
282+
[4.2, 4.2, 4.2],
283+
[3.1500000000000004, 3.1500000000000004, 3.1500000000000004]
284+
],
285+
[
286+
[0, 0, 0],
287+
[1.05, 1.05, 1.05]
288+
],
289+
[
290+
[0, 0, 4.2],
291+
[1.05, 1.05, 3.1500000000000004]
292+
],
293+
[
294+
[4.2, 0, 0],
295+
[3.1500000000000004, 1.05, 1.05]
296+
]
297+
],
298+
keyframes: [0, 1],
299+
color: '#f9dc3c',
300+
tooltip: 'label',
301+
radius: 0.1,
302+
type: 'cylinders',
303+
clickable: true
304+
},
305+
{
306+
positionPairs: [
307+
[
308+
[2.1, 2.1, 2.1], // starts from center sphere
309+
[1.05, 1.05, 1.05] // end in yellow
310+
],
311+
[
312+
[2.1, 2.1, 2.1],
313+
[3.1500000000000004, 1.05, 1.05]
314+
],
315+
[
316+
[2.1, 2.1, 2.1],
317+
[3.1500000000000004, 3.1500000000000004, 3.1500000000000004]
318+
],
319+
[
320+
[2.1, 2.1, 2.1],
321+
[3.1500000000000004, 1.05, 3.1500000000000004]
322+
],
323+
[
324+
[2.1, 2.1, 2.1],
325+
[1.05, 3.1500000000000004, 1.05]
326+
],
327+
[
328+
[2.1, 2.1, 2.1],
329+
[3.1500000000000004, 3.1500000000000004, 1.05]
330+
],
331+
[
332+
[2.1, 2.1, 2.1],
333+
[1.05, 1.05, 3.1500000000000004]
334+
],
335+
[
336+
[2.1, 2.1, 2.1],
337+
[1.05, 3.1500000000000004, 3.1500000000000004]
338+
]
339+
],
340+
keyframes: [0, 1],
341+
color: '#a121f6',
342+
radius: 0.1,
343+
type: 'cylinders',
344+
tooltip: 'label',
345+
clickable: true
346+
}
347+
],
348+
origin: [-2.1, -2.1, -2.1],
349+
visible: true
350+
},
351+
{
352+
name: 'cubes',
353+
contents: [
354+
{
355+
positions: [
356+
[4, 4, 4],
357+
[10, 10, 10]
358+
],
359+
width: 2,
360+
color: '#ababaa',
361+
type: 'cubes',
362+
tooltip: 'label',
363+
keyframes: [0, 1]
364+
}
365+
]
366+
},
367+
{
368+
name: 'polyhedra',
369+
contents: [
370+
{
371+
positions: [
372+
[2.1, 2.1, 2.1],
373+
[0, 0, 0],
374+
[4.2, 0, 0],
375+
[4.2, 4.2, 4.2],
376+
[4.2, 0, 4.2],
377+
[0, 4.2, 0],
378+
[4.2, 4.2, 0],
379+
[0, 0, 4.2],
380+
[0, 4.2, 4.2]
381+
],
382+
keyframes: [0, 1],
383+
color: '#a121f6',
384+
type: 'convex'
385+
}
386+
],
387+
origin: [-2.1, -2.1, -2.1],
388+
tooltip: 'label',
389+
visible: true
390+
},
391+
{
392+
name: 'unit_cell',
393+
contents: [
394+
{
395+
name: 'a=4.2, b=4.2, c=4.2, alpha=90.0, beta=90.0, gamma=90.0',
396+
contents: [
397+
{
398+
positions: [
399+
[0, 0, 0],
400+
[4.2, 0, 0],
401+
[0, 0, 0],
402+
[0, 4.2, 0],
403+
[0, 0, 0],
404+
[0, 0, 4.2],
405+
[4.2, 0, 0],
406+
[4.2, 4.2, 0],
407+
[4.2, 0, 0],
408+
[4.2, 0, 4.2],
409+
[0, 4.2, 0],
410+
[4.2, 4.2, 0],
411+
[0, 4.2, 0],
412+
[0, 4.2, 4.2],
413+
[0, 0, 4.2],
414+
[4.2, 0, 4.2],
415+
[0, 0, 4.2],
416+
[0, 4.2, 4.2],
417+
[4.2, 4.2, 0],
418+
[4.2, 4.2, 4.2],
419+
[4.2, 0, 4.2],
420+
[4.2, 4.2, 4.2],
421+
[0, 4.2, 4.2],
422+
[4.2, 4.2, 4.2]
423+
],
424+
keyframes: [0, 1],
425+
type: 'lines'
426+
}
427+
],
428+
visible: false
429+
}
430+
],
431+
origin: [-2.1, -2.1, -2.1],
432+
visible: false
433+
},
434+
{
435+
name: 'axes',
436+
contents: [
437+
{
438+
positionPairs: [
439+
[
440+
[-2.1, -2.1, -2.1],
441+
[-1.4, -1.4, -3.1]
442+
]
443+
],
444+
color: 'red',
445+
radius: 0.07, // / 0.37302772291498865) * 2,
446+
headLength: 0.24,
447+
headWidth: 0.14,
448+
type: 'arrows',
449+
clickable: false
450+
},
451+
{
452+
positionPairs: [
453+
[
454+
[-2.1, -2.1, -2.1],
455+
[-0.1, -2.5, -1.1]
456+
]
457+
],
458+
color: 'green',
459+
radius: 0.07, // / 0.37302772291498865) * 2,
460+
headLength: 0.24, // / 0.37302772291498865,
461+
headWidth: 0.14, // 0.37302772291498865,
462+
type: 'arrows',
463+
clickable: false
464+
},
465+
{
466+
positionPairs: [
467+
[
468+
[-2.1, -2.1, -2.1],
469+
[-1.1, -1.1, -1.1]
470+
]
471+
],
472+
color: 'blue',
473+
radius: 0.07, // 0.37302772291498865) * 2,
474+
headLength: 0.24, // / 0.37302772291498865) * 2,
475+
headWidth: 0.14, // / 0.37302772291498865) * 2,
476+
type: 'arrows',
477+
clickable: false
478+
},
479+
{
480+
positions: [[-2.1, -2.1, -2.1]],
481+
color: 'black',
482+
radius: 0.0175,
483+
type: 'spheres',
484+
clickable: false
485+
}
486+
],
487+
visible: false
488+
}
489+
],
490+
origin: [-2.1, -2.1, -2.1],
491+
visible: true
492+
};
493+
494+
export const s2_old = {
223495
name: '_ct_StructureMoleculeComponent_1',
224496
contents: [
225497
{

src/components/data-display/SearchUI/SearchUIContextProvider/MatscholarSearchUIContextProvider.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,8 @@ export const MatscholarSearchUIContextProvider: React.FC<SearchState> = ({
234234
const params: any = preprocessQueryParams(
235235
{ ...query, ...props.apiEndpointParams },
236236
state.filterGroups,
237-
defaultQuery
237+
defaultQuery,
238+
''
238239
);
239240
params[props.fieldsKey] = fields;
240241

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// src/components/data-display/SearchUI/index.tsx

src/pages/CrystalStructureAnimationViewer/CrystalStructureAnimationViewer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ export const CrystalStructureAnimationViewer: React.FC = () => {
184184
extractAxis: false,
185185
zoomToFit2D: true
186186
}}
187-
//data={phonon_scene}
188-
data={phonon_position_scene}
187+
data={phonon_scene}
188+
// data={phonon_position_scene}
189189
sceneSize="100%"
190190
debug={false}
191191
toggleVisibility={{}}

0 commit comments

Comments
 (0)