Changeset View
Changeset View
Standalone View
Standalone View
cypress/support/index.js
Show All 25 Lines | before(function() { | ||||
this.origin = [{ | this.origin = [{ | ||||
url: 'https://github.com/memononen/libtess2', | url: 'https://github.com/memononen/libtess2', | ||||
content: [{ | content: [{ | ||||
path: 'Source/tess.h' | path: 'Source/tess.h' | ||||
}, { | }, { | ||||
path: 'premake4.lua' | path: 'premake4.lua' | ||||
}], | }], | ||||
directory: [{ | |||||
path: 'Source', | |||||
id: 'cd19126d815470b28919d64b2a8e6a3e37f900dd' | |||||
}], | |||||
revision: [], | |||||
invalidSubDir: 'Source1' | invalidSubDir: 'Source1' | ||||
}, { | }, { | ||||
url: 'https://github.com/wcoder/highlightjs-line-numbers.js', | url: 'https://github.com/wcoder/highlightjs-line-numbers.js', | ||||
content: [] | content: [], | ||||
directory: [], | |||||
revision: ['1c480a4573d2a003fc2630c21c2b25829de49972'] | |||||
}]; | }]; | ||||
const getMetadataForOrigin = async originUrl => { | const getMetadataForOrigin = async originUrl => { | ||||
const originVisitsApiUrl = this.Urls.api_1_origin_visits(originUrl); | const originVisitsApiUrl = this.Urls.api_1_origin_visits(originUrl); | ||||
const originVisits = await httpGetJson(originVisitsApiUrl); | const originVisits = await httpGetJson(originVisitsApiUrl); | ||||
const lastVisit = originVisits[0]; | const lastVisit = originVisits[0]; | ||||
const snapshotApiUrl = this.Urls.api_1_snapshot(lastVisit.snapshot); | const snapshotApiUrl = this.Urls.api_1_snapshot(lastVisit.snapshot); | ||||
const lastOriginSnapshot = await httpGetJson(snapshotApiUrl); | const lastOriginSnapshot = await httpGetJson(snapshotApiUrl); | ||||
Show All 10 Lines | cy.visit('/').window().then(async win => { | ||||
this.Urls = win.Urls; | this.Urls = win.Urls; | ||||
for (let origin of this.origin) { | for (let origin of this.origin) { | ||||
const metadata = await getMetadataForOrigin(origin.url); | const metadata = await getMetadataForOrigin(origin.url); | ||||
const directoryApiUrl = this.Urls.api_1_directory(metadata.directory); | const directoryApiUrl = this.Urls.api_1_directory(metadata.directory); | ||||
origin.dirContent = await httpGetJson(directoryApiUrl); | origin.dirContent = await httpGetJson(directoryApiUrl); | ||||
origin.rootDirectory = metadata.directory; | origin.rootDirectory = metadata.directory; | ||||
origin.revision = metadata.revision; | origin.revision.push(metadata.revision); | ||||
vlorentz: it should be named `origin.revisions` then. | |||||
origin.snapshot = metadata.snapshot; | origin.snapshot = metadata.snapshot; | ||||
for (let content of origin.content) { | for (let content of origin.content) { | ||||
cy.visit(this.Urls.browse_origin_content(origin.url, content.path)) | cy.visit(this.Urls.browse_origin_content(origin.url, content.path)) | ||||
.window().then(win => { | .window().then(win => { | ||||
const contentMetaData = win.swh.webapp.getBrowsedSwhObjectMetadata(); | const contentMetaData = win.swh.webapp.getBrowsedSwhObjectMetadata(); | ||||
Show All 15 Lines | for (let origin of this.origin) { | ||||
}); | }); | ||||
}); | }); | ||||
} | } | ||||
} | } | ||||
}); | }); | ||||
}); | }); | ||||
// 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; | |||||
}); | |||||
// Ensure code coverage data do not get lost each time a new | |||||
// page is loaded during a single test execution | |||||
let coverage = {}; | |||||
Cypress.on('window:before:unload', e => { | |||||
coverage = Object.assign(coverage, e.currentTarget.__coverage__); | |||||
}); | |||||
beforeEach(function() { | |||||
coverage = {}; | |||||
}); | |||||
afterEach(function() { | |||||
cy.task('combineCoverage', coverage); | |||||
}); |
it should be named origin.revisions then.