Пример #1
0
def test_translation(base_url, selenium):
    admin = AdminLogin(selenium, base_url).open()
    admin.login_moderator_user()
    page = EditPage(selenium, base_url, locale='fr').open()
    # CKEditor loads and is ready
    editor = page.editor()
    assert editor.ready
    # Tagit loads
    assert page.tagit_loaded
    # save button disabled
    assert page.is_save_button_disabled
    # edit in source mode, including an iframe, exit source mode
    editor.edit_source()
    content = editor.content_source()
    # iframe edit removed
    assert 'iframe' not in content
    # content edit remains
    assert 'Pumpkin' in content
    # save button enabled
    assert not page.is_save_button_disabled
    # check contents of draft
    draft_content = editor.draft_content(selenium.current_url)
    assert 'Pumpkin' in draft_content
    # discard
    page.discard()
Пример #2
0
def test_edit(base_url, selenium):
    admin = AdminLogin(selenium, base_url).open()
    admin.login_new_user()
    article_page = ArticlePage(selenium, base_url).open()
    page = article_page.click_edit(True)
    # welcome message displays
    assert page.is_first_contrib_welcome_displayed
    # CKEditor loads and is ready
    editor = page.editor()
    assert editor.ready
    # Tagit loads
    assert page.tagit_loaded
    # save button disabled
    assert page.is_save_button_disabled
    # edit in source mode, including an iframe, exit source mode
    editor.edit_source()
    content = editor.content_source()
    # iframe edit removed
    assert 'iframe' not in content
    # content edit remains
    assert 'Pumpkin' in content
    # check contents of draft
    draft_content = editor.draft_content(selenium.current_url)
    assert 'Pumpkin' in draft_content
    # save button enabled
    assert not page.is_save_button_disabled
    # discard
    page.discard()
Пример #3
0
def test_content_exp_logged_in(base_url, selenium, exp_id, locale, slug):
    data = get_experiment_data(exp_id, locale, slug)
    admin = AdminLogin(selenium, base_url).open()
    admin.login_new_user()
    page = ArticlePage(selenium, base_url, locale=locale, slug=slug).open()
    assert selenium.title == data['expected_title']
    assert selenium.current_url == page.seed_url
    assert page.has_edit_button
Пример #4
0
def test_content_exp_logged_in(base_url, selenium, exp_id, locale, slug):
    data = get_experiment_data(exp_id, locale, slug)
    admin = AdminLogin(selenium, base_url).open()
    admin.login_new_user()
    page = ArticlePage(selenium, base_url, locale=locale, slug=slug).open()
    assert selenium.title == data['expected_title']
    assert selenium.current_url == page.seed_url
    assert page.has_edit_button
Пример #5
0
def test_dashboard_super(base_url, selenium):
    admin = AdminLogin(selenium, base_url).open()
    admin.login_super_user()
    page = DashboardPage(selenium, base_url).open()
    first_row = page.first_row
    # ip toggle present
    assert page.is_ip_toggle_present
    # ip ban present
    assert first_row.is_ip_ban_present
    # spam ham button present
    assert first_row.is_spam_ham_button_present
Пример #6
0
def test_dashboard_super(base_url, selenium):
    admin = AdminLogin(selenium, base_url).open()
    admin.login_super_user()
    page = DashboardPage(selenium, base_url).open()
    first_row = page.first_row
    # ip toggle present
    assert page.is_ip_toggle_present
    # ip ban present
    assert first_row.is_ip_ban_present
    # spam ham button present
    assert first_row.is_spam_ham_button_present
Пример #7
0
def test_dashboard_overflow(base_url, selenium):
    """
    The revision detail diff stays in page boundaries

    bug 1405690 - some content causes overflows
    """
    admin = AdminLogin(selenium, base_url).open()
    admin.login_new_user()
    page = DashboardPage(selenium, base_url).open()
    page.open_first_details()
    assert page.scroll_width <= page.client_width
Пример #8
0
def test_dashboard_load_page_two(base_url, selenium):
    admin = AdminLogin(selenium, base_url).open()
    admin.login_new_user()
    page = DashboardPage(selenium, base_url).open()
    # save id of first revision on page one
    first_row_id = page.first_row_id
    # click on page two link
    page.click_page_two()
    # save id of first revision on page tw0
    new_first_row_id = page.first_row_id
    # check first revison on page one is not on page two
    assert first_row_id is not new_first_row_id
