Changeset View
Changeset View
Standalone View
Standalone View
cypress/integration/add-forge-now-request-dashboard.spec.js
/** | /** | ||||
* Copyright (C) 2022 The Software Heritage developers | * Copyright (C) 2022 The Software Heritage developers | ||||
* See the AUTHORS file at the top-level directory of this distribution | * See the AUTHORS file at the top-level directory of this distribution | ||||
* License: GNU Affero General Public License version 3, or any later version | * License: GNU Affero General Public License version 3, or any later version | ||||
* See top-level LICENSE file for more information | * See top-level LICENSE file for more information | ||||
*/ | */ | ||||
let requestId; | let requestId, forgeDomain; | ||||
function createDummyRequest(urls) { | function createDummyRequest(urls) { | ||||
cy.task('db:add_forge_now:delete'); | cy.task('db:add_forge_now:delete'); | ||||
cy.userLogin(); | cy.userLogin(); | ||||
cy.getCookie('csrftoken').its('value').then((token) => { | cy.getCookie('csrftoken').its('value').then((token) => { | ||||
cy.request({ | cy.request({ | ||||
method: 'POST', | method: 'POST', | ||||
url: urls.api_1_add_forge_request_create(), | url: urls.api_1_add_forge_request_create(), | ||||
body: { | body: { | ||||
forge_type: 'bitbucket', | forge_type: 'bitbucket', | ||||
forge_url: 'test.example.com', | forge_url: 'test.example.com', | ||||
forge_contact_email: 'test@example.com', | forge_contact_email: 'test@example.com', | ||||
forge_contact_name: 'test user', | forge_contact_name: 'test user', | ||||
submitter_forward_username: true, | submitter_forward_username: true, | ||||
forge_contact_comment: 'test comment' | forge_contact_comment: 'test comment' | ||||
}, | }, | ||||
headers: { | headers: { | ||||
'X-CSRFToken': token | 'X-CSRFToken': token | ||||
} | } | ||||
}).then((response) => { | }).then((response) => { | ||||
// setting requestId from response | // setting requestId and forgeDomain from response | ||||
requestId = response.body.id; | requestId = response.body.id; | ||||
forgeDomain = response.body.forge_domain; | |||||
// logout the user | // logout the user | ||||
cy.visit(urls.swh_web_homepage()); | cy.visit(urls.swh_web_homepage()); | ||||
cy.contains('a', 'logout').click(); | cy.contains('a', 'logout').click(); | ||||
}); | }); | ||||
}); | }); | ||||
} | } | ||||
describe('Test add forge now request dashboard load', function() { | describe('Test add forge now request dashboard load', function() { | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | it('should show send message link', function() { | ||||
cy.wait('@forgeRequestGet'); | cy.wait('@forgeRequestGet'); | ||||
cy.get('#contactForgeAdmin') | cy.get('#contactForgeAdmin') | ||||
.should('have.attr', 'emailto') | .should('have.attr', 'emailto') | ||||
.and('include', 'test@example.com'); | .and('include', 'test@example.com'); | ||||
cy.get('#contactForgeAdmin') | cy.get('#contactForgeAdmin') | ||||
.should('have.attr', 'emailsubject') | .should('have.attr', 'emailsubject') | ||||
.and('include', `[swh-add_forge_now] Request ${requestId}`); | .and('include', `Software Heritage archival request for ${forgeDomain}`); | ||||
}); | }); | ||||
it('should not show any error message', function() { | it('should not show any error message', function() { | ||||
cy.wait('@forgeRequestGet'); | cy.wait('@forgeRequestGet'); | ||||
cy.get('#fetchError') | cy.get('#fetchError') | ||||
.should('have.class', 'd-none'); | .should('have.class', 'd-none'); | ||||
cy.get('#requestDetails') | cy.get('#requestDetails') | ||||
▲ Show 20 Lines • Show All 131 Lines • Show Last 20 Lines |