generated from eea/volto-addon-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed progress flow closes on click outside
- Loading branch information
Alex Medesan
committed
Apr 12, 2021
1 parent
d180257
commit f2cc442
Showing
3 changed files
with
195 additions
and
5 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
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 |
---|---|---|
@@ -0,0 +1,165 @@ | ||
// ✓ ca nu crapa la obiect gol | ||
// ca nu crapa fara procent | ||
// daca vine cum trebuie vedem procent, titlu, sidebar progress tracker | ||
// ca nu face nimic daca nu e pe ce ruta trebuie | ||
// ca nu face nimic daca nu e logat userul | ||
// ca nu face nimic daca nu exista toolbar | ||
|
||
import React from 'react'; | ||
import { Provider } from 'react-intl-redux'; | ||
import { MemoryRouter } from 'react-router-dom'; | ||
import renderer from 'react-test-renderer'; | ||
import configureStore from 'redux-mock-store'; | ||
import ProgressWorkflow from './ProgressWorkflow'; | ||
|
||
const mockStore = configureStore(); | ||
const props = { content: { review_state: 'pending' }, pathname: '/' }; | ||
const propsEmpty = {}; | ||
|
||
describe('ProgressWorkflow', () => { | ||
it('renders the ProgressWorkflow component without breaking if props and workflow are empty', () => { | ||
const store = mockStore({ | ||
intl: { | ||
locale: 'en', | ||
messages: {}, | ||
}, | ||
workflowProgress: {}, | ||
}); | ||
const component = renderer.create( | ||
<Provider store={store}> | ||
<MemoryRouter> | ||
<ProgressWorkflow | ||
pathname="/test" | ||
{...propsEmpty} | ||
hasToolbar={true} | ||
/> | ||
</MemoryRouter> | ||
</Provider>, | ||
); | ||
const json = component.toJSON(); | ||
expect(json).toMatchSnapshot(); | ||
}); | ||
|
||
it('renders the ProgressWorkflow component', () => { | ||
const store = mockStore({ | ||
intl: { | ||
locale: 'en', | ||
messages: {}, | ||
}, | ||
workflowProgress: { | ||
'@id': 'http://localhost:3000/api/my-page/@workflow.progress', | ||
done: 50, | ||
steps: [ | ||
[ | ||
['private'], | ||
25, | ||
['Private'], | ||
['Can only be seen and edited by the owner.'], | ||
], | ||
[ | ||
['pending'], | ||
50, | ||
['Pending review'], | ||
['Waiting to be reviewed, not editable by the owner.'], | ||
], | ||
[ | ||
['review_one', 'review_two', 'review_three', 'review_four'], | ||
75, | ||
[ | ||
'Review One: Technical', | ||
'Review two: Head of Technical', | ||
'Review three: Head of Department', | ||
'Review Four: CTO', | ||
], | ||
[ | ||
'Review One: Technical', | ||
'Review by Head of Tech Depart', | ||
'Review by Head of Department', | ||
'Review by CTO', | ||
], | ||
], | ||
[ | ||
['published', 'visible'], | ||
100, | ||
['Published', 'Public draft'], | ||
[ | ||
'Visible to everyone, not editable by the owner.', | ||
'Visible to everyone, but not approved by the reviewers.', | ||
], | ||
], | ||
], | ||
}, | ||
}); | ||
const component = renderer.create( | ||
<Provider store={store}> | ||
<MemoryRouter> | ||
<ProgressWorkflow pathname="/test" {...props} hasToolbar={true} /> | ||
</MemoryRouter> | ||
</Provider>, | ||
); | ||
const json = component.toJSON(); | ||
expect(json).toMatchSnapshot(); | ||
}); | ||
|
||
it('renders the ProgressWorkflow component with Percent showing correct value', () => { | ||
const store = mockStore({ | ||
intl: { | ||
locale: 'en', | ||
messages: {}, | ||
}, | ||
workflowProgress: { | ||
'@id': 'http://localhost:3000/api/my-page/@workflow.progress', | ||
done: 50, | ||
steps: [ | ||
[ | ||
['private'], | ||
25, | ||
['Private'], | ||
['Can only be seen and edited by the owner.'], | ||
], | ||
[ | ||
['pending'], | ||
50, | ||
['Pending review'], | ||
['Waiting to be reviewed, not editable by the owner.'], | ||
], | ||
[ | ||
['review_one', 'review_two', 'review_three', 'review_four'], | ||
75, | ||
[ | ||
'Review One: Technical', | ||
'Review two: Head of Technical', | ||
'Review three: Head of Department', | ||
'Review Four: CTO', | ||
], | ||
[ | ||
'Review One: Technical', | ||
'Review by Head of Tech Depart', | ||
'Review by Head of Department', | ||
'Review by CTO', | ||
], | ||
], | ||
[ | ||
['published', 'visible'], | ||
100, | ||
['Published', 'Public draft'], | ||
[ | ||
'Visible to everyone, not editable by the owner.', | ||
'Visible to everyone, but not approved by the reviewers.', | ||
], | ||
], | ||
], | ||
}, | ||
}); | ||
const component = renderer.create( | ||
<Provider store={store}> | ||
<MemoryRouter> | ||
<ProgressWorkflow pathname="/test" {...props} hasToolbar={true} /> | ||
</MemoryRouter> | ||
</Provider>, | ||
); | ||
|
||
const json = component.toJSON(); | ||
expect(json).toMatchSnapshot(); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`ProgressWorkflow renders the ProgressWorkflow component 1`] = `null`; | ||
|
||
exports[`ProgressWorkflow renders the ProgressWorkflow component with Percent showing correct value 1`] = `null`; | ||
|
||
exports[`ProgressWorkflow renders the ProgressWorkflow component without breaking if props and workflow are empty 1`] = `null`; |