Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7066674
D5222.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
27 KB
Subscribers
None
D5222.diff
View Options
diff --git a/cypress/integration/admin.spec.js b/cypress/integration/admin.spec.js
--- a/cypress/integration/admin.spec.js
+++ b/cypress/integration/admin.spec.js
@@ -1,5 +1,5 @@
/**
- * Copyright (C) 2019 The Software Heritage developers
+ * Copyright (C) 2019-2021 The Software Heritage developers
* See the AUTHORS file at the top-level directory of this distribution
* License: GNU Affero General Public License version 3, or any later version
* See top-level LICENSE file for more information
@@ -71,11 +71,8 @@
it('should redirect to correct page after login', function() {
// mock calls to deposit list api to avoid possible errors
// while running the test
- cy.server();
- cy.route({
- method: 'GET',
- url: `${this.Urls.admin_deposit_list()}**`,
- response: {
+ cy.intercept(`${this.Urls.admin_deposit_list()}**`, {
+ body: {
data: [],
recordsTotal: 0,
recordsFiltered: 0,
diff --git a/cypress/integration/api-tokens.spec.js b/cypress/integration/api-tokens.spec.js
--- a/cypress/integration/api-tokens.spec.js
+++ b/cypress/integration/api-tokens.spec.js
@@ -1,5 +1,5 @@
/**
- * Copyright (C) 2020 The Software Heritage developers
+ * Copyright (C) 2020-2021 The Software Heritage developers
* See the AUTHORS file at the top-level directory of this distribution
* License: GNU Affero General Public License version 3, or any later version
* See top-level LICENSE file for more information
@@ -15,11 +15,8 @@
});
function initTokensPage(Urls, tokens) {
- cy.server();
- cy.route({
- method: 'GET',
- url: `${Urls.oidc_list_bearer_tokens()}/**`,
- response: {
+ cy.intercept(`${Urls.oidc_list_bearer_tokens()}/**`, {
+ body: {
'recordsTotal': tokens.length,
'draw': 2,
'recordsFiltered': tokens.length,
@@ -63,11 +60,9 @@
});
function displayToken(Urls, status, tokenValue = '') {
- cy.route({
- method: 'POST',
- url: `${Urls.oidc_get_bearer_token()}/**`,
- response: tokenValue,
- status: status
+ cy.intercept('POST', `${Urls.oidc_get_bearer_token()}/**`, {
+ body: tokenValue,
+ statusCode: status
}).as('getTokenRequest');
cy.contains('Display token')
@@ -96,11 +91,9 @@
});
function revokeToken(Urls, status) {
- cy.route({
- method: 'POST',
- url: `${Urls.oidc_revoke_bearer_tokens()}/**`,
- response: '',
- status: status
+ cy.intercept('POST', `${Urls.oidc_revoke_bearer_tokens()}/**`, {
+ body: '',
+ statusCode: status
}).as('revokeTokenRequest');
cy.contains('Revoke token')
diff --git a/cypress/integration/deposit-admin.spec.js b/cypress/integration/deposit-admin.spec.js
--- a/cypress/integration/deposit-admin.spec.js
+++ b/cypress/integration/deposit-admin.spec.js
@@ -1,5 +1,5 @@
/**
- * Copyright (C) 2020 The Software Heritage developers
+ * Copyright (C) 2020-2021 The Software Heritage developers
* See the AUTHORS file at the top-level directory of this distribution
* License: GNU Affero General Public License version 3, or any later version
* See top-level LICENSE file for more information
@@ -55,11 +55,8 @@
let testDeposits = responseDeposits;
- cy.server();
- cy.route({
- method: 'GET',
- url: `${this.Urls.admin_deposit_list()}**`,
- response: {
+ cy.intercept(`${this.Urls.admin_deposit_list()}**`, {
+ body: {
'draw': 10,
'recordsTotal': testDeposits.length,
'recordsFiltered': testDeposits.length,
diff --git a/cypress/integration/home.spec.js b/cypress/integration/home.spec.js
--- a/cypress/integration/home.spec.js
+++ b/cypress/integration/home.spec.js
@@ -1,5 +1,5 @@
/**
- * Copyright (C) 2019-2020 The Software Heritage developers
+ * Copyright (C) 2019-2021 The Software Heritage developers
* See the AUTHORS file at the top-level directory of this distribution
* License: GNU Affero General Public License version 3, or any later version
* See top-level LICENSE file for more information
@@ -23,12 +23,8 @@
it('should display positive stats for each category', function() {
- cy.server();
-
- cy.route({
- method: 'GET',
- url: this.Urls.stat_counters()
- }).as('getStatCounters');
+ cy.intercept(this.Urls.stat_counters())
+ .as('getStatCounters');
cy.visit(url)
.wait('@getStatCounters')
@@ -45,12 +41,8 @@
it('should display null counters and hide history graphs when storage is empty', function() {
- cy.server();
-
- cy.route({
- method: 'GET',
- url: this.Urls.stat_counters(),
- response: {
+ cy.intercept(this.Urls.stat_counters(), {
+ body: {
'stat_counters': {},
'stat_counters_history': {}
}
@@ -73,12 +65,8 @@
it('should hide counters when data is missing', function() {
- cy.server();
-
- cy.route({
- method: 'GET',
- url: this.Urls.stat_counters(),
- response: {
+ cy.intercept(this.Urls.stat_counters(), {
+ body: {
'stat_counters': {
'content': 150,
'directory': 45,
diff --git a/cypress/integration/layout.spec.js b/cypress/integration/layout.spec.js
--- a/cypress/integration/layout.spec.js
+++ b/cypress/integration/layout.spec.js
@@ -1,5 +1,5 @@
/**
- * Copyright (C) 2019-2020 The Software Heritage developers
+ * Copyright (C) 2019-2021 The Software Heritage developers
* See the AUTHORS file at the top-level directory of this distribution
* License: GNU Affero General Public License version 3, or any later version
* See top-level LICENSE file for more information
@@ -162,13 +162,17 @@
}
];
+ const responses = [];
+ for (let std of statusTestData) {
+ responses.push(genStatusResponse(std.status, std.statusCode));
+ }
+
for (let std of statusTestData) {
- cy.server();
- cy.route({
- url: `${statusUrl}/**`,
- response: genStatusResponse(std.status, std.statusCode)
- }).as('getSwhStatusData');
cy.visit(url);
+ // trick to override the response of an intercepted request
+ // https://github.com/cypress-io/cypress/issues/9302
+ cy.intercept(`${statusUrl}/**`, req => req.reply(responses.shift()))
+ .as('getSwhStatusData');
cy.wait('@getSwhStatusData');
cy.get('.swh-current-status-indicator').should('have.class', std.color);
cy.get('#swh-current-status-description').should('have.text', std.status);
@@ -176,10 +180,8 @@
});
it('should not display swh status widget when data are not available', function() {
- cy.server();
- cy.route({
- url: `${statusUrl}/**`,
- response: {}
+ cy.intercept(`${statusUrl}/**`, {
+ body: {}
}).as('getSwhStatusData');
cy.visit(url);
cy.wait('@getSwhStatusData');
diff --git a/cypress/integration/origin-save.spec.js b/cypress/integration/origin-save.spec.js
--- a/cypress/integration/origin-save.spec.js
+++ b/cypress/integration/origin-save.spec.js
@@ -1,5 +1,5 @@
/**
- * Copyright (C) 2019-2020 The Software Heritage developers
+ * Copyright (C) 2019-2021 The Software Heritage developers
* See the AUTHORS file at the top-level directory of this distribution
* License: GNU Affero General Public License version 3, or any later version
* See top-level LICENSE file for more information
@@ -60,12 +60,8 @@
saveTaskStatus: saveTaskStatus,
visitDate: visitDate});
}
- cy.route({
- method: 'POST',
- status: responseStatus,
- url: requestUrl,
- response: response
- }).as('saveRequest');
+ cy.intercept('POST', requestUrl, {body: response, statusCode: responseStatus})
+ .as('saveRequest');
}
// Mocks API response : /save/(:visit_type)/(:origin_url)
@@ -100,7 +96,6 @@
cy.fixture('origin-save').as('originSaveJSON');
cy.fixture('save-task-info').as('saveTaskInfoJSON');
cy.visit(url);
- cy.server();
});
it('should display accepted message when accepted', function() {
@@ -220,7 +215,7 @@
});
it('should display origin save info in the requests table', function() {
- cy.route('GET', '/save/requests/list/**', '@originSaveJSON');
+ cy.intercept('/save/requests/list/**', {fixture: 'origin-save'});
cy.get('#swh-origin-save-requests-list-tab').click();
cy.get('tbody tr').then(rows => {
let i = 0;
@@ -262,7 +257,7 @@
'recordsFiltered': 1,
'data': [saveRequestData]
};
- cy.route('GET', '/save/requests/list/**', saveRequestsListData);
+ cy.intercept('/save/requests/list/**', {body: saveRequestsListData});
cy.get('#swh-origin-save-requests-list-tab').click();
cy.get('tbody tr').then(rows => {
const firstRowCells = rows[0].cells;
@@ -273,8 +268,8 @@
});
it('should display/close task info popover when clicking on the info button', function() {
- cy.route('GET', '/save/requests/list/**', '@originSaveJSON');
- cy.route('GET', '/save/task/info/**', '@saveTaskInfoJSON');
+ cy.intercept('/save/requests/list/**', {fixture: 'origin-save'});
+ cy.intercept('/save/task/info/**', {fixture: 'save-task-info'});
cy.get('#swh-origin-save-requests-list-tab').click();
cy.get('.swh-save-request-info')
@@ -293,8 +288,8 @@
});
it('should hide task info popover when clicking on the close button', function() {
- cy.route('GET', '/save/requests/list/**', '@originSaveJSON');
- cy.route('GET', '/save/task/info/**', '@saveTaskInfoJSON');
+ cy.intercept('/save/requests/list/**', {fixture: 'origin-save'});
+ cy.intercept('/save/task/info/**', {fixture: 'save-task-info'});
cy.get('#swh-origin-save-requests-list-tab').click();
cy.get('.swh-save-request-info')
@@ -312,7 +307,7 @@
});
it('should fill save request form when clicking on "Save again" button', function() {
- cy.route('GET', '/save/requests/list/**', '@originSaveJSON');
+ cy.intercept('/save/requests/list/**', {fixture: 'origin-save'});
cy.get('#swh-origin-save-requests-list-tab').click();
cy.get('.swh-save-origin-again')
@@ -332,7 +327,7 @@
const originUrl = 'https://gitlab.inria.fr/solverstack/maphys/maphys/';
const badVisitType = 'hg';
const goodVisitType = 'git';
- cy.route('GET', '/save/requests/list/**', '@originSaveJSON');
+ cy.intercept('/save/requests/list/**', {fixture: 'origin-save'});
stubSaveRequest({requestUrl: this.Urls.origin_save_request(badVisitType, originUrl),
visitType: badVisitType,
saveRequestStatus: 'accepted',
diff --git a/cypress/integration/origin-search.spec.js b/cypress/integration/origin-search.spec.js
--- a/cypress/integration/origin-search.spec.js
+++ b/cypress/integration/origin-search.spec.js
@@ -31,12 +31,9 @@
}
function stubOriginVisitLatestRequests(status = 200, response = {type: 'tar'}) {
- cy.server();
- cy.route({
- method: 'GET',
- url: '**/visit/latest/**',
- response: response,
- status: status
+ cy.intercept('**/visit/latest/**', {
+ body: response,
+ statusCode: status
}).as('originVisitLatest');
}
@@ -187,20 +184,15 @@
});
it('should not send request to the resolve endpoint', function() {
- cy.server();
+ cy.intercept(`${this.Urls.api_1_resolve_swhid('').slice(0, -1)}**`)
+ .as('resolveSWHID');
- cy.route({
- method: 'GET',
- url: `${this.Urls.api_1_resolve_swhid('').slice(0, -1)}**`
- }).as('resolveSWHID');
-
- cy.route({
- method: 'GET',
- url: `${this.Urls.api_1_origin_search(origin.url)}**`
- }).as('searchOrigin');
+ cy.intercept(`${this.Urls.api_1_origin_search(origin.url)}**`)
+ .as('searchOrigin');
cy.get('#swh-origins-url-patterns')
.type(origin.url);
+
cy.get('.swh-search-icon')
.click();
@@ -457,21 +449,17 @@
});
it('should not send request to the search endpoint', function() {
- cy.server();
const swhid = `swh:1:rev:${origin.revisions[0]}`;
- cy.route({
- method: 'GET',
- url: this.Urls.api_1_resolve_swhid(swhid)
- }).as('resolveSWHID');
+ cy.intercept(this.Urls.api_1_resolve_swhid(swhid))
+ .as('resolveSWHID');
- cy.route({
- method: 'GET',
- url: `${this.Urls.api_1_origin_search('').slice(0, -1)}**`
- }).as('searchOrigin');
+ cy.intercept(`${this.Urls.api_1_origin_search('').slice(0, -1)}**`)
+ .as('searchOrigin');
cy.get('#swh-origins-url-patterns')
.type(swhid);
+
cy.get('.swh-search-icon')
.click();
diff --git a/cypress/integration/vault.spec.js b/cypress/integration/vault.spec.js
--- a/cypress/integration/vault.spec.js
+++ b/cypress/integration/vault.spec.js
@@ -1,5 +1,5 @@
/**
- * Copyright (C) 2019-2020 The Software Heritage developers
+ * Copyright (C) 2019-2021 The Software Heritage developers
* See the AUTHORS file at the top-level directory of this distribution
* License: GNU Affero General Public License version 3, or any later version
* See top-level LICENSE file for more information
@@ -104,7 +104,6 @@
message, this.vaultFetchRevisionUrl);
};
- cy.server();
});
it('should report an error when vault service is experiencing issues', function() {
@@ -113,11 +112,9 @@
// Stub responses when requesting the vault API to simulate
// an internal server error
- cy.route({
- method: 'GET',
- url: this.vaultDirectoryUrl,
- response: {'exception': 'APIError'},
- status: 500
+ cy.intercept(this.vaultDirectoryUrl, {
+ body: {'exception': 'APIError'},
+ statusCode: 500
}).as('checkVaultCookingTask');
cy.contains('button', 'Download')
@@ -136,17 +133,13 @@
// Stub responses when requesting the vault API to simulate
// a task can not be created
- cy.route({
- method: 'GET',
- url: this.vaultDirectoryUrl,
- response: {'exception': 'NotFoundExc'}
+ cy.intercept('GET', this.vaultDirectoryUrl, {
+ body: {'exception': 'NotFoundExc'}
}).as('checkVaultCookingTask');
- cy.route({
- method: 'POST',
- url: this.vaultDirectoryUrl,
- response: {'exception': 'ValueError'},
- status: 500
+ cy.intercept('POST', this.vaultDirectoryUrl, {
+ body: {'exception': 'ValueError'},
+ statusCode: 500
}).as('createVaultCookingTask');
cy.contains('button', 'Download')
@@ -170,29 +163,37 @@
// Browse a directory
cy.visit(this.directoryUrl);
+ // Stub response to the vault API to simulate archive download
+ cy.intercept('GET', this.vaultFetchDirectoryUrl, {
+ fixture: `${this.directory}.tar.gz`,
+ headers: {
+ 'Content-disposition': `attachment; filename=${this.directory}.tar.gz`,
+ 'Content-Type': 'application/gzip'
+ }
+ }).as('fetchCookedArchive');
+
+ // Stub responses when checking vault task status
+ const checkVaulResponses = [
+ {'exception': 'NotFoundExc'},
+ this.genVaultDirCookingResponse('new'),
+ this.genVaultDirCookingResponse('pending', 'Processing...'),
+ this.genVaultDirCookingResponse('done')
+ ];
+
+ // trick to override the response of an intercepted request
+ // https://github.com/cypress-io/cypress/issues/9302
+ cy.intercept('GET', this.vaultDirectoryUrl, req => req.reply(checkVaulResponses.shift()))
+ .as('checkVaultCookingTask');
+
// Stub responses when requesting the vault API to simulate
// a task has been created
- cy.route({
- method: 'GET',
- url: this.vaultDirectoryUrl,
- response: {'exception': 'NotFoundExc'}
- }).as('checkVaultCookingTask');
-
- cy.route({
- method: 'POST',
- url: this.vaultDirectoryUrl,
- response: this.genVaultDirCookingResponse('new')
+ cy.intercept('POST', this.vaultDirectoryUrl, {
+ body: this.genVaultDirCookingResponse('new')
}).as('createVaultCookingTask');
cy.contains('button', 'Download')
.click();
- cy.route({
- method: 'GET',
- url: this.vaultDirectoryUrl,
- response: this.genVaultDirCookingResponse('new')
- }).as('checkVaultCookingTask');
-
cy.window().then(win => {
const swhIdsContext = win.swh.webapp.getSwhIdsContext();
const browseDirectoryUrl = swhIdsContext.directory.swhid_with_context_url;
@@ -216,39 +217,14 @@
testStatus(this.directory, progressbarColors['new'], 'new', 'new');
});
- // Stub response to the vault API indicating the task is processing
- cy.route({
- method: 'GET',
- url: this.vaultDirectoryUrl,
- response: this.genVaultDirCookingResponse('pending', 'Processing...')
- }).as('checkVaultCookingTask');
-
cy.wait('@checkVaultCookingTask').then(() => {
testStatus(this.directory, progressbarColors['pending'], 'Processing...', 'pending');
});
- // Stub response to the vault API indicating the task is finished
- cy.route({
- method: 'GET',
- url: this.vaultDirectoryUrl,
- response: this.genVaultDirCookingResponse('done')
- }).as('checkVaultCookingTask');
-
cy.wait('@checkVaultCookingTask').then(() => {
testStatus(this.directory, progressbarColors['done'], 'done', 'done');
});
- // Stub response to the vault API to simulate archive download
- cy.route({
- method: 'GET',
- url: this.vaultFetchDirectoryUrl,
- response: `fx:${this.directory}.tar.gz`,
- headers: {
- 'Content-disposition': `attachment; filename=${this.directory}.tar.gz`,
- 'Content-Type': 'application/gzip'
- }
- }).as('fetchCookedArchive');
-
cy.get(`#vault-task-${this.directory} .vault-origin a`)
.should('contain', this.origin[0].url)
.should('have.attr', 'href', `${this.Urls.browse_origin()}?origin_url=${this.origin[0].url}`);
@@ -272,29 +248,37 @@
// Browse a revision
cy.visit(this.revisionUrl);
+ // Stub response to the vault API indicating to simulate archive download
+ cy.intercept(this.vaultFetchRevisionUrl, {
+ fixture: `${this.revision}.gitfast.gz`,
+ headers: {
+ 'Content-disposition': `attachment; filename=${this.revision}.gitfast.gz`,
+ 'Content-Type': 'application/gzip'
+ }
+ }).as('fetchCookedArchive');
+
+ // Stub responses when checking vault task status
+ const checkVaultResponses = [
+ {'exception': 'NotFoundExc'},
+ this.genVaultRevCookingResponse('new'),
+ this.genVaultRevCookingResponse('pending', 'Processing...'),
+ this.genVaultRevCookingResponse('done')
+ ];
+
+ // trick to override the response of an intercepted request
+ // https://github.com/cypress-io/cypress/issues/9302
+ cy.intercept('GET', this.vaultRevisionUrl, req => req.reply(checkVaultResponses.shift()))
+ .as('checkVaultCookingTask');
+
// Stub responses when requesting the vault API to simulate
// a task has been created
- cy.route({
- method: 'GET',
- url: this.vaultRevisionUrl,
- response: {'exception': 'NotFoundExc'}
- }).as('checkVaultCookingTask');
-
- cy.route({
- method: 'POST',
- url: this.vaultRevisionUrl,
- response: this.genVaultRevCookingResponse('new')
+ cy.intercept('POST', this.vaultRevisionUrl, {
+ body: this.genVaultRevCookingResponse('new')
}).as('createVaultCookingTask');
// Create a vault cooking task through the GUI
checkVaultCookingTask('as git');
- cy.route({
- method: 'GET',
- url: this.vaultRevisionUrl,
- response: this.genVaultRevCookingResponse('new')
- }).as('checkVaultCookingTask');
-
cy.window().then(win => {
const swhIdsContext = win.swh.webapp.getSwhIdsContext();
const browseRevisionUrl = swhIdsContext.revision.swhid_url;
@@ -318,40 +302,14 @@
testStatus(this.revision, progressbarColors['new'], 'new', 'new');
});
- // Stub response to the vault API indicating the task is processing
- cy.route({
- method: 'GET',
- url: this.vaultRevisionUrl,
- response: this.genVaultRevCookingResponse('pending', 'Processing...')
- }).as('checkVaultCookingTask');
-
cy.wait('@checkVaultCookingTask').then(() => {
testStatus(this.revision, progressbarColors['pending'], 'Processing...', 'pending');
});
- // Stub response to the vault API indicating the task is finished
- cy.route({
- method: 'GET',
- url: this.vaultRevisionUrl,
- response: this.genVaultRevCookingResponse('done')
- }).as('checkVaultCookingTask');
-
cy.wait('@checkVaultCookingTask').then(() => {
testStatus(this.revision, progressbarColors['done'], 'done', 'done');
});
- // Stub response to the vault API indicating to simulate archive
- // download
- cy.route({
- method: 'GET',
- url: this.vaultFetchRevisionUrl,
- response: `fx:${this.revision}.gitfast.gz`,
- headers: {
- 'Content-disposition': `attachment; filename=${this.revision}.gitfast.gz`,
- 'Content-Type': 'application/gzip'
- }
- }).as('fetchCookedArchive');
-
cy.get(`#vault-task-${this.revision} .vault-origin`)
.should('have.text', 'unknown');
@@ -373,29 +331,26 @@
// Browse a directory
cy.visit(this.releaseUrl);
+ // Stub responses when checking vault task status
+ const checkVaultResponses = [
+ {'exception': 'NotFoundExc'},
+ this.genVaultDirCookingResponse('new')
+ ];
+
+ // trick to override the response of an intercepted request
+ // https://github.com/cypress-io/cypress/issues/9302
+ cy.intercept('GET', this.vaultReleaseDirectoryUrl, req => req.reply(checkVaultResponses.shift()))
+ .as('checkVaultCookingTask');
+
// Stub responses when requesting the vault API to simulate
// a task has been created
- cy.route({
- method: 'GET',
- url: this.vaultReleaseDirectoryUrl,
- response: {'exception': 'NotFoundExc'}
- }).as('checkVaultCookingTask');
-
- cy.route({
- method: 'POST',
- url: this.vaultReleaseDirectoryUrl,
- response: this.genVaultDirCookingResponse('new')
+ cy.intercept('POST', this.vaultReleaseDirectoryUrl, {
+ body: this.genVaultDirCookingResponse('new')
}).as('createVaultCookingTask');
cy.contains('button', 'Download')
.click();
- cy.route({
- method: 'GET',
- url: this.vaultReleaseDirectoryUrl,
- response: this.genVaultDirCookingResponse('new')
- }).as('checkVaultCookingTask');
-
// Create a vault cooking task through the GUI
cy.get('.modal-dialog')
.contains('button:visible', 'Ok')
@@ -414,11 +369,9 @@
updateVaultItemList(this.Urls.browse_vault(), vaultItems);
// Send 404 when fetching vault item
- cy.route({
- method: 'GET',
- status: 404,
- url: this.vaultFetchRevisionUrl,
- response: {
+ cy.intercept(this.vaultFetchRevisionUrl, {
+ statusCode: 404,
+ body: {
'exception': 'NotFoundExc',
'reason': `Revision with ID '${this.revision}' not found.`
},
@@ -431,16 +384,12 @@
.click();
cy.wait('@fetchCookedArchive').then(() => {
- cy.route({
- method: 'POST',
- url: this.vaultRevisionUrl,
- response: this.genVaultRevCookingResponse('new')
+ cy.intercept('POST', this.vaultRevisionUrl, {
+ body: this.genVaultRevCookingResponse('new')
}).as('createVaultCookingTask');
- cy.route({
- method: 'GET',
- url: this.vaultRevisionUrl,
- response: this.genVaultRevCookingResponse('new')
+ cy.intercept(this.vaultRevisionUrl, {
+ body: this.genVaultRevCookingResponse('new')
}).as('checkVaultCookingTask');
cy.get('#vault-recook-object-modal > .modal-dialog')
@@ -475,25 +424,21 @@
// Browse a directory
cy.visit(this.directoryUrl);
- // Stub responses when requesting the vault API to simulate
- // the directory tarball has already been cooked
- cy.route({
- method: 'GET',
- url: this.vaultDirectoryUrl,
- response: this.genVaultDirCookingResponse('done')
- }).as('checkVaultCookingTask');
-
// Stub response to the vault API to simulate archive download
- cy.route({
- method: 'GET',
- url: this.vaultFetchDirectoryUrl,
- response: `fx:${this.directory}.tar.gz`,
+ cy.intercept(this.vaultFetchDirectoryUrl, {
+ fixture: `${this.directory}.tar.gz`,
headers: {
'Content-disposition': `attachment; filename=${this.directory}.tar.gz`,
'Content-Type': 'application/gzip'
}
}).as('fetchCookedArchive');
+ // Stub responses when requesting the vault API to simulate
+ // the directory tarball has already been cooked
+ cy.intercept(this.vaultDirectoryUrl, {
+ body: this.genVaultDirCookingResponse('done')
+ }).as('checkVaultCookingTask');
+
// Create a vault cooking task through the GUI
cy.contains('button', 'Download')
.click();
@@ -512,25 +457,21 @@
// Browse a directory
cy.visit(this.revisionUrl);
- // Stub responses when requesting the vault API to simulate
- // the directory tarball has already been cooked
- cy.route({
- method: 'GET',
- url: this.vaultRevisionUrl,
- response: this.genVaultRevCookingResponse('done')
- }).as('checkVaultCookingTask');
-
// Stub response to the vault API to simulate archive download
- cy.route({
- method: 'GET',
- url: this.vaultFetchRevisionUrl,
- response: `fx:${this.revision}.gitfast.gz`,
+ cy.intercept(this.vaultFetchRevisionUrl, {
+ fixture: `${this.revision}.gitfast.gz`,
headers: {
'Content-disposition': `attachment; filename=${this.revision}.gitfast.gz`,
'Content-Type': 'application/gzip'
}
}).as('fetchCookedArchive');
+ // Stub responses when requesting the vault API to simulate
+ // the directory tarball has already been cooked
+ cy.intercept(this.vaultRevisionUrl, {
+ body: this.genVaultRevCookingResponse('done')
+ }).as('checkVaultCookingTask');
+
checkVaultCookingTask('as git');
// Start archive download through the GUI
@@ -548,10 +489,8 @@
// Stub responses when requesting the vault API to simulate
// the last cooking of the directory tarball has failed
- cy.route({
- method: 'GET',
- url: this.vaultDirectoryUrl,
- response: this.genVaultDirCookingResponse('failed')
+ cy.intercept(this.vaultDirectoryUrl, {
+ body: this.genVaultDirCookingResponse('failed')
}).as('checkVaultCookingTask');
cy.contains('button', 'Download')
diff --git a/cypress/support/index.js b/cypress/support/index.js
--- a/cypress/support/index.js
+++ b/cypress/support/index.js
@@ -14,10 +14,9 @@
});
Cypress.Commands.add('xhrShouldBeCalled', (alias, timesCalled) => {
- expect(
- cy.state('requests').filter(call => call.alias === alias),
- `${alias} should have been called ${timesCalled} times`
- ).to.have.length(timesCalled);
+ const testRoutes = cy.state('routes');
+ const aliasRoute = Cypress._.find(testRoutes, {alias});
+ expect(Object.keys(aliasRoute.requests || {})).to.have.length(timesCalled);
});
Cypress.Commands.add('adminLogin', () => {
@@ -144,9 +143,3 @@
}
});
});
-
-// force the use of fetch polyfill wrapping XmlHttpRequest
-// in order for cypress to be able to intercept and stub them
-Cypress.on('window:before:load', win => {
- win.fetch = null;
-});
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Nov 5 2024, 6:04 PM (12 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3215653
Attached To
D5222: cypress: Migrate from cy.route API to cy.intercept API
Event Timeline
Log In to Comment