Пример #9
0
def test_dashboard_open_details(base_url, selenium):
    admin = AdminLogin(selenium, base_url).open()
    admin.login_new_user()
    page = DashboardPage(selenium, base_url).open()
    # no dashboard-details
    assert page.details_items_length == 0
    # click first cell
    page.open_first_details()
    # dashboard-details exist and are visible
    assert page.details_items_length == 1
    assert page.is_first_details_displayed
    # contains a diff
    page.wait_for_first_details_diff_displayed()
Пример #10
0
def test_dashboard(base_url, selenium):
    admin = AdminLogin(selenium, base_url).open()
    admin.login_new_user()
    page = DashboardPage(selenium, base_url).open()
    first_row = page.first_row
    # ip toggle not present
    assert not page.is_ip_toggle_present
    # ip ban not present
    assert not first_row.is_ip_ban_present
    # spam ham button not present
    assert not first_row.is_spam_ham_button_present
    # no dashboard-details
    assert page.details_items_length == 0
def test_new(base_url, selenium):
    admin = AdminLogin(selenium, base_url).open()
    admin.login_moderator_user()
    page = NewPage(selenium, base_url).open()
    # CKEditor loads and is ready
    editor = page.editor()
    assert editor.ready
    # Tagit loads
    assert page.tagit_loaded
    # save button disabled
    assert page.is_save_button_disabled
    # edit in source mode, including an iframe, exit source mode
    editor.edit_source()
    content = editor.content_source()
    # iframe edit removed
    assert 'iframe' not in content
    # content edit remains
    assert 'Pumpkin' in content
    # wait for throttled draft function to activate (hopefully not)
    time.sleep(0.6)
    # check save draft not activated
    assert not editor.is_draft_container_displayed
    # save button enabled
    assert not page.is_save_button_disabled
    # write title
    page.write_title()
    # check slug updates
    assert page.is_slug_suggested
    # publish
    published_page = page.publish()
    # correct content published
    assert 'Pumpkin' in published_page.article_content()
    # needs a review, because it's new
    assert published_page.is_technical_review_needed
    assert published_page.is_editorial_review_needed
    # passes TOC test
    assert published_page.is_test_toc
Пример #12
0
def test_drafts(base_url, selenium):
    admin = AdminLogin(selenium, base_url).open()
    admin.login_moderator_user()
    # create new page
    new_page = NewPage(selenium, base_url).open()
    new_page.write_title()
    new_page_editor = new_page.editor()
    # check draft autosave is not enabled
    assert not new_page_editor.is_draft_status_displayed
    new_page_editor.edit_source('Create page.')
    # publish page
    published_page = new_page.publish()
    # edit page
    edit_page = published_page.click_edit(True)
    editor = edit_page.editor()
    editor.edit_source('Draft1')
    # draft UI reports save
    assert editor.is_draft_autosave_displayed
    # check draft contents
    draft_content = editor.draft_content(selenium.current_url)
    assert 'Draft1' in draft_content
    # refresh page
    selenium.refresh()
    refreshed_editor = edit_page.editor()
    # wait until recovery option found
    edit_page.wait.until(lambda s: refreshed_editor.is_draft_restore_displayed)
    # recover draft
    refreshed_editor.restore_draft()
    # check article contents match draft
    editor_content = editor.content_source()
    assert 'Draft1' in editor_content
    # publish page
    second_published_page = edit_page.save()
    # check rev_saved striped from URL
    second_published_page.wait.until(
        lambda s: 'rev_saved' not in selenium.current_url)
    # edit page
    second_edit_page = published_page.click_edit(True)
    second_editor = second_edit_page.editor()
    # check first draft was deleted after being published
    initial_second_draft_content = second_editor.draft_content(
        selenium.current_url)
    assert 'Draft1' not in initial_second_draft_content
    second_editor.edit_source('Draft2')
    # check draft contents
    second_draft_content = second_editor.draft_content(selenium.current_url)
    # check second draft saved
    assert 'Draft2' in second_draft_content
    # discard page (and with it second draft)
    second_publish = second_edit_page.discard()
    # edit page
    third_edit_page = second_publish.click_edit(True)
    third_editor = third_edit_page.editor()
    # check second draft discarded
    discarded_draft_content = third_editor.draft_content(selenium.current_url)
    assert 'Draft2' not in discarded_draft_content
    # edit third page
    third_editor.edit_source('Draft3')
    # refresh page
    selenium.refresh()
    refreshed_editor = third_edit_page.editor()
    # discard draft
    refreshed_editor.discard_draft()
    # check draft discarded
    refreshed_editor_draft_contents = refreshed_editor.draft_content(
        selenium.current_url)
    assert 'Draft3' not in refreshed_editor_draft_contents
    # check interface updated
    assert refreshed_editor.draft_discarded_status
    current_revision_id = third_edit_page.current_revision_id
    refreshed_editor.fake_old_draft(selenium.current_url, current_revision_id)
    # refresh page
    selenium.refresh()
    fake_draft_refreshed_editor = third_edit_page.editor()
    # check that saved draft was detected & reported as old, can't be restored
    assert fake_draft_refreshed_editor.is_draft_old_displayed
    assert fake_draft_refreshed_editor.is_draft_outdated
    assert not fake_draft_refreshed_editor.is_draft_restore_displayed
    # view saved draft
    fake_draft_refreshed_editor.view_draft()
    # give JS a second to do that
    time.sleep(0.5)
    # check view happened
    editor_content = fake_draft_refreshed_editor.content_source()
    assert 'Old draft' in editor_content
    # check publishing blocked as expected
    publish_old = third_edit_page.save()
    assert publish_old.is_error_list_displayed
