-
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.
[DT-744] Add option to modify email preferences (#2717)
- Loading branch information
Showing
2 changed files
with
81 additions
and
1 deletion.
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
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