-
Notifications
You must be signed in to change notification settings - Fork 247
fix(test): deflake diagram-editor tests COMPASS-9462 #7030
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
a245cd8
7f1d021
8442b34
9569384
2757c9c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import React, { useMemo, useState } from 'react'; | ||
| import React, { useCallback, useMemo, useRef, useState } from 'react'; | ||
| import { connect } from 'react-redux'; | ||
| import type { DataModelingState } from '../store/reducer'; | ||
| import { | ||
|
|
@@ -27,6 +27,7 @@ import { | |
| Diagram, | ||
| type NodeProps, | ||
| type EdgeProps, | ||
| useDiagram, | ||
| } from '@mongodb-js/diagramming'; | ||
| import type { Edit, StaticModel } from '../services/data-model-storage'; | ||
| import { UUID } from 'bson'; | ||
|
|
@@ -132,6 +133,20 @@ const DiagramEditor: React.FunctionComponent<{ | |
| onApplyClick, | ||
| }) => { | ||
| const isDarkMode = useDarkMode(); | ||
| const diagramContainerRef = useRef<HTMLDivElement | null>(null); | ||
| const diagram = useDiagram(); | ||
|
|
||
| const setDiagramContainerRef = useCallback( | ||
| (ref: HTMLDivElement) => { | ||
| if (ref) { | ||
| // For debugging purposes, we attach the diagram to the ref. | ||
| (ref as any)._diagram = diagram; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we could limit this to
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, i did that in my last PR and Sergey suggested we try this (ref) approach or the one we already have (validate what user actually sees). The one we have is failing (don't really know why, but my guess is that we are currently doing random positioning and once we have that done this may not be the issue anymore), so i am using ref approach in this PR. We also do this in codemirror to access current instance in e2e. |
||
| } | ||
| diagramContainerRef.current = ref; | ||
| }, | ||
| [diagram] | ||
| ); | ||
|
|
||
| const [applyInput, setApplyInput] = useState('{}'); | ||
|
|
||
| const isEditValid = useMemo(() => { | ||
|
|
@@ -265,6 +280,7 @@ const DiagramEditor: React.FunctionComponent<{ | |
| if (step === 'EDITING') { | ||
| content = ( | ||
| <div | ||
| ref={setDiagramContainerRef} | ||
| className={modelPreviewContainerStyles} | ||
| data-testid="diagram-editor-container" | ||
| > | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.