refactor: remove unused cloud routes (#25584)

* chore: remove unused cloud routes

* remove project references in unit tests

Co-authored-by: Emily Rohrbough <emilyrohrbough@users.noreply.github.com>
This commit is contained in:
Tim Griesser
2023-01-26 10:54:11 -05:00
committed by GitHub
parent ed8786b6c3
commit 1d8d2f9787
4 changed files with 0 additions and 165 deletions
-53
View File
@@ -13,8 +13,6 @@ const machineId = require('./machine_id')
const errors = require('../errors')
const { apiRoutes } = require('./routes')
import type Bluebird from 'bluebird'
const THIRTY_SECONDS = humanInterval('30 seconds')
const SIXTY_SECONDS = humanInterval('60 seconds')
const TWO_MINUTES = humanInterval('2 minutes')
@@ -176,16 +174,6 @@ module.exports = {
.catch(tagError)
},
getMe (authToken): Bluebird<any> {
return rp.get({
url: apiRoutes.me(),
json: true,
auth: {
bearer: authToken,
},
})
},
getAuthUrls () {
return rp.get({
url: apiRoutes.auth(),
@@ -198,20 +186,6 @@ module.exports = {
.catch(tagError)
},
getProject (projectId, authToken) {
return rp.get({
url: apiRoutes.project(projectId),
json: true,
auth: {
bearer: authToken,
},
headers: {
'x-route-version': '2',
},
})
.catch(tagError)
},
createRun (options: CreateRunOptions) {
return retryWithBackoff((attemptIndex) => {
const body = {
@@ -374,33 +348,6 @@ module.exports = {
)
},
createProject (projectDetails, remoteOrigin, authToken) {
debug('create project with args %o', {
projectDetails,
remoteOrigin,
authToken,
})
return rp.post({
url: apiRoutes.projects(),
json: true,
auth: {
bearer: authToken,
},
headers: {
'x-route-version': '2',
},
body: {
name: projectDetails.projectName,
orgId: projectDetails.orgId,
public: projectDetails.public,
remoteOrigin,
},
})
.catch(RequestErrors.StatusCodeError, formatResponseBody)
.catch(tagError)
},
clearCache () {
responseCache = {}
},
-3
View File
@@ -7,15 +7,12 @@ const apiUrl = app_config[process.env.CYPRESS_CONFIG_ENV || process.env.CYPRESS_
const CLOUD_ENDPOINTS = {
api: '',
auth: 'auth',
me: 'me',
ping: 'ping',
runs: 'runs',
instances: 'runs/:id/instances',
instanceTests: 'instances/:id/tests',
instanceResults: 'instances/:id/results',
instanceStdout: 'instances/:id/stdout',
projects: 'projects',
project: 'projects/:id',
exceptions: 'exceptions',
} as const
-101
View File
@@ -746,107 +746,6 @@ describe('lib/cloud/api', () => {
})
})
context('.createProject', () => {
beforeEach(function () {
this.postProps = {
name: 'foobar',
orgId: 'org-id-123',
public: true,
remoteOrigin: 'remoteOrigin',
}
this.createProps = {
projectName: 'foobar',
orgId: 'org-id-123',
public: true,
}
})
it('POST /projects', function () {
nock(API_BASEURL)
.matchHeader('x-os-name', 'linux')
.matchHeader('x-cypress-version', pkg.version)
.matchHeader('x-route-version', '2')
.matchHeader('authorization', 'Bearer auth-token-123')
.matchHeader('accept-encoding', /gzip/)
.post('/projects', this.postProps)
.reply(200, {
id: 'id-123',
name: 'foobar',
orgId: 'org-id-123',
public: true,
})
return api.createProject(this.createProps, 'remoteOrigin', 'auth-token-123')
.then((projectDetails) => {
expect(projectDetails).to.deep.eq({
id: 'id-123',
name: 'foobar',
orgId: 'org-id-123',
public: true,
})
})
})
it('POST /projects failure formatting', () => {
nock(API_BASEURL)
.matchHeader('x-os-name', 'linux')
.matchHeader('x-cypress-version', pkg.version)
.matchHeader('x-route-version', '2')
.matchHeader('authorization', 'Bearer auth-token-123')
.matchHeader('accept-encoding', /gzip/)
.post('/projects', {
name: 'foobar',
orgId: 'org-id-123',
public: true,
remoteOrigin: 'remoteOrigin',
})
.reply(422, {
errors: {
orgId: ['is required'],
},
})
const projectDetails = {
projectName: 'foobar',
orgId: 'org-id-123',
public: true,
}
return api.createProject(projectDetails, 'remoteOrigin', 'auth-token-123')
.then(() => {
throw new Error('should have thrown here')
}).catch((err) => {
expect(err.message).to.eq(`\
422
{
"errors": {
"orgId": [
"is required"
]
}
}\
`)
})
})
it('tags errors', function () {
nock(API_BASEURL)
.matchHeader('authorization', 'Bearer auth-token-123')
.matchHeader('accept-encoding', /gzip/)
.post('/projects', this.postProps)
.reply(500, {})
return api.createProject(this.createProps, 'remoteOrigin', 'auth-token-123')
.then(() => {
throw new Error('should have thrown here')
}).catch((err) => {
expect(err.isApiError).to.be.true
})
})
})
context('.createCrashReport', () => {
beforeEach(function () {
this.setup = (body, authToken, delay = 0) => {
@@ -38,14 +38,6 @@ describe('lib/cloud/routes', () => {
expect(apiRoutes.instanceResults(123)).to.eq('http://localhost:1234/instances/123/results')
})
it('projects', () => {
expect(apiRoutes.projects()).to.eq('http://localhost:1234/projects')
})
it('project', () => {
expect(apiRoutes.project('123-foo')).to.eq('http://localhost:1234/projects/123-foo')
})
it('exceptions', () => {
expect(apiRoutes.exceptions()).to.eq('http://localhost:1234/exceptions')
})