test: Exit Interview
diff --git a/erpnext/hr/doctype/exit_interview/exit_interview.json b/erpnext/hr/doctype/exit_interview/exit_interview.json
index 4b39640..86720a1 100644
--- a/erpnext/hr/doctype/exit_interview/exit_interview.json
+++ b/erpnext/hr/doctype/exit_interview/exit_interview.json
@@ -30,7 +30,7 @@
   "reference_document_name",
   "interview_summary_section",
   "interviewers",
-  "text_editor_12",
+  "interview_summary",
   "employee_status_section",
   "employee_status",
   "amended_from"
@@ -113,11 +113,6 @@
    "label": "Interview Details"
   },
   {
-   "fieldname": "text_editor_12",
-   "fieldtype": "Text Editor",
-   "label": "Interview Summary"
-  },
-  {
    "fieldname": "column_break_10",
    "fieldtype": "Column Break"
   },
@@ -213,12 +208,17 @@
    "options": "Exit Interview",
    "print_hide": 1,
    "read_only": 1
+  },
+  {
+   "fieldname": "interview_summary",
+   "fieldtype": "Text Editor",
+   "label": "Interview Summary"
   }
  ],
  "index_web_pages_for_search": 1,
  "is_submittable": 1,
  "links": [],
- "modified": "2021-12-05 18:56:34.856854",
+ "modified": "2021-12-07 14:08:29.355390",
  "modified_by": "Administrator",
  "module": "HR",
  "name": "Exit Interview",
diff --git a/erpnext/hr/doctype/exit_interview/exit_interview.py b/erpnext/hr/doctype/exit_interview/exit_interview.py
index e72c47e..30e19f1 100644
--- a/erpnext/hr/doctype/exit_interview/exit_interview.py
+++ b/erpnext/hr/doctype/exit_interview/exit_interview.py
@@ -109,7 +109,7 @@
 
 	if not settings.exit_questionnaire_web_form or not settings.exit_questionnaire_notification_template:
 		frappe.throw(
-			message=_('Please set {0} and {1} in {2}.').format(
+			_('Please set {0} and {1} in {2}.').format(
 				frappe.bold('Exit Questionnaire Web Form'),
 				frappe.bold('Notification Template'),
 				get_link_to_form('HR Settings', 'HR Settings')),
@@ -122,8 +122,10 @@
 	if email_success:
 		message += _('{0}: {1}').format(
 			frappe.bold('Sent Successfully'), ', '.join(email_success))
+	if message and email_failure:
+		message += '<br><br>'
 	if email_failure:
-		message += '<br><br>' + _('{0} due to missing email information for employee(s): {1}').format(
+		message += _('{0} due to missing email information for employee(s): {1}').format(
 			frappe.bold('Sending Failed'), ', '.join(email_failure))
 
 	frappe.msgprint(message, title=_('Exit Questionnaire'), indicator='blue', is_minimizable=True, wide=True)
\ No newline at end of file
diff --git a/erpnext/hr/doctype/exit_interview/test_exit_interview.py b/erpnext/hr/doctype/exit_interview/test_exit_interview.py
index 3a6316c..8eeb4a1 100644
--- a/erpnext/hr/doctype/exit_interview/test_exit_interview.py
+++ b/erpnext/hr/doctype/exit_interview/test_exit_interview.py
@@ -1,9 +1,89 @@
 # Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and Contributors
 # See license.txt
 
-# import frappe
 import unittest
 
+import frappe
+from frappe.core.doctype.user_permission.test_user_permission import create_user
+from frappe.tests.test_webform import create_custom_doctype, create_webform
+from frappe.utils import getdate
+
+from erpnext.hr.doctype.employee.test_employee import make_employee
+from erpnext.hr.doctype.exit_interview.exit_interview import send_exit_questionnaire
+
 
 class TestExitInterview(unittest.TestCase):
-	pass
+	def test_duplicate_interview(self):
+		employee = make_employee('employeeexit1@example.com')
+		frappe.db.set_value('Employee', employee, 'relieving_date', getdate())
+		interview = create_exit_interview(employee)
+
+		doc = frappe.copy_doc(interview)
+		self.assertRaises(frappe.DuplicateEntryError, doc.save)
+
+	def test_relieving_date_validation(self):
+		employee = make_employee('employeeexit2@example.com')
+
+		interview = create_exit_interview(employee, save=False)
+		self.assertRaises(frappe.ValidationError, interview.save)
+
+		# set relieving date
+		frappe.db.set_value('Employee', employee, 'relieving_date', getdate())
+		interview = create_exit_interview(employee)
+		self.assertTrue(interview.name)
+
+	def test_interview_date_updated_in_employee_master(self):
+		employee = make_employee('employeeexit3@example.com')
+		frappe.db.set_value('Employee', employee, 'relieving_date', getdate())
+
+		interview = create_exit_interview(employee)
+		interview.status = 'Completed'
+		interview.employee_status = 'Exit Confirmed'
+
+		# exit interview date updated on submit
+		interview.submit()
+		self.assertEqual(frappe.db.get_value('Employee', employee, 'held_on'), interview.date)
+
+		# exit interview reset on cancel
+		interview.reload()
+		interview.cancel()
+		self.assertEqual(frappe.db.get_value('Employee', employee, 'held_on'), None)
+
+	def test_send_exit_questionnaire(self):
+		create_custom_doctype()
+		create_webform()
+
+		webform = frappe.db.get_all('Web Form', limit=1)
+		frappe.db.set_value('HR Settings', 'HR Settings', 'exit_questionnaire_web_form', webform[0].name)
+
+		employee = make_employee('employeeexit3@example.com')
+		frappe.db.set_value('Employee', employee, 'relieving_date', getdate())
+
+		interview = create_exit_interview(employee)
+		send_exit_questionnaire([interview])
+
+		email_queue = frappe.db.get_all('Email Queue', ['name', 'message'], limit=1)
+		self.assertTrue('Subject: Exit Questionnaire Notification' in email_queue[0].message)
+
+	def tearDown(self):
+		frappe.db.rollback()
+
+
+def create_exit_interview(employee, save=True):
+	interviewer = create_user('test_interviewer1@example.com')
+
+	doc = frappe.get_doc({
+		'doctype': 'Exit Interview',
+		'employee': employee,
+		'company': '_Test Company',
+		'status': 'Pending',
+		'date': getdate(),
+		'interviewers': [{
+			'interviewer': interviewer.name
+		}],
+		'interview_summary': 'Test'
+	})
+
+	if save:
+		return doc.insert()
+	return doc