mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	feature: Add support for permission system in unleash frontend
add a test for feature-list-item without permission
This commit is contained in:
		
							parent
							
								
									aad612d3d6
								
							
						
					
					
						commit
						7740a9abe9
					
				| @ -55,3 +55,59 @@ exports[`renders correctly with one feature 1`] = ` | ||||
|   <span /> | ||||
| </react-mdl-ListItem> | ||||
| `; | ||||
| 
 | ||||
| exports[`renders correctly with one feature without permission 1`] = ` | ||||
| <react-mdl-ListItem | ||||
|   twoLine={true} | ||||
| > | ||||
|   <span | ||||
|     className="listItemMetric" | ||||
|   > | ||||
|     <svg | ||||
|       className="mdl-color-text--grey-300" | ||||
|       viewBox="0 0 24 24" | ||||
|     > | ||||
|       <path | ||||
|         d="M17.3,18C19,16.5 20,14.4 20,12A8,8 0 0,0 12,4A8,8 0 0,0 4,12C4,14.4 5,16.5 6.7,18C8.2,16.7 10,16 12,16C14,16 15.9,16.7 17.3,18M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1 12,2M7,9A1,1 0 0,1 8,10A1,1 0 0,1 7,11A1,1 0 0,1 6,10A1,1 0 0,1 7,9M10,6A1,1 0 0,1 11,7A1,1 0 0,1 10,8A1,1 0 0,1 9,7A1,1 0 0,1 10,6M17,9A1,1 0 0,1 18,10A1,1 0 0,1 17,11A1,1 0 0,1 16,10A1,1 0 0,1 17,9M14.4,6.1C14.9,6.3 15.1,6.9 15,7.4L13.6,10.8C13.8,11.1 14,11.5 14,12A2,2 0 0,1 12,14A2,2 0 0,1 10,12C10,11 10.7,10.1 11.7,10L13.1,6.7C13.3,6.1 13.9,5.9 14.4,6.1Z" | ||||
|         fill="currentColor" | ||||
|       /> | ||||
|     </svg> | ||||
|   </span> | ||||
|   <span | ||||
|     className="listItemToggle" | ||||
|   > | ||||
|     <react-mdl-Switch | ||||
|       checked={false} | ||||
|       disabled={true} | ||||
|       onChange={[Function]} | ||||
|       title="Toggle Another" | ||||
|     /> | ||||
|   </span> | ||||
|   <span | ||||
|     className="mdl-list__item-primary-content listItemLink" | ||||
|   > | ||||
|     <a | ||||
|       className="listLink truncate" | ||||
|       href="/features/strategies/Another" | ||||
|       onClick={[Function]} | ||||
|     > | ||||
|       Another | ||||
|       <span | ||||
|         className="mdl-list__item-sub-title truncate" | ||||
|       > | ||||
|         another's description | ||||
|       </span> | ||||
|     </a> | ||||
|   </span> | ||||
|   <span | ||||
|     className="listItemStrategies hideLt920" | ||||
|   > | ||||
|     <react-mdl-Chip | ||||
|       className="strategyChip" | ||||
|     > | ||||
|       gradualRolloutRandom | ||||
|     </react-mdl-Chip> | ||||
|   </span> | ||||
|   <span /> | ||||
| </react-mdl-ListItem> | ||||
| `; | ||||
|  | ||||
| @ -45,3 +45,40 @@ test('renders correctly with one feature', () => { | ||||
| 
 | ||||
|     expect(tree).toMatchSnapshot(); | ||||
| }); | ||||
| 
 | ||||
| test('renders correctly with one feature without permission', () => { | ||||
|     const feature = { | ||||
|         name: 'Another', | ||||
|         description: "another's description", | ||||
|         enabled: false, | ||||
|         strategies: [ | ||||
|             { | ||||
|                 name: 'gradualRolloutRandom', | ||||
|                 parameters: { | ||||
|                     percentage: 50, | ||||
|                 }, | ||||
|             }, | ||||
|         ], | ||||
|         createdAt: '2018-02-04T20:27:52.127Z', | ||||
|     }; | ||||
|     const store = { user: new $Map({ profile: { permissions: [] } }) }; | ||||
|     const featureMetrics = { lastHour: {}, lastMinute: {}, seenApps: {} }; | ||||
|     const settings = { sort: 'name' }; | ||||
|     const tree = renderer.create( | ||||
|         <Provider store={createStore(state => state, store)}> | ||||
|             <MemoryRouter> | ||||
|                 <Feature | ||||
|                     key={0} | ||||
|                     settings={settings} | ||||
|                     metricsLastHour={featureMetrics.lastHour[feature.name]} | ||||
|                     metricsLastMinute={featureMetrics.lastMinute[feature.name]} | ||||
|                     feature={feature} | ||||
|                     toggleFeature={jest.fn()} | ||||
|                 /> | ||||
|             </MemoryRouter> | ||||
|         </Provider> | ||||
|     ); | ||||
| 
 | ||||
|     expect(tree).toMatchSnapshot(); | ||||
| }); | ||||
| 
 | ||||
|  | ||||
| @ -99,7 +99,6 @@ Feature.propTypes = { | ||||
|     metricsLastHour: PropTypes.object, | ||||
|     metricsLastMinute: PropTypes.object, | ||||
|     revive: PropTypes.func, | ||||
|     updateable: PropTypes.bool, | ||||
| }; | ||||
| 
 | ||||
| export default Feature; | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user