From 75cb917a7beee86d1d22a100f083a77b6f7ba925 Mon Sep 17 00:00:00 2001 From: shariquerik Date: Tue, 13 Jul 2021 21:31:03 +0530 Subject: [PATCH] test: UI test for datetime field form validation --- .../datetime_field_form_validation.js | 18 ++++++++++++++++++ frappe/tests/ui_test_helpers.py | 12 ++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 cypress/integration/datetime_field_form_validation.js diff --git a/cypress/integration/datetime_field_form_validation.js b/cypress/integration/datetime_field_form_validation.js new file mode 100644 index 0000000000..6a6ea4c7af --- /dev/null +++ b/cypress/integration/datetime_field_form_validation.js @@ -0,0 +1,18 @@ +context('Datetime Validation', () => { + before(() => { + cy.login(); + cy.visit('/app/communication'); + cy.window().its('frappe').then(frappe => { + frappe.call("frappe.tests.ui_test_helpers.create_communication_records"); + }); + }); + + 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'); + }) + }); +}); \ No newline at end of file diff --git a/frappe/tests/ui_test_helpers.py b/frappe/tests/ui_test_helpers.py index f56311b2e3..f4a6f474ce 100644 --- a/frappe/tests/ui_test_helpers.py +++ b/frappe/tests/ui_test_helpers.py @@ -60,6 +60,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