Changeset View
Standalone View
cypress/integration/origin-diff.spec.js
- This file was added.
/** | |||||
* Copyright (C) 2019 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 | |||||
*/ | |||||
const origin = { | |||||
url: 'https://github.com/memononen/libtess2', | |||||
revision: '344b31572659aa74426c5c6ad91bbde3fe23bbb8' | |||||
}; | |||||
let diffData; | |||||
describe('Test Diffs View', function() { | |||||
before(function() { | |||||
const url = this.Urls.browse_revision(origin.revision) + `?origin=${origin.url}`; | |||||
cy.visit(url).window().then(win => { | |||||
cy.request(win.diffRevUrl) | |||||
.then(res => { | |||||
diffData = res.body; | |||||
}); | |||||
}); | |||||
}); | |||||
beforeEach(function() { | |||||
const url = this.Urls.browse_revision(origin.revision) + `?origin=${origin.url}`; | |||||
cy.visit(url); | |||||
cy.contains('a[data-toggle="tab"]', 'Changes') | |||||
anlambert: You can chain the calls to the cypress API here | |||||
.click(); | |||||
}); | |||||
it('should list all files with changes', function() { | |||||
for (let change of diffData.changes) { | |||||
const fromFile = change.from_path; | |||||
const toFile = change.to_path; | |||||
anlambertUnsubmitted Not Done Inline ActionsHere I would put all paths in a Set first to avoid running some tests twice (from_path and to_path are equal when a file is modified) anlambert: Here I would put all paths in a `Set` first to avoid running some tests twice (`from_path` and… | |||||
cy.get('#swh-revision-changes-list a') | |||||
.contains(fromFile) | |||||
.should('be.visible'); | |||||
cy.get('#swh-revision-changes-list a') | |||||
.contains(toFile) | |||||
.should('be.visible'); | |||||
} | |||||
}); | |||||
it('should load diffs when scrolled down', function() { | |||||
kalpitkAuthorUnsubmitted Done Inline ActionsThis test crashes the server with segmentation fault sometimes. kalpitk: This test crashes the server with segmentation fault sometimes.
Can't figure out how a e2e test… | |||||
kalpitkAuthorUnsubmitted Done Inline Actions(happens most of the times , when this spec file is run alone) kalpitk: (happens most of the times , when this spec file is run alone) | |||||
anlambertUnsubmitted Not Done Inline ActionsI managed to reproduce the issue from my side but it took me some time to analyze it and fix it properly. The segfault was due to the use of the file-magic package in swh-web. I have just committed 0721db0ce7e8 and cd747b23ec7f properly fixing the issue. While maintaining backward compatibility anlambert: I managed to reproduce the issue from my side but it took me some time to analyze it and fix it… | |||||
cy.wait(500) | |||||
.then(() => { | |||||
const next = Cypress.$('#swh-nb-diffs-computed').text(); | |||||
cy.get('div[id^="panel_"]:contains("Loading diff").card') | |||||
.eq(next) | |||||
.scrollIntoView() | |||||
.wait(300) | |||||
.find('.swh-content') | |||||
.should('be.visible'); | |||||
}); | |||||
}); | |||||
}); | |||||
anlambertUnsubmitted Not Done Inline ActionsHere I would rather use the implementation below as it is easier to understand: it('should load diffs when scrolled down', function() { cy.wait(500) .get('#swh-revision-changes-list a') .each(elt => { cy.get(elt.attr('href')) .scrollIntoView() .wait(500) .find('.swh-content') .should('be.visible'); }); }); anlambert: Here I would rather use the implementation below as it is easier to understand:
```lang=js
it… |
You can chain the calls to the cypress API here