<commit_before>import zeit.content.article.edit.browser.testing


class Supertitle(zeit.content.article.edit.browser.testing.EditorTestCase):

    supertitle = 'article-content-head.supertitle'
    teaser_supertitle = 'teaser-supertitle.teaserSupertitle'

    layer = zeit.content.article.testing.WEBDRIVER_LAYER

    def setUp(self):
        super(Supertitle, self).setUp()
        self.open('/repository/online/2007/01/Somalia/@@checkout')
        self.selenium.waitForElementPresent('id=%s' % self.teaser_supertitle)

    def test_teaser_supertitle_is_copied_to_article_supertitle_if_empty(self):
        s = self.selenium
        self.eval('document.getElementById("%s").value = ""' % self.supertitle)
        s.click('//a[@href="edit-form-teaser"]')
        s.type('id=%s' % self.teaser_supertitle, 'super\t')
        # XXX There's nothing asynchronous going on here, but with a direct
        # assert, the test fails with "Element is no longer attached to the
        # DOM" (at least on WS's machine).
        s.waitForValue('id=%s' % self.supertitle, 'super')<commit_msg>Fix test that may break with DOM element no longer attached, since the DOM element in question is reloaded.<commit_after>import zeit.content.article.edit.browser.testing
import time


class Supertitle(zeit.content.article.edit.browser.testing.EditorTestCase):

    supertitle = 'article-content-head.supertitle'
    teaser_supertitle = 'teaser-supertitle.teaserSupertitle'

    layer = zeit.content.article.testing.WEBDRIVER_LAYER

    def setUp(self):
        super(Supertitle, self).setUp()
        self.open('/repository/online/2007/01/Somalia/@@checkout')
        self.selenium.waitForElementPresent('id=%s' % self.teaser_supertitle)

    def test_teaser_supertitle_is_copied_to_article_supertitle_if_empty(self):
        s = self.selenium
        self.eval('document.getElementById("%s").value = ""' % self.supertitle)
        s.click('//a[@href="edit-form-teaser"]')
        s.type('id=%s' % self.teaser_supertitle, 'super\t')

        # We cannot use waitForValue, since the DOM element changes in-between
        # but Selenium retrieves the element once and only checks the value
        # repeatedly, thus leading to an error that DOM is no longer attached
        for i in range(10):
            try:
                s.assertValue('id=%s' % self.supertitle, 'super')
                break
            except:
                time.sleep(0.1)
                continue
        s.assertValue('id=%s' % self.supertitle, 'super')
{'fraction_non_alphanumeric': 0.1173428798727128, 'fraction_numerical': 0.006364359586316627, 'mean_word_length': 3.1639072847682117, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '370463', 'n_tokens_mistral': 803, 'n_tokens_neox': 745, 'n_words': 154}