Пример #13
0
def test_drafts(base_url, selenium):
    admin = AdminLogin(selenium, base_url).open()
    admin.login_moderator_user()
    # create new page
    new_page = NewPage(selenium, base_url).open()
    new_page.write_title()
    new_page_editor = new_page.editor()
    # check draft autosave is not enabled
    assert not new_page_editor.is_draft_status_displayed
    new_page_editor.edit_source('Create page.')
    # publish page
    published_page = new_page.publish()
    # edit page
    edit_page = published_page.click_edit(True)
    editor = edit_page.editor()
    editor.edit_source('Draft1')
    # draft UI reports save
    assert editor.is_draft_autosave_displayed
    # check draft contents
    draft_content = editor.draft_content(selenium.current_url)
    assert 'Draft1' in draft_content
    # refresh page
    selenium.refresh()
    refreshed_editor = edit_page.editor()
    # wait until recovery option found
    edit_page.wait.until(lambda s: refreshed_editor.is_draft_restore_displayed)
    # recover draft
    refreshed_editor.restore_draft()
    # check article contents match draft
    editor_content = editor.content_source()
    assert 'Draft1' in editor_content
    # publish page
    second_published_page = edit_page.save()
    # check rev_saved striped from URL
    second_published_page.wait.until(lambda s: 'rev_saved' not in selenium.current_url)
    # edit page
    second_edit_page = published_page.click_edit(True)
    second_editor = second_edit_page.editor()
    # check first draft was deleted after being published
    initial_second_draft_content = second_editor.draft_content(selenium.current_url)
    assert 'Draft1' not in initial_second_draft_content
    second_editor.edit_source('Draft2')
    # check draft contents
    second_draft_content = second_editor.draft_content(selenium.current_url)
    # check second draft saved
    assert 'Draft2' in second_draft_content
    # discard page (and with it second draft)
    second_publish = second_edit_page.discard()
    # edit page
    third_edit_page = second_publish.click_edit(True)
    third_editor = third_edit_page.editor()
    # check second draft discarded
    discarded_draft_content = third_editor.draft_content(selenium.current_url)
    assert 'Draft2' not in discarded_draft_content
    # edit third page
    third_editor.edit_source('Draft3')
    # refresh page
    selenium.refresh()
    refreshed_editor = third_edit_page.editor()
    # discard draft
    refreshed_editor.discard_draft()
    # check draft discarded
    refreshed_editor_draft_contents = refreshed_editor.draft_content(selenium.current_url)
    assert 'Draft3' not in refreshed_editor_draft_contents
    # check interface updated
    assert refreshed_editor.draft_discarded_status
    current_revision_id = third_edit_page.current_revision_id
    refreshed_editor.fake_old_draft(selenium.current_url, current_revision_id)
    # refresh page
    selenium.refresh()
    fake_draft_refreshed_editor = third_edit_page.editor()
    # check that saved draft was detected & reported as old, can't be restored
    assert fake_draft_refreshed_editor.is_draft_old_displayed
    assert fake_draft_refreshed_editor.is_draft_outdated
    assert not fake_draft_refreshed_editor.is_draft_restore_displayed
    # view saved draft
    fake_draft_refreshed_editor.view_draft()
    # give JS a second to do that
    time.sleep(0.5)
    # check view happened
    editor_content = fake_draft_refreshed_editor.content_source()
    assert 'Old draft' in editor_content
    # check publishing blocked as expected
    publish_old = third_edit_page.save()
    assert publish_old.is_error_list_displayed