<commit_before>import unittest
from selenium import webdriver

from app.config import SecureMessaging


class TestDraft(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Chrome(executable_path=SecureMessaging.chrome_driver)
        self.driver.implicitly_wait(30)

        # navigate to the create message page
        self.driver.get("http://0.0.0.0:5001/secure-message/create-message")

    def save_message_test(self):
        # Save a draft
        self.subject_field = self.driver.find_element_by_id("secure-message-subject").send_keys('Test Subject ')
        self.body_field = self.driver.find_element_by_id("secure-message-body").send_keys('Test Body ')
        self.driver.find_element_by_id("draft").click()
        self.assertTrue(self.driver.find_element_by_id('inbox-link'))

        # Open a saved draft
        self.driver.get("http://0.0.0.0:5001/secure-message/messages/DRAFT")
        self.driver.find_element_by_link_text("Test Subject").click()
        self.assertTrue(self.driver.find_element_by_id('inbox-link'))

        # Change text in draft and save
        self.subject_field = self.driver.find_element_by_id("secure-message-subject").send_keys('Edited')
        self.body_field = self.driver.find_element_by_id("secure-message-body").send_keys('Edited')<commit_msg>Extracted duplicate code, improved readability<commit_after>import unittest
from selenium import webdriver

from app.config import SecureMessaging


class TestDraft(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Chrome(executable_path=SecureMessaging.chrome_driver)
        self.driver.implicitly_wait(30)

        # navigate to the create message page
        self.driver.get("http://0.0.0.0:5001/secure-message/create-message")

    def test_check_saved_draft(self):
        self.subject_field = self.driver.find_element_by_id("secure-message-subject").send_keys('Test Subject ')
        self.body_field = self.driver.find_element_by_id("secure-message-body").send_keys('Test Body ')
        self.driver.find_element_by_id("draft").click()
        self.assertTrue(self.driver.find_element_by_id('inbox-link'))

    def test_open_saved_draft(self):
        self.driver.get("http://0.0.0.0:5001/secure-message/messages/DRAFT")
        self.driver.find_element_by_link_text("Test Subject").click()
        self.assertTrue(self.driver.find_element_by_id('inbox-link'))

    def test_edit_saved_draft_then_save(self):
        self.driver.get("http://0.0.0.0:5001/secure-message/messages/DRAFT")
        self.driver.find_element_by_link_text("Test Subject").click()
        self.subject_field = self.driver.find_element_by_id("secure-message-subject").send_keys('Edited')
        self.body_field = self.driver.find_element_by_id("secure-message-body").send_keys('Edited')
{'fraction_non_alphanumeric': 0.125311498754005, 'fraction_numerical': 0.015663937344250624, 'mean_word_length': 4.017857142857143, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 5, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5984709', 'n_tokens_mistral': 914, 'n_tokens_neox': 885, 'n_words': 107}