Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7123477
D8516.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
8 KB
Subscribers
None
D8516.diff
View Options
diff --git a/cypress/e2e/add-forge-now-request-create.cy.js b/cypress/e2e/add-forge-now-request-create.cy.js
--- a/cypress/e2e/add-forge-now-request-create.cy.js
+++ b/cypress/e2e/add-forge-now-request-create.cy.js
@@ -7,7 +7,9 @@
function populateForm(type, url, contact, email, consent, comment) {
cy.get('#swh-input-forge-type').select(type);
- cy.get('#swh-input-forge-url').clear().type(url);
+ if (url) {
+ cy.get('#swh-input-forge-url').clear().type(url);
+ }
cy.get('#swh-input-forge-contact-name').clear().type(contact);
cy.get('#swh-input-forge-contact-email').clear().type(email);
if (comment) {
@@ -16,10 +18,28 @@
cy.get('#swh-input-consent-check').click({force: consent === 'on'});
}
+function submitForm() {
+ cy.get('#requestCreateForm input[type=submit]').click();
+ cy.get('#requestCreateForm').then($form => {
+ if ($form[0].checkValidity()) {
+ cy.wait('@addForgeRequestCreate');
+ }
+ });
+}
+
+function initTest(testEnv) {
+ testEnv.addForgeNowUrl = testEnv.Urls.forge_add_create();
+ testEnv.addForgeNowRequestCreateUrl = testEnv.Urls.api_1_add_forge_request_create();
+ testEnv.listAddForgeRequestsUrl = testEnv.Urls.add_forge_request_list_datatables();
+ cy.intercept('POST', testEnv.addForgeNowRequestCreateUrl + '**')
+ .as('addForgeRequestCreate');
+ cy.intercept(testEnv.listAddForgeRequestsUrl + '**')
+ .as('addForgeRequestsList');
+}
+
describe('Browse requests list tests', function() {
beforeEach(function() {
- this.addForgeNowUrl = this.Urls.forge_add_create();
- this.listAddForgeRequestsUrl = this.Urls.add_forge_request_list_datatables();
+ initTest(this);
});
it('should not show user requests filter checkbox for anonymous users', function() {
@@ -44,7 +64,7 @@
// create requests for the user 'user'
populateForm('gitlab', 'https://gitlab.org', 'admin', 'admin@example.org', 'on', '');
- cy.get('#requestCreateForm').submit();
+ submitForm();
// user requests filter checkbox should be in the DOM
cy.get('#swh-add-forge-requests-list-tab').click();
@@ -63,12 +83,9 @@
cy.visit(this.addForgeNowUrl);
populateForm('gitea', 'https://gitea.org', 'admin', 'admin@example.org', 'on', '');
- cy.get('#requestCreateForm').submit();
+ submitForm();
populateForm('cgit', 'https://cgit.org', 'admin', 'admin@example.org', 'on', '');
- cy.get('#requestCreateForm').submit();
-
- cy.intercept(this.Urls.add_forge_request_list_datatables() + '**')
- .as('addForgeRequestsList');
+ submitForm();
// user requests filter checkbox should be in the DOM
cy.get('#swh-add-forge-requests-list-tab').click();
@@ -95,7 +112,7 @@
describe('Test add-forge-request creation', function() {
beforeEach(function() {
- this.addForgeNowUrl = this.Urls.forge_add_create();
+ initTest(this);
});
it('should show all the tabs for every user', function() {
@@ -216,10 +233,13 @@
cy.userLogin();
cy.visit(this.addForgeNowUrl);
populateForm('bitbucket', 'https://gitlab.com', 'test', 'test@example.com', 'on', 'test comment');
- cy.get('#requestCreateForm').submit();
+ submitForm();
cy.visit(this.addForgeNowUrl);
cy.get('#swh-add-forge-requests-list-tab').click();
+
+ cy.wait('@addForgeRequestsList');
+
cy.get('#add-forge-request-browse')
.should('be.visible')
.should('contain', 'gitlab.com');
@@ -233,9 +253,9 @@
cy.userLogin();
cy.visit(this.addForgeNowUrl);
populateForm('bitbucket', 'https://gitlab.com', 'test', 'test@example.com', 'on', 'test comment');
- cy.get('#requestCreateForm').submit();
+ submitForm();
- cy.get('#requestCreateForm').submit(); // Submitting the same data again
+ submitForm(); // Submitting the same data again
cy.get('#userMessage')
.should('have.class', 'badge-danger')
@@ -245,34 +265,24 @@
it('should show error message', function() {
cy.userLogin();
- cy.intercept('POST', `${this.Urls.api_1_add_forge_request_create()}**`,
- {
- body: {
- 'exception': 'BadInputExc',
- 'reason': '{"add-forge-comment": ["This field is required"]}'
- },
- statusCode: 400
- }).as('errorRequest');
-
cy.visit(this.addForgeNowUrl);
populateForm(
- 'bitbucket', 'https://gitlab.com', 'test', 'test@example.com', 'off', 'comment'
+ 'bitbucket', '', 'test', 'test@example.com', 'off', 'comment'
+ );
+ submitForm();
+
+ cy.get('#requestCreateForm').then(
+ $form => expect($form[0].checkValidity()).to.be.false
);
- cy.get('#requestCreateForm').submit();
- cy.wait('@errorRequest').then((xhr) => {
- cy.get('#userMessage')
- .should('have.class', 'badge-danger')
- .should('contain', 'field is required');
- });
});
- it('should bot validate form when forge URL is invalid', function() {
+ it('should not validate form when forge URL is invalid', function() {
cy.userLogin();
cy.visit(this.addForgeNowUrl);
populateForm('bitbucket', 'bitbucket.org', 'test', 'test@example.com', 'on', 'test comment');
- cy.get('#requestCreateForm').submit();
+ submitForm();
cy.get('#swh-input-forge-url')
.then(input => {
diff --git a/cypress/e2e/add-forge-now-request-dashboard.cy.js b/cypress/e2e/add-forge-now-request-dashboard.cy.js
--- a/cypress/e2e/add-forge-now-request-dashboard.cy.js
+++ b/cypress/e2e/add-forge-now-request-dashboard.cy.js
@@ -192,7 +192,7 @@
function populateAndSubmitForm() {
cy.get('#decisionOptions').select('WAITING_FOR_FEEDBACK');
cy.get('#updateComment').type('This is an update comment');
- cy.get('#updateRequestForm').submit();
+ cy.get('#updateRequestForm button[type=submit]').click();
}
describe('Test add forge now request update', function() {
@@ -301,7 +301,7 @@
{forceNetworkError: true})
.as('updateFailedRequest');
cy.get('#updateComment').type('This is an update comment');
- cy.get('#updateRequestForm').submit();
+ cy.get('#updateRequestForm button[type=submit]').click();
cy.wait('@updateFailedRequest');
cy.get('#userMessage')
diff --git a/cypress/e2e/add-forge-now-requests-moderation.cy.js b/cypress/e2e/add-forge-now-requests-moderation.cy.js
--- a/cypress/e2e/add-forge-now-requests-moderation.cy.js
+++ b/cypress/e2e/add-forge-now-requests-moderation.cy.js
@@ -21,8 +21,8 @@
.type('admin')
.get('input[name="password"]')
.type('admin')
- .get('.container form')
- .submit();
+ .get('.container form button[type=submit]')
+ .click();
cy.location('pathname')
.should('be.equal', this.addForgeModerationUrl);
diff --git a/cypress/e2e/admin.cy.js b/cypress/e2e/admin.cy.js
--- a/cypress/e2e/admin.cy.js
+++ b/cypress/e2e/admin.cy.js
@@ -23,8 +23,8 @@
.type('admin')
.get('input[name="password"]')
.type('admin')
- .get('.container form')
- .submit();
+ .get('.container form button[type=submit]')
+ .click();
cy.location('pathname')
.should('be.equal', this.Urls.swh_web_homepage());
diff --git a/cypress/e2e/layout.cy.js b/cypress/e2e/layout.cy.js
--- a/cypress/e2e/layout.cy.js
+++ b/cypress/e2e/layout.cy.js
@@ -191,8 +191,8 @@
cy.get('#swh-origins-search-top-input')
.type(keyword);
- cy.get('.swh-search-navbar')
- .submit();
+ cy.get('#swh-origins-search-top button[type=submit]')
+ .click({force: true});
cy.url()
.should('include', `${this.Urls.browse_search()}?q=${keyword}`);
diff --git a/cypress/e2e/origin-save.cy.js b/cypress/e2e/origin-save.cy.js
--- a/cypress/e2e/origin-save.cy.js
+++ b/cypress/e2e/origin-save.cy.js
@@ -30,8 +30,8 @@
.type(originUrl)
.get('#swh-input-visit-type')
.select(originType)
- .get('#swh-save-origin-form')
- .submit();
+ .get('#swh-save-origin-form button[type=submit]')
+ .click();
}
function checkAlertVisible(alertType, msg) {
@@ -618,8 +618,8 @@
.get('#swh-input-artifact-version-0')
.clear()
.type(artifactVersion)
- .get('#swh-save-origin-form')
- .submit();
+ .get('#swh-save-origin-form button[type=submit]')
+ .click();
cy.wait('@saveRequest').then(() => {
checkAlertVisible('success', saveCodeMsg['success']);
@@ -696,8 +696,8 @@
}).as('saveRequest');
// submit form
- cy.get('#swh-save-origin-form')
- .submit();
+ cy.get('#swh-save-origin-form button[type=submit]')
+ .click();
// submission should be successful
cy.wait('@saveRequest').then(() => {
@@ -776,8 +776,8 @@
.type(originUrl);
// submit form
- cy.get('#swh-save-origin-form')
- .submit();
+ cy.get('#swh-save-origin-form button[type=submit]')
+ .click();
// submission should be successful
cy.wait('@ghWebApiRequest')
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Dec 19 2024, 9:32 AM (11 w, 23 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3218473
Attached To
D8516: cypress: Use click command instead of submit one for form submission
Event Timeline
Log In to Comment