-
Notifications
You must be signed in to change notification settings - Fork 479
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39166 from code-dot-org/dtl_candidate_405a95f8
- Loading branch information
Showing
43 changed files
with
431 additions
and
203 deletions.
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
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
83 changes: 80 additions & 3 deletions
83
apps/test/unit/code-studio/components/header/SignInCalloutTest.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 |
---|---|---|
@@ -1,22 +1,99 @@ | ||
import React from 'react'; | ||
import SignInCalloutWrapper from '@cdo/apps/code-studio/components/header/SignInCalloutWrapper'; | ||
import {shallow} from 'enzyme'; | ||
import {shallow, mount} from 'enzyme'; | ||
import {expect} from '../../../../util/reconfiguredChai'; | ||
import i18n from '@cdo/locale'; | ||
|
||
const wrapper = shallow(<SignInCalloutWrapper />); | ||
import sinon from 'sinon'; | ||
import cookies from 'js-cookie'; | ||
|
||
describe('ViewPopup', () => { | ||
it('displays the correct background darkness', () => { | ||
const wrapper = shallow(<SignInCalloutWrapper />); | ||
wrapper.setState({hideCallout: false}); | ||
expect(wrapper.html().includes('opacity:0.5')).to.be.true; | ||
}); | ||
|
||
it('shows the correct header', () => { | ||
const wrapper = shallow(<SignInCalloutWrapper />); | ||
expect(wrapper.html().includes(i18n.notSignedInHeader())).to.be.true; | ||
}); | ||
|
||
it('shows the correct image', () => { | ||
const wrapper = shallow(<SignInCalloutWrapper />); | ||
expect(wrapper.html().includes('user-not-signed-in.png')).to.be.true; | ||
}); | ||
}); | ||
|
||
describe('Check popup does not appear when flag is set', () => { | ||
it('does not obscure the current view', () => { | ||
const wrapper = shallow(<SignInCalloutWrapper />); | ||
wrapper.setState({hideCallout: true}); | ||
expect(wrapper.html()).to.be.null; | ||
}); | ||
}); | ||
|
||
describe('Check cookies and session storage appear on click', () => { | ||
afterEach(() => { | ||
if (cookies.get.restore) { | ||
cookies.get.restore(); | ||
} | ||
if (cookies.set.restore) { | ||
cookies.set.restore(); | ||
} | ||
if (sessionStorage.getItem.restore) { | ||
sessionStorage.getItem.restore(); | ||
} | ||
if (sessionStorage.setItem.restore) { | ||
sessionStorage.setItem.restore(); | ||
} | ||
}); | ||
|
||
it('cookies appear when clicked', () => { | ||
const wrapper = mount(<SignInCalloutWrapper />); | ||
wrapper.setState({hideCallout: false}); | ||
var cookieSetStub = sinon.stub(cookies, 'set'); | ||
wrapper.find('.login-callout').simulate('click'); | ||
expect(cookieSetStub).to.have.been.calledWith( | ||
'hide_signin_callout', | ||
'true', | ||
{expires: 1, path: '/'} | ||
); | ||
}); | ||
|
||
it('session storage appears when clicked', () => { | ||
const wrapper = mount(<SignInCalloutWrapper />); | ||
wrapper.setState({hideCallout: false}); | ||
var sessionSetStub = sinon.stub(sessionStorage, 'setItem'); | ||
wrapper.find('.login-callout').simulate('click'); | ||
expect(sessionSetStub).to.have.been.calledWith( | ||
'hide_signin_callout', | ||
'true' | ||
); | ||
}); | ||
|
||
it('if cookie is set, callout does not appear', () => { | ||
const wrapper = mount(<SignInCalloutWrapper />); | ||
sinon | ||
.stub(cookies, 'get') | ||
.withArgs('hide_signin_callout') | ||
.returns('true'); | ||
expect(wrapper.html()).to.be.null; | ||
}); | ||
|
||
it('if session storage flag is set, callout does not appear', () => { | ||
const wrapper = mount(<SignInCalloutWrapper />); | ||
sinon | ||
.stub(sessionStorage, 'getItem') | ||
.withArgs('hide_signin_callout') | ||
.returns('true'); | ||
expect(wrapper.html()).to.be.null; | ||
}); | ||
|
||
it('shows prior to click, and dismisses after', () => { | ||
const wrapper = mount(<SignInCalloutWrapper />); | ||
wrapper.setState({hideCallout: false}); | ||
expect(wrapper.html().includes('uitest-signincallout')).to.be.true; | ||
wrapper.find('.login-callout').simulate('click'); | ||
expect(wrapper.html()).to.be.null; | ||
}); | ||
}); |
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
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
Oops, something went wrong.