Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/resources/contents/code/extensions/test.diff
- This file was added.
diff --git a/cypress/integration/directory.spec.js b/cypress/integration/directory.spec.js | |||||
index c59e376c..944f2bc5 100644 | |||||
--- a/cypress/integration/directory.spec.js | |||||
+++ b/cypress/integration/directory.spec.js | |||||
@@ -5,37 +5,56 @@ | |||||
* See top-level LICENSE file for more information | |||||
*/ | |||||
-const url = 'browse/origin/https://github.com/memononen/libtess2/directory/'; | |||||
-const numContent = 5; | |||||
-const numDirectory = 5; | |||||
-const firstSubDirectory = 'browse/origin/https://github.com/memononen/libtess2/directory/Bin/'; | |||||
+import {httpGetJson} from './utils'; | |||||
+const url = 'browse/origin/https://github.com/memononen/libtess2/directory/'; | |||||
const $ = Cypress.$; | |||||
+let dirs, files; | |||||
+ | |||||
describe('Directory Tests', function() { | |||||
- beforeEach(function () { | |||||
+ | |||||
+ before(function() { | |||||
+ cy.visit(url); | |||||
+ cy.window().then(async win => { | |||||
+ const metadata = win.swh.webapp.getBrowsedSwhObjectMetadata(); | |||||
+ const apiUrl = Cypress.config().baseUrl + '/api/1/directory/' + metadata.directory; | |||||
+ let dirContent = await httpGetJson(apiUrl); | |||||
+ files = []; | |||||
+ dirs = []; | |||||
+ for (let entry of dirContent) { | |||||
+ if (entry.type === 'file') { | |||||
+ files.push(entry); | |||||
+ } else { | |||||
+ dirs.push(entry); | |||||
+ } | |||||
+ } | |||||
+ }); | |||||
+ }); | |||||
+ | |||||
+ beforeEach(function() { | |||||
cy.visit(url); | |||||
- }) | |||||
+ }); | |||||
it('should display all files and directories', function() { | |||||
cy.get('.swh-directory') | |||||
- .should('have.length', numDirectory) | |||||
+ .should('have.length', dirs.length) | |||||
.and('be.visible'); | |||||
cy.get('.swh-content') | |||||
- .should('have.length', numContent) | |||||
+ .should('have.length', files.length) | |||||
.and('be.visible'); | |||||
- }) | |||||
+ }); | |||||
it('should display sizes for files', function() { | |||||
cy.get('.swh-content') | |||||
.parent('tr') | |||||
.then((rows) => { | |||||
- for(let row of rows) { | |||||
+ for (let row of rows) { | |||||
let text = $(row).children('td').eq(2).text(); | |||||
expect(text.trim()).to.not.be.empty; | |||||
} | |||||
- }) | |||||
- }) | |||||
+ }); | |||||
+ }); | |||||
it('should display readme when it is present', function() { | |||||
cy.get('#readme-panel > .card-body') | |||||
@@ -43,7 +62,7 @@ describe('Directory Tests', function() { | |||||
.and('have.class', 'swh-showdown') | |||||
.and('not.be.empty') | |||||
.and('not.contain', 'Readme bytes are not available'); | |||||
- }) | |||||
+ }); | |||||
it('should open subdirectory when clicked', function() { | |||||
cy.get('.swh-directory') | |||||
@@ -52,9 +71,9 @@ describe('Directory Tests', function() { | |||||
.click(); | |||||
cy.url() | |||||
- .should('include', firstSubDirectory); | |||||
+ .should('include', url + dirs[0]['name']); | |||||
cy.get('.swh-directory-table') | |||||
.should('exist'); | |||||
- }) | |||||
-}) | |||||
+ }); | |||||
+}); | |||||
No newline at end of file |