-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'refs/heads/develop' into gr-DT-979-appcues
# Conflicts: # src/components/SignInButton.tsx
- Loading branch information
Showing
16 changed files
with
361 additions
and
84 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
cypress/component/DataSearch/dataset_search_footer.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 |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* eslint-disable no-undef */ | ||
import {mount} from 'cypress/react'; | ||
import {React} from 'react'; | ||
import {DatasetSearchFooter} from '../../../src/components/data_search/DatasetSearchFooter'; | ||
|
||
const datasets = [ | ||
{ | ||
datasetId: 123456, | ||
study: { | ||
studyId: 1, | ||
} | ||
}, | ||
{ | ||
datasetId: 234567, | ||
study: { | ||
studyId: 1, | ||
} | ||
}, | ||
{ | ||
datasetId: 345678, | ||
study: { | ||
studyId: 2, | ||
} | ||
}, | ||
]; | ||
|
||
const oneDatasetProps = { | ||
selectedDatasets: [123456], | ||
datasets: datasets, | ||
onClick: () => {}, | ||
}; | ||
|
||
const oneStudyProps = { | ||
selectedDatasets: [123456, 234567], | ||
datasets: datasets, | ||
onClick: () => {}, | ||
}; | ||
|
||
const twoStudiesProps = { | ||
selectedDatasets: [123456, 234567, 345678], | ||
datasets: datasets, | ||
onClick: () => {}, | ||
}; | ||
|
||
describe('Dataset Search Footer renders correct text and button', () => { | ||
|
||
it('Shows button and single dataset and study text', () => { | ||
mount(<DatasetSearchFooter {...oneDatasetProps} />); | ||
cy.contains('1 dataset selected from 1 study'); | ||
cy.contains('Apply for Access'); | ||
}); | ||
|
||
|
||
it('Shows button and two datasets from one study text', () => { | ||
mount(<DatasetSearchFooter {...oneStudyProps} />); | ||
cy.contains('2 datasets selected from 1 study'); | ||
cy.contains('Apply for Access'); | ||
}); | ||
|
||
it('Shows button and three datasets from two studies text', () => { | ||
mount(<DatasetSearchFooter {...twoStudiesProps} />); | ||
cy.contains('3 datasets selected from 2 studies'); | ||
cy.contains('Apply for Access'); | ||
}); | ||
}); |
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,43 @@ | ||
/* eslint-disable no-undef */ | ||
import {React} from 'react'; | ||
import {mount} from 'cypress/react'; | ||
import DatasetSearchTable from '../../../src/components/data_search/DatasetSearchTable'; | ||
import {TerraDataRepo} from '../../../src/libs/ajax/TerraDataRepo'; | ||
|
||
const datasets = [ | ||
{ | ||
datasetId: 123456, | ||
datasetIdentifier: `DUOS-123456`, | ||
datasetName: 'Some Dataset 1', | ||
study: { | ||
studyId: 1, | ||
dataCustodianEmail: ['Some Data Custodian Email 1'], | ||
} | ||
} | ||
]; | ||
|
||
const props = { | ||
datasets: datasets, | ||
history: {} | ||
}; | ||
|
||
describe('Dataset Search Table tests', () => { | ||
|
||
describe('Data library with three datasets', () => { | ||
beforeEach(() => { | ||
cy.stub(TerraDataRepo, 'listSnapshotsByDatasetIds').returns({}); | ||
mount(<DatasetSearchTable {...props} />); | ||
}); | ||
|
||
it('When no datasets are selected the footer does not appear', () => { | ||
cy.contains('1 dataset selected from 1 study').should('not.exist'); | ||
}); | ||
|
||
|
||
it('When a dataset is selected the footer appears', () => { | ||
cy.get('#header-checkbox').click(); | ||
cy.contains('1 dataset selected from 1 study'); | ||
}); | ||
|
||
}); | ||
}); |
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 |
---|---|---|
|
@@ -10,12 +10,18 @@ import {Metrics} from '../../../src/libs/ajax/Metrics'; | |
import {StackdriverReporter} from '../../../src/libs/stackdriverReporter'; | ||
import {ToS} from '../../../src/libs/ajax/ToS'; | ||
import {mockOidcUser} from '../Auth/mockOidcUser'; | ||
|
||
const signInText = 'Sign In'; | ||
|
||
const duosUser = { | ||
displayName: 'display name', | ||
email: '[email protected]', | ||
isAdmin: true, | ||
isAlumni: false, | ||
isChairPerson: false, | ||
isDataSubmitter: false, | ||
isMember: false, | ||
isResearcher: false, | ||
isSigningOfficial: false, | ||
roles: [{ | ||
name: 'Admin' | ||
}] | ||
|
@@ -33,6 +39,11 @@ const notAcceptedUserStatus = Object.assign({}, userStatus, {'tosAccepted': fals | |
|
||
describe('Sign In: Component Loads', function () { | ||
|
||
// Intercept configuration calls | ||
beforeEach(() => { | ||
cy.initApplicationConfig(); | ||
}); | ||
|
||
it('Sign In Button Loads', function () { | ||
cy.viewport(600, 300); | ||
mount(<SignInButton history={undefined}/>); | ||
|
@@ -42,14 +53,15 @@ describe('Sign In: Component Loads', function () { | |
it('Sign In: On Success', function () { | ||
cy.viewport(600, 300); | ||
cy.stub(Auth, 'signIn').returns(Promise.resolve(mockOidcUser)); | ||
cy.stub(User, 'getMe').returns(duosUser); | ||
cy.intercept({method: 'GET', url: '**/api/user/me'}, {statusCode: 200, body: duosUser}).as('getMe'); | ||
cy.stub(StackdriverReporter, 'report'); | ||
cy.stub(Metrics, 'identify'); | ||
cy.stub(Metrics, 'syncProfile'); | ||
cy.stub(Metrics, 'captureEvent'); | ||
cy.stub(ToS, 'getStatus').returns(userStatus); | ||
mount(<SignInButton history={[]}/>); | ||
cy.get('button').click().then(() => { | ||
cy.get('button').click(); | ||
cy.wait('@getMe').then(() => { | ||
expect(Storage.getCurrentUser()).to.deep.equal(duosUser); | ||
expect(Storage.getAnonymousId()).to.not.be.null; | ||
expect(StackdriverReporter.report).to.not.be.called; | ||
|
@@ -63,29 +75,31 @@ describe('Sign In: Component Loads', function () { | |
const bareUser = {email: '[email protected]'}; | ||
cy.viewport(600, 300); | ||
cy.stub(Auth, 'signIn').returns(Promise.resolve(mockOidcUser)); | ||
cy.stub(User, 'getMe').returns(bareUser); | ||
cy.intercept({method: 'GET', url: '**/api/user/me'}, {statusCode: 200, body: bareUser}).as('getMe'); | ||
cy.stub(StackdriverReporter, 'report'); | ||
cy.stub(Metrics, 'identify'); | ||
cy.stub(Metrics, 'syncProfile'); | ||
cy.stub(Metrics, 'captureEvent'); | ||
cy.stub(ToS, 'getStatus').returns(userStatus); | ||
mount(<SignInButton history={[]}/>); | ||
cy.get('button').click().then(() => { | ||
cy.get('button').click(); | ||
cy.wait('@getMe').then(() => { | ||
expect(StackdriverReporter.report).to.be.called; | ||
}); | ||
}); | ||
|
||
it('Sign In: Redirects to ToS if not accepted', function () { | ||
cy.viewport(600, 300); | ||
cy.stub(Auth, 'signIn').returns(Promise.resolve(mockOidcUser)); | ||
cy.stub(User, 'getMe').returns(duosUser); | ||
cy.intercept({method: 'GET', url: '**/api/user/me'}, {statusCode: 200, body: duosUser}).as('getMe'); | ||
cy.stub(ToS, 'getStatus').returns(notAcceptedUserStatus); | ||
cy.stub(Metrics, 'identify'); | ||
cy.stub(Metrics, 'syncProfile'); | ||
cy.stub(Metrics, 'captureEvent'); | ||
let history = []; | ||
mount(<SignInButton history={history}/>); | ||
cy.get('button').click().then(() => { | ||
cy.get('button').click(); | ||
cy.wait('@getMe').then(() => { | ||
expect(history).to.not.be.empty; | ||
expect(history[0].includes('tos_acceptance')).to.be.true; | ||
}); | ||
|
@@ -96,15 +110,15 @@ describe('Sign In: Component Loads', function () { | |
cy.stub(Auth, 'signIn').returns(Promise.resolve(mockOidcUser)); | ||
// Simulate user not found | ||
cy.stub(User, 'getMe').throws(); | ||
cy.stub(User, 'registerUser').returns(duosUser); | ||
cy.intercept({method: 'POST', url: '**/api/user'}, {statusCode: 200, body: duosUser}).as('registerUser'); | ||
cy.stub(ToS, 'getStatus').returns(notAcceptedUserStatus); | ||
cy.stub(Metrics, 'identify'); | ||
cy.stub(Metrics, 'syncProfile'); | ||
cy.stub(Metrics, 'captureEvent'); | ||
let history = []; | ||
mount(<SignInButton history={history}/>); | ||
cy.get('button').click().then(() => { | ||
expect(User.registerUser).to.be.called; | ||
cy.get('button').click(); | ||
cy.wait('@registerUser').then(() => { | ||
expect(history).to.not.be.empty; | ||
expect(history[0].includes('tos_acceptance')).to.be.true; | ||
}); | ||
|
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,50 @@ | ||
/* eslint-disable no-undef */ | ||
|
||
import {mount} from 'cypress/react'; | ||
import React from 'react'; | ||
import {Storage} from '../../../src/libs/storage'; | ||
import {User} from '../../../src/libs/ajax/User'; | ||
import {Institution} from '../../../src/libs/ajax/Institution'; | ||
import UserProfile from '../../../src/pages/user_profile/UserProfile'; | ||
|
||
const duosUser = { | ||
isSigningOfficial: false, | ||
}; | ||
|
||
describe('User Profile', () => { | ||
// Intercept configuration calls | ||
beforeEach(() => { | ||
cy.intercept({ | ||
method: 'GET', | ||
url: '/config.json', | ||
hostname: 'localhost', | ||
}, {'env': 'ci'}); | ||
}); | ||
|
||
it('Renders the user profile page', () => { | ||
cy.stub(Storage, 'getCurrentUser').returns(duosUser); | ||
cy.stub(Institution, 'list').returns([]); | ||
cy.stub(User, 'getMe').returns(duosUser); | ||
cy.stub(User, 'getApprovedDatasets').returns([]); | ||
cy.stub(User, 'getAcknowledgements').returns({}); | ||
mount(<UserProfile/>); | ||
cy.get('h2').should('contain', 'Your Profile'); | ||
}); | ||
|
||
it('Updates the user email preferences', () => { | ||
cy.stub(Storage, 'getCurrentUser').returns(duosUser); | ||
cy.stub(Institution, 'list').returns([]); | ||
cy.stub(User, 'getMe').returns(duosUser); | ||
cy.stub(User, 'getApprovedDatasets').returns([]); | ||
cy.stub(User, 'getAcknowledgements').returns({}); | ||
cy.intercept( | ||
{method: 'PUT', url: '**/user'}, | ||
{statusCode: 200, body: duosUser} | ||
).as('updateSelf'); | ||
mount(<UserProfile/>); | ||
cy.get('input[id="profileEmailEnabled_yes"]').check(); | ||
cy.wait('@updateSelf').then(() => { | ||
cy.get('div').contains('Email preference updated successfully!'); | ||
}); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import {Styles} from '../../libs/theme'; | ||
|
||
export const styles = { | ||
baseStyle: { | ||
fontFamily: 'Montserrat', | ||
fontSize: '1.6rem', | ||
fontWeight: 400, | ||
display: 'flex', | ||
padding: '1rem 2%', | ||
justifyContent: 'space-between', | ||
alignItems: 'center', | ||
whiteSpace: 'pre-wrap', | ||
backgroundColor: 'white', | ||
border: '1px solid #DEDEDE', | ||
borderRadius: '4px', | ||
margin: '0.5% 0' | ||
}, | ||
columnStyle: Object.assign({}, Styles.TABLE.HEADER_ROW, { | ||
justifyContent: 'space-between', | ||
color: '#7B7B7B', | ||
fontFamily: 'Montserrat', | ||
fontSize: '1.2rem', | ||
fontWeight: 'bold', | ||
letterSpacing: '0.2px', | ||
textTransform: 'uppercase', | ||
backgroundColor: 'B8CDD3', | ||
border: 'none' | ||
}), | ||
cellWidths: { | ||
duosId: '10%', | ||
phsId: '10%', | ||
datasetName: '15%', | ||
studyName: '15%', | ||
dataSubmitter: '15%', | ||
dataCustodian: '15%', | ||
dataUse: '10%', | ||
status: '10%' | ||
}, | ||
color: { | ||
dataUseGroup: '#000000', | ||
votes: '#000000', | ||
numberOfDatasets: '#000000', | ||
datasets: '#000000', | ||
}, | ||
fontSize: { | ||
dataUseGroup: '1.4rem', | ||
votes: '1.4rem', | ||
numberOfDatasets: '1.4rem', | ||
datasets: '1.4rem', | ||
}, | ||
}; |
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
Oops, something went wrong.