Merge pull request #13532 from shariquerik/date-field-validation-fix
fix: datetime field form validation
This commit is contained in:
commit
37d3555f1e
3 changed files with 36 additions and 0 deletions
19
cypress/integration/datetime_field_form_validation.js
Normal file
19
cypress/integration/datetime_field_form_validation.js
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
context('Datetime Field Validation', () => {
|
||||
before(() => {
|
||||
cy.login();
|
||||
cy.visit('/app/communication');
|
||||
cy.window().its('frappe').then(frappe => {
|
||||
frappe.call("frappe.tests.ui_test_helpers.create_communication_records");
|
||||
});
|
||||
});
|
||||
|
||||
// validating datetime field value when value is set from backend and get validated on form load.
|
||||
it('datetime field form validation', () => {
|
||||
cy.visit('/app/communication');
|
||||
cy.get('a[title="Test Form Communication 1"]').invoke('attr', 'data-name')
|
||||
.then((name) => {
|
||||
cy.visit(`/app/communication/${name}`);
|
||||
cy.get('.indicator-pill').should('contain', 'Open').should('have.class', 'red');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -36,4 +36,9 @@ frappe.ui.form.ControlDatetime = class ControlDatetime extends frappe.ui.form.Co
|
|||
$tp.$secondsText.prev().css('display', 'none');
|
||||
}
|
||||
}
|
||||
|
||||
get_model_value() {
|
||||
let value = super.get_model_value();
|
||||
return frappe.datetime.get_datetime_as_string(value);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -61,6 +61,18 @@ def create_todo_records():
|
|||
"description": "this is fourth todo"
|
||||
}).insert()
|
||||
|
||||
@frappe.whitelist()
|
||||
def create_communication_records():
|
||||
if frappe.db.get_all('Communication', {'subject': 'Test Form Communication 1'}):
|
||||
return
|
||||
|
||||
frappe.get_doc({
|
||||
"doctype": "Communication",
|
||||
"recipients": "test@gmail.com",
|
||||
"subject": "Test Form Communication 1",
|
||||
"communication_date": frappe.utils.now_datetime(),
|
||||
}).insert()
|
||||
|
||||
@frappe.whitelist()
|
||||
def setup_workflow():
|
||||
from frappe.workflow.doctype.workflow.test_workflow import create_todo_workflow
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue