Skip to content

Commit

Permalink
Add data access control group test
Browse files Browse the repository at this point in the history
  • Loading branch information
snf2ye committed Dec 21, 2023
1 parent 6f67775 commit b830031
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 4 deletions.
47 changes: 47 additions & 0 deletions src/components/snapshot/DataAccessControlGroup.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { mount } from 'cypress/react';
import { Router } from 'react-router-dom';
import { ThemeProvider } from '@mui/styles';
import { Provider } from 'react-redux';
import React from 'react';
import createMockStore from 'redux-mock-store';
import history from '../../modules/hist';
import globalTheme from '../../modules/theme';
import SnapshotAccess from './SnapshotAccess';
import DataAccessControlGroup from './DataAccessControlGroup';

const snapshot = {
id: 'uuid',
};

const initialState = {
snapshots: {
snapshot,
snapshotAuthDomains: ['authdomain1', 'authdomain2', 'authdomain3'],
},
};

describe('DataAccessControlGroup', () => {
beforeEach(() => {
const mockStore = createMockStore([]);
const store = mockStore(initialState);
mount(
<Router history={history}>
<Provider store={store}>
<ThemeProvider theme={globalTheme}>
<DataAccessControlGroup />
</ThemeProvider>
</Provider>
</Router>,
);
});
it('Displays snapshot policies and emails', () => {
cy.get('[data-cy="data-access-control-container"]').should('contain.text', 'Data Access Control Groups');

Check failure on line 38 in src/components/snapshot/DataAccessControlGroup.test.tsx

View workflow job for this annotation

GitHub Actions / lint (16.x)

Replace `'contain.text',·'Data·Access·Control·Groups'` with `⏎······'contain.text',⏎······'Data·Access·Control·Groups',⏎····`
cy.get('[data-cy="data-access-controls"]')
.should('contain.text', 'Data Access Controls')
.within(() => {
cy.get('[data-cy="user-email"]').then((user) => {
cy.wrap(user[0]).should('contain.text', 'authdomain1');
});
});
});
});
6 changes: 2 additions & 4 deletions src/components/snapshot/DataAccessControlGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import React from 'react';
import { connect } from 'react-redux';
import _ from 'lodash';
import { withStyles } from '@mui/styles';
import { Typography, Grid } from '@mui/material';
import { TdrState } from '../../reducers';
import UserList from '../UserList';

const styles = () => ({});

Check failure on line 8 in src/components/snapshot/DataAccessControlGroup.tsx

View workflow job for this annotation

GitHub Actions / lint (16.x)

Delete `⏎`
type DataAccessControlGroupProps = {
authDomains: Array<string>;
Expand All @@ -15,7 +13,7 @@ type DataAccessControlGroupProps = {
function DataAccessControlGroup(props: DataAccessControlGroupProps) {
const { authDomains } = props;
return (
<Grid container spacing={1}>
<Grid container spacing={1} data-cy="data-access-control-container">
<Typography variant="h6">Data Access Control Groups</Typography>
<Grid item xs={12} data-cy="data-access-controls">
<UserList

Check failure on line 19 in src/components/snapshot/DataAccessControlGroup.tsx

View workflow job for this annotation

GitHub Actions / lint (16.x)

Replace `⏎··········canManageUsers={false}⏎··········typeOfUsers="Data·Access·Controls"⏎··········users={authDomains}⏎·······` with `·canManageUsers={false}·typeOfUsers="Data·Access·Controls"·users={authDomains}`
Expand All @@ -34,4 +32,4 @@ function mapStateToProps(state: TdrState) {
};
}

export default connect(mapStateToProps)(withStyles(styles)(DataAccessControlGroup));
export default connect(mapStateToProps)(DataAccessControlGroup);

0 comments on commit b830031

Please sign in to comment.