Add tests for status update and API failure
Add tests for mailto email contact
Details
- Reviewers
anlambert - Group Reviewers
Reviewers - Commits
- rDWAPPSe28c8b5e78c7: Add missing cypress tests for 'add-forge-now' request dashboard
Diff Detail
- Repository
- rDWAPPS Web applications
- Branch
- cypress-tests
- Lint
No Linters Available - Unit
No Unit Test Coverage - Build Status
Buildable 27894 Build 43676: Phabricator diff pipeline on jenkins Jenkins console · Jenkins Build 43675: arc lint + arc unit
Event Timeline
Build has FAILED
Patch application report for D7451 (id=26977)
Rebasing onto 4bc8aaf1d9...
Current branch diff-target is up to date.
Changes applied before test
commit 48d8c0f3559fae428dd2d67b77102c2ae9a30f4d Author: Jayesh Velayudhan <jayesh@softwareheritage.org> Date: Tue Mar 29 12:00:00 2022 +0200 Add missing cypress tests to 'add-fore-now' request dashboard Add tests for status update and API failiure Add tests for mailto email contact
Link to build: https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/1616/
See console output for more information: https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/1616/console
Build is green
Patch application report for D7451 (id=26978)
Rebasing onto 4bc8aaf1d9...
Current branch diff-target is up to date.
Changes applied before test
commit 5e38178834e6a063326f4954d2541c56d9dda0ef Author: Jayesh Velayudhan <jayesh@softwareheritage.org> Date: Tue Mar 29 12:26:53 2022 +0200 Add missing cypress tests for 'add-fore-now' request dashboard Add tests for status update and API failiure Add tests for mailto email contact
See https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/1618/ for more details.
Build is green
Patch application report for D7451 (id=26985)
Rebasing onto f7281122f2...
First, rewinding head to replay your work on top of it... Applying: Add missing cypress tests for 'add-forge-now' request dashboard
Changes applied before test
commit 4c4688ecc6a83ed0d911982f1f30a3da62773fdb Author: Jayesh Velayudhan <jayesh@softwareheritage.org> Date: Tue Mar 29 14:23:50 2022 +0200 Add missing cypress tests for 'add-forge-now' request dashboard Add tests for status update and API failiure Add tests for mailto email contact
See https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/1622/ for more details.
cypress/integration/add-forge-now-request-dashboard.spec.js | ||
---|---|---|
105–108 | Instead of using a cypress fixture, you should rather drop the add forge now database tables using the cypress task db:add_forge_now:delete added by @ardumont. It has the advantage to avoid mocking the HTTP request responses. So you can replace these two lines by: cy.intercept(`${this.Urls.api_1_add_forge_request_get(requestId)}**` .as('forgeAddRequest'); cy.intercept('POST', `${this.Urls.api_1_add_forge_request_update(requestId)}**`, .as('updateRequest'); cy.task('db:add_forge_now:delete'); I think you will also have to drop the add_forge_now_request_history in the db:add_forge_now:delete task implementation. |
cypress/integration/add-forge-now-request-dashboard.spec.js | ||
---|---|---|
105–108 | So I managed to avoid using fixtures the following way using cy.request to create a new add forge request through a call to the Web API: diff --git a/cypress/integration/add-forge-now-request-dashboard.spec.js b/cypress/integration/add-forge-now-request-dashboard.spec.js index 282291c1..07db0a6c 100644 --- a/cypress/integration/add-forge-now-request-dashboard.spec.js +++ b/cypress/integration/add-forge-now-request-dashboard.spec.js @@ -101,16 +101,44 @@ describe('Test forge now request update', function() { beforeEach(function() { const url = this.Urls.add_forge_now_request_dashboard(requestId); - cy.adminLogin(); + cy.intercept(`${this.Urls.api_1_add_forge_request_get(requestId)}**`) + .as('forgeAddRequest'); + cy.intercept('POST', `${this.Urls.api_1_add_forge_request_update(requestId)}**`) + .as('updateRequest'); + cy.task('db:add_forge_now:delete'); + + cy.userLogin(); + cy.visit(url); - cy.intercept(`${this.Urls.api_1_add_forge_request_get(requestId)}**`, - {fixture: 'add-forge-now-request'}).as('forgeAddRequest'); - cy.intercept('POST', `${this.Urls.api_1_add_forge_request_update(requestId)}**`, - {fixture: 'add-forge-now-request'}).as('updateRequest'); + cy.getCookie('csrftoken').its('value').then((token) => { + cy.request({ + method: 'POST', + url: this.Urls.api_1_add_forge_request_create(), + body: { + forge_type: 'bitbucket', + forge_url: 'test.com', + forge_contact_email: 'test@example.com', + forge_contact_name: 'test user', + submitter_forward_username: true, + forge_contact_comment: 'test comment' + }, + headers: { + 'X-CSRFToken': token + } + }); + }); + + cy.contains('a', 'logout').click(); + + cy.adminLogin(); cy.visit(url); + }); it('should post data on submit', function() { + cy.get('#decisionOptions').select('WAITING_FOR_FEEDBACK'); cy.get('#updateComment').type('This is an update comment'); cy.get('#updateRequestForm').submit(); @@ -126,6 +154,7 @@ describe('Test forge now request update', function() { }); it('should show an error on API failiure', function() { + cy.intercept('POST', `${this.Urls.api_1_add_forge_request_update(requestId)}**`, {forceNetworkError: true}) diff --git a/cypress/plugins/index.js b/cypress/plugins/index.js index eeb7373b..3f66173c 100644 --- a/cypress/plugins/index.js +++ b/cypress/plugins/index.js @@ -150,7 +150,10 @@ module.exports = (on, config) => { 'db:add_forge_now:delete': () => { const db = getDatabase(); db.serialize(function() { + db.run('DELETE FROM add_forge_now_requesthistory'); + db.run('DELETE FROM sqlite_sequence WHERE name="add_forge_now_requesthistory"'); db.run('DELETE FROM add_forge_now_request'); + db.run('DELETE FROM sqlite_sequence WHERE name="add_forge_now_request"'); }); db.close(); return true; I lost some debugging time on the request id as sqlite3 does not reset id sequences by default. |
Build has FAILED
Patch application report for D7451 (id=27089)
Rebasing onto 0dc0765eed...
Current branch diff-target is up to date.
Changes applied before test
commit 3add2a70b3dacf3fa49f0e56f10bf270449b9338 Author: Jayesh Velayudhan <jayesh@softwareheritage.org> Date: Wed Mar 30 11:45:42 2022 +0200 Add missing cypress tests for 'add-forge-now' request dashboard Remove mock fixture from load tests. Add tests for status update and API failure. Add tests for mailto email contact.
Link to build: https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/1638/
See console output for more information: https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/1638/console
Build is green
Patch application report for D7451 (id=27093)
Rebasing onto 0dc0765eed...
Current branch diff-target is up to date.
Changes applied before test
commit 9daf78d2be2e6b94372778d95c7c5bd1b7fa60c5 Author: Jayesh Velayudhan <jayesh@softwareheritage.org> Date: Wed Mar 30 12:07:58 2022 +0200 Add missing cypress tests for 'add-forge-now' request dashboard Remove mock fixture from load tests. Add tests for status update and API failure. Add tests for mailto email contact.
See https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/1639/ for more details.
Build is green
Patch application report for D7451 (id=27094)
Rebasing onto 0dc0765eed...
Current branch diff-target is up to date.
Changes applied before test
commit 5ea2dcd599074ea7b67b7c0124a5ee47d68fc1c2 Author: Jayesh Velayudhan <jayesh@softwareheritage.org> Date: Wed Mar 30 12:19:19 2022 +0200 Add missing cypress tests for 'add-forge-now' request dashboard Remove mock fixture from load tests. Add tests for status update and API failure. Add tests for mailto email contact.
See https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/1640/ for more details.
Build is green
Patch application report for D7451 (id=27106)
Rebasing onto cc4a82eb38...
First, rewinding head to replay your work on top of it... Applying: Add missing cypress tests for 'add-forge-now' request dashboard
Changes applied before test
commit e6b1b66d03f796f6e4b0f43771e8d9ba699f694d Author: Jayesh Velayudhan <jayesh@softwareheritage.org> Date: Wed Mar 30 14:03:12 2022 +0200 Add missing cypress tests for 'add-forge-now' request dashboard Remove mock fixture from load tests. Add tests for status update and API failure. Add tests for mailto email contact.
See https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/1641/ for more details.
Build is green
Patch application report for D7451 (id=27107)
Rebasing onto cc4a82eb38...
Current branch diff-target is up to date.
Changes applied before test
commit e28c8b5e78c776aebc12ff577ed50130d4822ca5 Author: Jayesh Velayudhan <jayesh@softwareheritage.org> Date: Wed Mar 30 14:03:12 2022 +0200 Add missing cypress tests for 'add-forge-now' request dashboard Remove mock fixture from load tests. Add tests for status update and API failure. Add tests for mailto email contact.
See https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/1642/ for more details.