Skip to content
Snippets Groups Projects
Commit 2b1ae269 authored by Antoine Lambert's avatar Antoine Lambert
Browse files

cypress: Add missing global intercept for https://status.swh.org

Each time a swh-web HTML page is loaded, an HTTP request is sent to
https://status.softwareheritage.org for getting the data needed to
display the status widget in the top right of the Web UI.

That request was not globally intercepted by cypress resulting in
making real HTTP requests on the internet while executing tests.
As a consequence, this was slowing down the whole testing process.

So ensure that request is globally intercepted to speedup tests
execution.
parent 5bc77709
No related branches found
No related tags found
1 merge request!744cypress: Add missing global intercept for https://status.swh.org
......@@ -58,6 +58,23 @@ Cypress.Commands.add('ambassadorLogin', () => {
return loginUser('ambassador', 'ambassador');
});
function mockSwhStatusRequest() {
cy.intercept('https://status.softwareheritage.org/**', {
body: {
'result': {
'status': [
{
'id': '5f7c4c567f50b304c1e7bd5f',
'name': 'Save Code Now',
'updated': '2020-11-30T13:51:21.151Z',
'status': 'Operational',
'status_code': 100
}
]
}
}}).as('swhPlatformStatus');
}
before(function() {
this.unarchivedRepo = {
url: 'https://github.com/SoftwareHeritage/swh-web',
......@@ -99,6 +116,8 @@ before(function() {
}
}];
mockSwhStatusRequest();
const getMetadataForOrigin = async originUrl => {
const originVisitsApiUrl = this.Urls.api_1_origin_visits(originUrl);
const originVisits = await httpGetJson(originVisitsApiUrl);
......@@ -156,3 +175,7 @@ before(function() {
}
});
});
beforeEach(function() {
mockSwhStatusRequest();
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment