-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathuser_profile.spec.jsx
43 lines (39 loc) · 1.45 KB
/
user_profile.spec.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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', () => {
beforeEach(() => {
cy.initApplicationConfig();
});
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!');
});
});
});