diff --git a/cypress/integration/revision-diff.spec.js b/cypress/integration/revision-diff.spec.js --- a/cypress/integration/revision-diff.spec.js +++ b/cypress/integration/revision-diff.spec.js @@ -5,15 +5,12 @@ * See top-level LICENSE file for more information */ -const origin = { - url: 'https://github.com/memononen/libtess2', - revision: '344b31572659aa74426c5c6ad91bbde3fe23bbb8' -}; - +let origin; let diffData; describe('Test Diffs View', function() { before(function() { + origin = this.origin[0]; const url = this.Urls.browse_revision(origin.revision) + `?origin=${origin.url}`; cy.visit(url).window().then(win => { diff --git a/cypress/support/index.js b/cypress/support/index.js --- a/cypress/support/index.js +++ b/cypress/support/index.js @@ -66,25 +66,28 @@ for (let content of origin.content) { - const contentPathApiUrl = this.Urls.api_1_directory(origin.rootDirectory, content.path); - const contentMetaData = await httpGetJson(contentPathApiUrl); - - content.name = contentMetaData.name; - content.sha1git = contentMetaData.target; - content.directory = contentMetaData.dir_id; - - content.rawFilePath = this.Urls.browse_content_raw(`sha1_git:${content.sha1git}`) + - `?filename=${encodeURIComponent(content.name)}`; - - cy.request(content.rawFilePath) - .then((response) => { - const fileText = response.body; - const fileLines = fileText.split('\n'); - content.numberLines = fileLines.length; - - // If last line is empty its not shown - if (!fileLines[content.numberLines - 1]) content.numberLines -= 1; + cy.visit(this.Urls.browse_origin_content(origin.url, content.path)) + .window().then(win => { + const contentMetaData = win.swh.webapp.getBrowsedSwhObjectMetadata(); + + content.name = contentMetaData.filename; + content.sha1git = contentMetaData.sha1_git; + content.directory = contentMetaData.directory; + + content.rawFilePath = this.Urls.browse_content_raw(`sha1_git:${content.sha1git}`) + + `?filename=${encodeURIComponent(content.name)}`; + + cy.request(content.rawFilePath) + .then((response) => { + const fileText = response.body; + const fileLines = fileText.split('\n'); + content.numberLines = fileLines.length; + + // If last line is empty its not shown + if (!fileLines[content.numberLines - 1]) content.numberLines -= 1; + }); }); + } }