mirror of
https://github.com/cypress-io/cypress.git
synced 2026-02-09 00:30:16 -06:00
* refactor record.js to extract upload logic into ts - streamlines the main uploadArtifact fn - extracts artifact specific logic to artifact classes - fully defines types for upload processing and reporting * tweak refactors so system tests produce same snapshots * some todos, fixes exports/imports from api/index.ts * fix api export so it can be imported by ts files * cleans up types * extracting artifact metadata from options logs to debug but does not throw if errors are encountered * fix type imports in print-run * fix debug formatting for artifacts * fix reporting successful protocol uploads * change inheritence to strategy * rm empty file * Update packages/server/lib/cloud/artifacts/upload_artifacts.ts * makes protocolManager optional to uploadArtifacts, fixes conditional accessor in protocol fatal error report * missed a potentially undef * convert to frozen object / keyof instead of string composition for artifact kinds --------- Co-authored-by: Ryan Manuel <ryanm@cypress.io> Co-authored-by: Jennifer Shehane <jennifer@cypress.io>
64 lines
1.9 KiB
JavaScript
64 lines
1.9 KiB
JavaScript
require('../../spec_helper')
|
|
|
|
const api = require('../../../lib/cloud/api').default
|
|
const cache = require('../../../lib/cache')
|
|
const user = require('../../../lib/cloud/user')
|
|
|
|
describe('lib/cloud/user', () => {
|
|
context('.get', () => {
|
|
it('calls cache.getUser', () => {
|
|
sinon.stub(cache, 'getUser').resolves({ name: 'brian' })
|
|
|
|
return user.get().then((user) => {
|
|
expect(user).to.deep.eq({ name: 'brian' })
|
|
})
|
|
})
|
|
})
|
|
|
|
context('.logOut', () => {
|
|
it('calls api.postLogout + removes the session from cache', () => {
|
|
sinon.stub(api, 'postLogout').withArgs('abc-123').resolves()
|
|
sinon.stub(cache, 'getUser').resolves({ name: 'brian', authToken: 'abc-123' })
|
|
sinon.spy(cache, 'removeUser')
|
|
|
|
return user.logOut().then(() => {
|
|
expect(cache.removeUser).to.be.calledOnce
|
|
})
|
|
})
|
|
|
|
it('does not send to api.postLogout without a authToken', () => {
|
|
sinon.spy(api, 'postLogout')
|
|
sinon.stub(cache, 'getUser').resolves({ name: 'brian' })
|
|
sinon.spy(cache, 'removeUser')
|
|
|
|
return user.logOut().then(() => {
|
|
expect(api.postLogout).not.to.be.called
|
|
|
|
expect(cache.removeUser).to.be.calledOnce
|
|
})
|
|
})
|
|
|
|
it('removes the session from cache even if api.postLogout rejects', () => {
|
|
sinon.stub(api, 'postLogout').withArgs('abc-123').rejects(new Error('ECONNREFUSED'))
|
|
sinon.stub(cache, 'getUser').resolves({ name: 'brian', authToken: 'abc-123' })
|
|
sinon.spy(cache, 'removeUser')
|
|
|
|
return user.logOut().catch(() => {
|
|
expect(cache.removeUser).to.be.calledOnce
|
|
})
|
|
})
|
|
})
|
|
|
|
context('.getBaseLoginUrl', () => {
|
|
it('calls api.getAuthUrls', () => {
|
|
sinon.stub(api, 'getAuthUrls').resolves({
|
|
'dashboardAuthUrl': 'https://github.com/login',
|
|
})
|
|
|
|
return user.getBaseLoginUrl().then((url) => {
|
|
expect(url).to.eq('https://github.com/login')
|
|
})
|
|
})
|
|
})
|
|
})
|