Changeset View
Changeset View
Standalone View
Standalone View
cypress/integration/origin-save.spec.js
Show All 11 Lines | const saveCodeMsg = { | ||||
'success': 'The "save code now" request has been accepted and will be processed as soon as possible.', | 'success': 'The "save code now" request has been accepted and will be processed as soon as possible.', | ||||
'warning': 'The "save code now" request has been put in pending state and may be accepted for processing after manual review.', | 'warning': 'The "save code now" request has been put in pending state and may be accepted for processing after manual review.', | ||||
'rejected': 'The "save code now" request has been rejected because the provided origin url is blacklisted.', | 'rejected': 'The "save code now" request has been rejected because the provided origin url is blacklisted.', | ||||
'rateLimit': 'The rate limit for "save code now" requests has been reached. Please try again later.', | 'rateLimit': 'The rate limit for "save code now" requests has been reached. Please try again later.', | ||||
'unknownErr': 'An unexpected error happened when submitting the "save code now request' | 'unknownErr': 'An unexpected error happened when submitting the "save code now request' | ||||
}; | }; | ||||
function makeOriginSaveRequest(originType, originUrl) { | function makeOriginSaveRequest(originType, originUrl) { | ||||
cy.get('#swh-input-origin-type') | cy.get('#swh-input-visit-type') | ||||
.select(originType) | .select(originType) | ||||
.get('#swh-input-origin-url') | .get('#swh-input-origin-url') | ||||
.type(originUrl) | .type(originUrl) | ||||
.get('#swh-save-origin-form') | .get('#swh-save-origin-form') | ||||
.submit(); | .submit(); | ||||
} | } | ||||
function checkAlertVisible(alertType, msg) { | function checkAlertVisible(alertType, msg) { | ||||
Show All 13 Lines | cy.route({ | ||||
response: genOriginSaveResponse(objectType, status, originUrl, Date().toString(), taskStatus) | response: genOriginSaveResponse(objectType, status, originUrl, Date().toString(), taskStatus) | ||||
}).as('saveRequest'); | }).as('saveRequest'); | ||||
} | } | ||||
// Mocks API response : /save/(:object_type)/(:origin_url) | // Mocks API response : /save/(:object_type)/(:origin_url) | ||||
// object_type : {'git', 'hg', 'svn'} | // object_type : {'git', 'hg', 'svn'} | ||||
function genOriginSaveResponse(objectType, saveRequestStatus, originUrl, saveRequestDate, saveTaskStatus) { | function genOriginSaveResponse(objectType, saveRequestStatus, originUrl, saveRequestDate, saveTaskStatus) { | ||||
return { | return { | ||||
'origin_type': objectType, | 'visit_type': objectType, | ||||
'save_request_status': saveRequestStatus, | 'save_request_status': saveRequestStatus, | ||||
'origin_url': originUrl, | 'origin_url': originUrl, | ||||
'id': 1, | 'id': 1, | ||||
'save_request_date': saveRequestDate, | 'save_request_date': saveRequestDate, | ||||
'save_task_status': saveTaskStatus, | 'save_task_status': saveTaskStatus, | ||||
'visit_date': null | 'visit_date': null | ||||
}; | }; | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 70 Lines • Show Last 20 Lines |