-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Annotate Button only shows for Drawing Workflows
- Loading branch information
Showing
5 changed files
with
91 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 46 additions & 25 deletions
71
...ges/lib-classifier/src/components/Classifier/components/ImageToolbar/ImageToolbar.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,55 @@ | ||
import { render } from '@testing-library/react' | ||
import zooTheme from '@zooniverse/grommet-theme' | ||
import { Grommet } from 'grommet' | ||
import { render, screen } from '@testing-library/react' | ||
import { Provider } from 'mobx-react' | ||
|
||
import mockStore from '@test/mockStore/mockStore.js' | ||
import { DrawingTaskFactory, SingleChoiceTaskFactory, WorkflowFactory } from '@test/factories' | ||
|
||
import mockStore from '@test/mockStore/mockStore.js' | ||
import ImageToolbar from './ImageToolbar' | ||
|
||
describe('Component > ImageToolbar', function () { | ||
function withStore() { | ||
return function Wrapper({ | ||
children = null, | ||
store = mockStore() | ||
}) { | ||
return ( | ||
<Grommet theme={zooTheme}> | ||
<Provider classifierStore={store}> | ||
{children} | ||
</Provider> | ||
</Grommet> | ||
) | ||
} | ||
} | ||
|
||
it('should render without crashing', function () { | ||
it('should render with the annotate button', function () { | ||
// Create minimal store with drawing task | ||
const store = mockStore({ | ||
workflow: WorkflowFactory.build({ | ||
tasks: { | ||
T1: DrawingTaskFactory.build(), | ||
} | ||
}) | ||
}) | ||
|
||
// SubjectViewerStore.afterAttach() reaction needs to be called manually | ||
// This is because the mockStore is not a real store, so it does not have the afterAttach() reaction | ||
store.subjectViewer.setAnnotateVisibility(store.workflowSteps.hasAnnotateTask); | ||
|
||
render( | ||
<ImageToolbar />, | ||
{ | ||
wrapper: withStore() | ||
} | ||
) | ||
<Provider classifierStore={store}> | ||
<ImageToolbar /> | ||
</Provider> | ||
); | ||
|
||
expect(screen.queryByLabelText('ImageToolbar.AnnotateButton.ariaLabel')).to.exist() | ||
}) | ||
|
||
it('should render without the annotate button', function () { | ||
// Create minimal store without drawing task | ||
const store = mockStore({ | ||
workflow: WorkflowFactory.build({ | ||
tasks: { | ||
T1: SingleChoiceTaskFactory.build(), | ||
} | ||
}) | ||
}) | ||
|
||
// SubjectViewerStore.afterAttach() reaction needs to be called manually | ||
// This is because the mockStore is not a real store, so it does not have the afterAttach() reaction | ||
store.subjectViewer.setAnnotateVisibility(store.workflowSteps.hasAnnotateTask); | ||
|
||
render( | ||
<Provider classifierStore={store}> | ||
<ImageToolbar /> | ||
</Provider> | ||
); | ||
|
||
expect(screen.queryByLabelText('ImageToolbar.AnnotateButton.ariaLabel')).to.be.null() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters