Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new e2e test for the build files page #2025

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/cypress/e2e/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ add_cypress_e2e_test(colorblind)
add_cypress_e2e_test(daterange)
add_cypress_e2e_test(build-notes)
add_cypress_e2e_test(sites)
add_cypress_e2e_test(build-files)
53 changes: 53 additions & 0 deletions tests/cypress/e2e/build-files.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
describe('The Build Configure Page', () => {
it('can be reached from the index page', () => {
cy.visit('index.php?project=TestCompressionExample');

cy.get('table#project_1_3').find('tbody').find('tr').first().as('build_row');
cy.get('@build_row').find('td').eq(1).find('a[title="2 files uploaded with this build"]').as('files_link');
cy.get('@files_link').should('have.attr', 'href').and('match', /builds?\/[0-9]+\/files/);
cy.get('@files_link').find('img').should('have.attr', 'src', 'img/package.png');
cy.get('@files_link').click();
cy.url().should('match', /builds?\/[0-9]+\/files/);
});


it('loads the right file data', () => {
cy.visit('index.php?project=TestCompressionExample');

cy.get('table#project_1_3').contains('a', 'RemovalWorksAsExpected').invoke('attr', 'href').then(build_url => {
const buildid = build_url.match(/builds?\/([0-9]+)/)[1];
cy.visit(`build/${buildid}/files`);

cy.contains('a', 'RemovalWorksAsExpected').invoke('attr', 'href')
.should('match', new RegExp (`builds?\\/${buildid}`));

// verify contents of the page
cy.get('h3').should('contain', 'URLs or Files submitted with this build');
cy.get('#filesTable').find('tbody').find('tr').as('table_rows').should('have.length', 2);

cy.get('#filesTable').find('thead').find('th').eq(0).should('contain', 'File');
cy.get('#filesTable').find('thead').find('th').eq(1).should('contain', 'Size');
cy.get('#filesTable').find('thead').find('th').eq(2).should('contain', 'SHA-1');

cy.get('@table_rows').eq(0).find('td').eq(1).should('contain', '418 b');
cy.get('@table_rows').eq(0).find('td').eq(2).should('contain', '3dca430f053532f670584760f41ce9ac0779dd9f');
cy.get('@table_rows').eq(1).find('td').eq(1).should('contain', '1016 b');
cy.get('@table_rows').eq(1).find('td').eq(2).should('contain', '4bbfc85cc17f93a41457544319eb664a0955a845');

// verify the file names and urls
cy.get('@table_rows').eq(0).find('td').eq(0).find('a').as('file1_td');
cy.get('@table_rows').eq(1).find('td').eq(0).find('a').as('file2_td');

const file_url_regex = new RegExp(`builds?\\/${buildid}\\/files?\\/[0-9]+`);

cy.get('@file1_td').find('img').should('have.attr', 'src').and('contain', 'img/package.png');
cy.get('@file1_td').should('contain', 'smile.gif');
cy.get('@file1_td').invoke('attr', 'href').should('match', file_url_regex);

cy.get('@file2_td').find('img').should('have.attr', 'src').and('contain', 'img/package.png');
cy.get('@file2_td').should('contain', 'smile2.gif');
cy.get('@file2_td').invoke('attr', 'href').should('match', file_url_regex);
// TODO: test that the path acutally works and the file is downloadable
});
});
});