Skip to content

Commit

Permalink
fix(ProcessEditor): e.appendChild is not a function (#12613)
Browse files Browse the repository at this point in the history
* fix(ProcessEditor): typeNode.appendChild is not a function
  • Loading branch information
framitdavid authored Apr 4, 2024
1 parent 9aa95d5 commit cb2f905
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('ConfigContent', () => {
});
it('should render heading for selected task', () => {
renderConfigContent({
modelerRef: { current: '<div></div>' as unknown as Modeler },
modelerRef: { current: { get: () => {} } as unknown as Modeler },
bpmnDetails: { ...mockBpmnDetails, taskType: 'data' as BpmnTaskType },
});

Expand All @@ -68,7 +68,7 @@ describe('ConfigContent', () => {
it('should render helpText for selected task', async () => {
const user = userEvent.setup();
renderConfigContent({
modelerRef: { current: '<div></div>' as unknown as Modeler },
modelerRef: { current: { get: () => {} } as unknown as Modeler },
bpmnDetails: { ...mockBpmnDetails, taskType: 'data' as BpmnTaskType },
});

Expand All @@ -82,7 +82,7 @@ describe('ConfigContent', () => {

it('should render EditTaskId component', () => {
renderConfigContent({
modelerRef: { current: '<div></div>' as unknown as Modeler },
modelerRef: { current: { get: () => {} } as unknown as Modeler },
bpmnDetails: { ...mockBpmnDetails, taskType: 'data' as BpmnTaskType },
});

Expand All @@ -95,7 +95,7 @@ describe('ConfigContent', () => {
'should render correct header config for each taskType',
(taskType) => {
renderConfigContent({
modelerRef: { current: '<div></div>' as unknown as Modeler },
modelerRef: { current: { get: () => {} } as unknown as Modeler },
bpmnDetails: { ...mockBpmnDetails, taskType: taskType as BpmnTaskType },
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import { useBpmnConfigPanelFormContext } from '../../../../contexts/BpmnConfigPa
jest.mock('../../../../contexts/BpmnContext', () => ({
useBpmnContext: () => ({
modelerRef: {
current: '<div></div>',
current: {
get: () => ({
updateProperties: jest.fn(),
}),
},
},
setBpmnDetails: jest.fn(),
bpmnDetails: {
Expand All @@ -20,16 +24,6 @@ jest.mock('../../../../contexts/BpmnContext', () => ({
}),
}));

jest.mock('../../../../hooks/useBpmnModeler', () => ({
useBpmnModeler: () => ({
getModeler: () => ({
get: () => ({
updateProperties: jest.fn(),
}),
}),
}),
}));

jest.mock('../../../../contexts/BpmnConfigPanelContext', () => ({
useBpmnConfigPanelFormContext: jest.fn(),
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { KeyVerticalIcon } from '@studio/icons';
import { useBpmnContext } from '../../../../contexts/BpmnContext';

import { useBpmnConfigPanelFormContext } from '../../../../contexts/BpmnConfigPanelContext';
import { useBpmnModeler } from '../../../../hooks/useBpmnModeler';
import type Modeling from 'bpmn-js/lib/features/modeling/Modeling';

import classes from './EditTaskId.module.css';
Expand All @@ -16,10 +15,9 @@ export const EditTaskId = ({ ...rest }: EditTaskIdProps): React.ReactElement =>
const { t } = useTranslation();
const { bpmnDetails, modelerRef, setBpmnDetails } = useBpmnContext();
const { setMetaDataForm } = useBpmnConfigPanelFormContext();
const { getModeler } = useBpmnModeler();

const modeler = getModeler(modelerRef.current as unknown as HTMLDivElement);
const modeling: Modeling = modeler.get('modeling');
const modelerInstance = modelerRef.current;
const modeling: Modeling = modelerInstance.get('modeling');

const updateId = (value: string): void => {
modeling.updateProperties(bpmnDetails.element, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('ConfigPanel', () => {

it('should render ConfigPanel if bpmn type is task', () => {
renderConfigPanel({
modelerRef: { current: '' as unknown as Modeler },
modelerRef: { current: { get: () => {} } as unknown as Modeler },
bpmnDetails: { ...mockBpmnDetails, type: BpmnTypeEnum.Task },
});
const editTaskIdButton = screen.getByRole('button', {
Expand Down

0 comments on commit cb2f905

Please sign in to comment.