소스 검색

Merge pull request #13532 from shariquerik/date-field-validation-fix

fix: datetime field form validation
version-14
Suraj Shetty 3 년 전
committed by GitHub
부모
커밋
37d3555f1e
No known key found for this signature in database GPG 키 ID: 4AEE18F83AFDEB23
3개의 변경된 파일36개의 추가작업 그리고 0개의 파일을 삭제
  1. +19
    -0
      cypress/integration/datetime_field_form_validation.js
  2. +5
    -0
      frappe/public/js/frappe/form/controls/datetime.js
  3. +12
    -0
      frappe/tests/ui_test_helpers.py

+ 19
- 0
cypress/integration/datetime_field_form_validation.js 파일 보기

@@ -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');
});
});
});

+ 5
- 0
frappe/public/js/frappe/form/controls/datetime.js 파일 보기

@@ -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);
}
};

+ 12
- 0
frappe/tests/ui_test_helpers.py 파일 보기

@@ -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


불러오는 중...
취소
저장