Page MenuHomeSoftware Heritage

Add tests for errors
ClosedPublic

Authored by kalpitk on Jun 27 2019, 2:30 PM.

Details

Diff Detail

Repository
rDWAPPS Web applications
Branch
errorTest
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 6649
Build 9288: tox-on-jenkinsJenkins
Build 9287: arc lint + arc unit

Event Timeline

  • Refactor errors.spec
  • Rebase with master
  • Add another test for errors
  • Refactor
  • Add tests
  • Rebase
kalpitk retitled this revision from [WIP] Add tests for errors to Add tests for errors.Jul 2 2019, 12:34 PM
  • removed unnecessary print (Commited by mistake)
anlambert added a subscriber: anlambert.

Great work, thanks !

Before landing this, I want you to remove the harcoded swh-web urls in tests implementation (see commit ea8796c I just pushed for examples and my inline comments).

The idea is to use the Urls global javascript object allowing to manipulate named urls instead of raw ones.
This object is made available by the django-js-reverse extension we are using in swh-web.
For each named Django view, it adds a function in the Urls that will generate the raw url from its name and its required arguments.
This way, if we modify a raw url in Python code, we will not need to modify it in the cypress tests implementation.

cypress/integration/errors.spec.js
38

Here, you must add the following global variable declaration:

let Urls;
39

Then add a before hook to get the Urls global object from swh-web:

before(function() {
  cy.visit('/').window().then(win => {
    Urls = win.Urls;
  });
});
41

Replace this line with:

const url = Urls.browse_origin_directory(unarchivedRepo.url);

And do the same in tests below. The naming scheme for the functions of the Urls object is quite straightforward:

  • Urls.browse_origin_<object_type>
  • Urls.browse_<object_type>
  • Urls.api_1_<object_type>

where <object_type> can be one of: content, directory, snapshot, ...

137

Replace this line with:

const url = Urls[`browse_${type}`](invalidChecksum)
This revision now requires changes to proceed.Jul 2 2019, 3:30 PM

@anlambert Thank you for the improvements. I think, it will be even better if we declare Urls object in cypress/support/index.js, no need to repeat in every spec file

Thank you for the improvements. I think, it will be even better if we declare Urls object in cypress/support/index.js, no need to repeat in every spec file

Thanks for pointing me to this, I was looking for such a feature yesterday but I missed it in the documentation.

I will commit the improvement today.

@kalpitk , the Urls variable is now set globally in the support file (958fd1da20e9). You can access it through this.Urls in tests implementation.

  • fetch urls through django-reverse
  • fetch api url through django-reverse

use Urls to fetch url at one more place

This revision is now accepted and ready to land.Jul 3 2019, 1:39 PM
This revision was automatically updated to reflect the committed changes.