Skip to content

Commit

Permalink
Merge branch 'develop' into controlledRerender
Browse files Browse the repository at this point in the history
  • Loading branch information
danielferro69 authored Jun 28, 2024
2 parents a42aa93 + bc826a4 commit 414272c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/components/blockly/PBBlocklyWorkspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const PBBlocklyWorkspace = ({ blockIds, categorized, sx, title, ...props
return (
<PBCard sx={{ ...sx }}>
{title && <Typography>{t('preview')}</Typography>}
<Box width="100%" height="100%" ref={setBlocklyContainer} className="blockly" />
<Box width="100%" height="100%" ref={setBlocklyContainer} data-testid='pb-blockly' className="blockly" />
</PBCard>
)
}
Expand Down
1 change: 1 addition & 0 deletions src/components/blockly/blockly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1483,5 +1483,6 @@ export const setXml = (xml: string ) => {

export const setupBlockly = (container: Element, workspaceConfiguration: Blockly.BlocklyOptions) => {
container.replaceChildren() //Removes previous injection, otherwise it might keep inserting below the current workspace
container.ariaValueText = 'child-blockly'
Blockly.inject(container, workspaceConfiguration)
}
16 changes: 7 additions & 9 deletions src/test/Creator/ToolboxPreview.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ import { ToolboxPreview } from '../../components/creator/Editor/ChallengeDetails
import { commonBlocks, sceneBlocks } from '../../components/blockly/blocks';

describe('Toolbox Preview', () => {
test.skip('rendering toolbox preview ', async () => {
test('rendering toolbox preview ', async () => {
const toolBoxItems = [...commonBlocks.map((block => block.id)), ...sceneBlocks.map((block => block.id))]
renderComponent(<ToolboxPreview blockIds={toolBoxItems} categorized={false} />);
const idPBBlockly = await screen.findByTestId('pb-blockly')
expect(idPBBlockly).toBeInTheDocument()
expect(idPBBlockly.firstChild).toHaveClass('injectionDiv')
});

const toolBoxItems = [...commonBlocks.map((block => block.id)), ...sceneBlocks.map((block => block.id))]

renderComponent(<ToolboxPreview blockIds={toolBoxItems} categorized={false}/>)

const blocks = await screen.findByTestId(toolBoxItems.join(","))

expect(blocks).toBeInTheDocument()
})
})

0 comments on commit 414272c

Please sign in to comment.