Skip to content
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

Refine Cypress tests #496

Merged
merged 3 commits into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 9 additions & 6 deletions cypress/e2e/ifc-model/load-sample-model.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,29 @@ describe('sample models', () => {
cy.setCookie('isFirstTime', 'false')
cy.visit('/')
cy.get('#viewer-container').get('canvas').should('be.visible')

// Wait up to 15 seconds for IFC to finish loading
cy.get('[data-model-ready="true"]', {timeout: 15000}).should('exist')
})

it('should display tooltip when hovering', () => {
cy.get('form').findByRole('button', {name: /Open IFC/, timeout: 5000}).realHover()
cy.findByRole('button', {name: 'Open IFC'}).realHover()
cy.findByRole('tooltip').contains('Open IFC')
})

it('should display the sample models dialog', () => {
cy.get('form').findByRole('button', {name: /Open IFC/, timeout: 5000}).realClick()
cy.findByRole('button', {name: 'Open IFC'}).realClick()
cy.findByRole('dialog').contains('Sample Projects')
})

it('should load the Momentum model when selected', () => {
cy.get('form').findByRole('button', {name: /Open IFC/, timeout: 5000}).realClick()
cy.findByRole('button', {name: /Sample Projects/}).realClick()
cy.findByRole('button', {name: 'Open IFC'}).realClick()
cy.findByLabelText('Sample Projects').realClick()
cy.findByRole('listbox').within(() => {
cy.findByRole('option', {name: /Momentum/}).realClick()
cy.findByRole('option', {name: 'Momentum'}).realClick()
})
cy.findByRole('listbox').should('not.exist')
cy.findByRole('tree', {label: /IFC Navigator/})
cy.findByRole('tree', {label: 'IFC Navigator'})
cy.findByText('Momentum / KNIK v3', {timeout: 5000})
})
})
Expand Down
2 changes: 1 addition & 1 deletion src/Components/OpenModelControl.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function OpenModelControl({fileOpen}) {
setIsDialogDisplayed(true)
}}
color='primary'
value={'something'}
value={'Open IFC'}
>
<OpenIcon/>
</ToggleButton>
Expand Down
8 changes: 7 additions & 1 deletion src/Containers/CadView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export default function CadView({
const setSelectedElements = useStore((state) => state.setSelectedElements)
const setViewerStore = useStore((state) => state.setViewerStore)
const snackMessage = useStore((state) => state.snackMessage)
const [modelReady, setModelReady] = useState(false)


/* eslint-disable react-hooks/exhaustive-deps */
Expand Down Expand Up @@ -147,6 +148,9 @@ export default function CadView({
debug().warn('CadView#onViewer, viewer is null')
return
}

setModelReady(false)

// define mesh colors for selected and preselected element
const preselectMat = new MeshLambertMaterial({
transparent: true,
Expand All @@ -168,6 +172,8 @@ export default function CadView({
const tmpModelRef = await loadIfc(pathToLoad)
await onModel(tmpModelRef)
selectElementBasedOnFilepath(pathToLoad)

setModelReady(true)
}


Expand Down Expand Up @@ -451,7 +457,7 @@ export default function CadView({


return (
<div className={classes.root}>
<div className={classes.root} data-model-ready={modelReady}>
<div className={classes.view} id='viewer-container'></div>
<div className={classes.menusWrapper}>
<SnackBarMessage
Expand Down