def do_user_registration(driver, profile, base_url):

    main_page = MainPage(driver)
    main_page.get()
    main_page.click_set_up_account()

    registration_page = RegistrationPage(driver)
    assert registration_page.is_current()

    registration_page.register(profile)

    assert driver.current_url == base_url + "/registration-continue"

    registration_link = get_link(profile, profile.registration_template_id, profile.email)

    driver.get(registration_link)

    do_verify(driver, profile)

    add_service_page = AddServicePage(driver)
    assert add_service_page.is_current()
    add_service_page.add_service(profile.service_name)

    dashboard_page = DashboardPage(driver)
    service_id = dashboard_page.get_service_id()
    dashboard_page.go_to_dashboard_for_service(service_id)

    assert dashboard_page.h2_is_service_name(profile.service_name)
def do_user_can_add_reply_to_email_to_service(driver):
    if config["env"] != "preview":
        return True
    email_address = config['service']['email_reply_to']
    email_address2 = config['service']['email_reply_to_2']
    email_address3 = config['service']['email_reply_to_3']
    dashboard_page = DashboardPage(driver)
    dashboard_page.go_to_dashboard_for_service()

    service_id = dashboard_page.get_service_id()

    email_reply_to_page = EmailReplyTo(driver)

    email_reply_to_page.go_to_add_email_reply_to_address(service_id)
    email_reply_to_page.insert_email_reply_to_address(email_address)
    email_reply_to_page.click_add_email_reply_to()

    email_reply_to_page.click_continue_button(time=120)

    body = email_reply_to_page.get_reply_to_email_addresses()

    assert email_address + default in body.text
    assert email_address2 not in body.text
    assert email_address3 not in body.text

    dashboard_page.go_to_dashboard_for_service(service_id)
def do_edit_and_delete_email_template(driver):
    test_name = "edit/delete test"
    dashboard_page = DashboardPage(driver)
    dashboard_page.go_to_dashboard_for_service()
    dashboard_page.click_email_templates()

    existing_templates = [x.text for x in driver.find_elements_by_class_name("message-name")]

    all_templates_page = SendEmailTemplatePage(driver)
    all_templates_page.click_add_new_template()

    template_page = EditEmailTemplatePage(driver)
    template_page.create_template(name=test_name)

    assert test_name in [x.text for x in driver.find_elements_by_class_name("message-name")]

    all_templates_page.click_edit_template()
    template_page.click_delete()

    assert [x.text for x in driver.find_elements_by_class_name("message-name")] == existing_templates
Ejemplo n.º 4
0
def test_sign_in(driver, base_url, profile):
    try:
        sign_in_page = SignInPage(driver)
        sign_in_page.get()
        assert sign_in_page.is_current()
        sign_in_page.login(profile['email'], profile['password'])

        two_factor_page = TwoFactorPage(driver)
        assert two_factor_page.is_current()

        verify_code = get_verify_code()
        two_factor_page.verify(verify_code)

        dashboard_page = DashboardPage(driver)

        assert dashboard_page.is_current(profile['config'].SERVICE_ID)
        dashboard_page.sign_out()
    except Exception as e:
        message = "Test failure in sign in test for {}. Exception: {}".format(profile['config'].NOTIFY_ADMIN_URL, e)
        send_to_deskpro(profile['config'], message)
        pytest.fail(message)
def do_user_registration(driver):
    main_page = MainPage(driver)
    main_page.get()
    main_page.click_set_up_account()

    registration_page = RegistrationPage(driver)
    assert registration_page.is_current()

    registration_page.register()

    assert driver.current_url == config['notify_admin_url'] + '/registration-continue'

    registration_link = get_link(config['notify_templates']['registration_template_id'], config['user']['email'])

    driver.get(registration_link)

    do_verify(driver)

    add_service_page = AddServicePage(driver)
    assert add_service_page.is_current()
    add_service_page.add_service(config['service_name'])

    dashboard_page = DashboardPage(driver)
    service_id = dashboard_page.get_service_id()
    dashboard_page.go_to_dashboard_for_service(service_id)

    assert dashboard_page.get_service_name() == config['service_name']
def test_send_csv(driver, profile, login_seeded_user, seeded_client, message_type):
    dashboard_page = DashboardPage(driver)
    dashboard_page.go_to_dashboard_for_service()
    template_id = profile.email_template_id if message_type == 'email' else profile.sms_template_id

    dashboard_stats_before = get_dashboard_stats(dashboard_page, message_type, template_id)

    upload_csv_page = UploadCsvPage(driver)
    notification_id = send_notification_via_csv(profile, upload_csv_page, message_type, seeded=True)

    notification = retry_call(
        get_notification_by_id_via_api,
        fargs=[seeded_client, notification_id, ['sending', 'delivered']],
        tries=Config.NOTIFICATION_RETRY_TIMES,
        delay=Config.NOTIFICATION_RETRY_INTERVAL
    )
    assert_notification_body(notification_id, notification)
    dashboard_page.go_to_dashboard_for_service()

    dashboard_stats_after = get_dashboard_stats(dashboard_page, message_type, template_id)

    assert_dashboard_stats(dashboard_stats_before, dashboard_stats_after)
def test_send_email_with_placeholders_to_one_recipient(driver, seeded_client,
                                                       login_seeded_user):
    go_to_templates_page(driver)
    template_name = "email with placeholders" + str(uuid.uuid4())
    content = "Hi ((name)), Is ((email address)) your email address? We want to send you some ((things))"
    template_id = create_email_template(driver,
                                        name=template_name,
                                        content=content)

    dashboard_page = DashboardPage(driver)
    dashboard_page.go_to_dashboard_for_service(
        service_id=config['service']['id'])
    dashboard_stats_before = get_dashboard_stats(dashboard_page, 'email',
                                                 template_id)

    placeholders = send_notification_to_one_recipient(
        driver,
        template_name,
        "email",
        test=False,
        recipient_data='*****@*****.**',
        placeholders_number=2)
    assert list(placeholders[0].keys()) == ["name"]
    assert list(placeholders[1].keys()) == ["things"]

    dashboard_page.click_continue()
    notification_id = dashboard_page.get_notification_id()
    one_off_email = seeded_client.get_notification_by_id(notification_id)
    assert one_off_email.get('created_by_name') == 'Preview admin tests user'

    dashboard_page.go_to_dashboard_for_service(
        service_id=config['service']['id'])
    dashboard_stats_after = get_dashboard_stats(dashboard_page, 'email',
                                                template_id)
    assert_dashboard_stats(dashboard_stats_before, dashboard_stats_after)

    placeholders_test = send_notification_to_one_recipient(
        driver, template_name, "email", test=True, placeholders_number=2)
    assert list(placeholders_test[0].keys()) == ["name"]
    assert list(placeholders_test[1].keys()) == ["things"]

    delete_template(driver, template_name)
def delete_template(driver, template_name):
    show_templates_page = ShowTemplatesPage(driver)
    try:
        show_templates_page.click_template_by_link_text(template_name)
    except TimeoutException:
        dashboard_page = DashboardPage(driver)
        dashboard_page.go_to_dashboard_for_service(config['service']['id'])
        dashboard_page.click_templates()
        show_templates_page.click_template_by_link_text(template_name)
    template_page = EditEmailTemplatePage(driver)
    template_page.click_delete()
def send_notification_to_one_recipient(driver,
                                       template_name,
                                       message_type,
                                       test=False,
                                       recipient_data=None,
                                       placeholders_number=None):
    dashboard_page = DashboardPage(driver)
    dashboard_page.go_to_dashboard_for_service(config['service']['id'])
    dashboard_page.click_templates()

    show_templates_page = ShowTemplatesPage(driver)
    show_templates_page.click_template_by_link_text(template_name)
    view_template_page = ViewTemplatePage(driver)
    view_template_page.click_send()

    send_to_one_recipient_page = SendOneRecipient(driver)
    send_to_one_recipient_page.choose_alternative_sender()
    send_to_one_recipient_page.click_continue()
    if test is True:
        send_to_one_recipient_page.send_to_myself(message_type)
    else:
        send_to_one_recipient_page.enter_placeholder_value(recipient_data)
        send_to_one_recipient_page.click_continue()
    placeholders = []
    index = 0
    while send_to_one_recipient_page.is_page_title("Personalise this message"):
        if not send_to_one_recipient_page.is_placeholder_a_recipient_field(
                message_type):
            placeholder_value = str(uuid.uuid4())
            send_to_one_recipient_page.enter_placeholder_value(
                placeholder_value)
            placeholder_name = send_to_one_recipient_page.get_placeholder_name(
            )
            placeholders.append({placeholder_name: placeholder_value})
        send_to_one_recipient_page.click_continue()
        index += 1
        if index > 10:
            raise TimeoutException(
                "Too many attempts, something is broken with placeholders")
    if placeholders_number:
        assert len(placeholders) == placeholders_number
    for placeholder in placeholders:
        assert send_to_one_recipient_page.is_text_present_on_page(
            list(placeholder.values())[0])
    if message_type == "email":
        _assert_one_off_email_filled_in_properly(driver, template_name, test,
                                                 recipient_data)
    else:
        _assert_one_off_sms_filled_in_properly(driver, template_name, test,
                                               recipient_data)
    return placeholders
Ejemplo n.º 10
0
def do_user_can_update_sms_sender_of_service(driver):
    dashboard_page = DashboardPage(driver)
    dashboard_page.go_to_dashboard_for_service()

    service_id = dashboard_page.get_service_id()

    sms_sender_page = SmsSenderPage(driver)

    sms_sender_page.go_to_text_message_senders(service_id)
    sms_sender_page.click_change_link_for_first_sms_sender()
    sms_sender_page.insert_sms_sender('first')
    sms_sender_page.click_save_sms_sender()

    main_content = sms_sender_page.get_sms_senders()

    assert 'first \u2002 (default)' in main_content.text

    dashboard_page.go_to_dashboard_for_service(service_id)
Ejemplo n.º 11
0
def test_inbox_page(inbound_sms, driver, login_seeded_user):
    dashboard_page = DashboardPage(driver)
    dashboard_page.go_to_dashboard_for_service(config['service']['id'])

    # go to inbox page
    dashboard_page.click_inbox_link()

    # select conversation for outbound phone number
    inbox_page = InboxPage(driver)
    assert inbox_page.is_current(config['service']['id'])

    inbox_page.go_to_conversation(config['user']['mobile'])

    conversation = ConversationPage(driver)
    assert conversation.get_message(inbound_sms) is not None
def test_send_sms_with_placeholders_to_one_recipient(driver, seeded_client,
                                                     login_seeded_user):
    go_to_templates_page(driver)
    template_name = "sms with placeholders" + str(uuid.uuid4())
    content = "Hi ((name)), Is ((phone number)) your mobile number? We want to send you some ((things))"
    template_id = create_sms_template(driver,
                                      name=template_name,
                                      content=content)

    dashboard_page = DashboardPage(driver)
    dashboard_page.go_to_dashboard_for_service(
        service_id=config['service']['id'])
    dashboard_stats_before = get_dashboard_stats(dashboard_page, 'sms',
                                                 template_id)

    placeholders = send_notification_to_one_recipient(
        driver,
        template_name,
        "sms",
        test=False,
        recipient_data='07700900998',
        placeholders_number=2)
    assert list(placeholders[0].keys()) == ["name"]
    assert list(placeholders[1].keys()) == ["things"]

    dashboard_page.click_continue()
    dashboard_page.go_to_dashboard_for_service(
        service_id=config['service']['id'])
    dashboard_stats_after = get_dashboard_stats(dashboard_page, 'sms',
                                                template_id)
    assert_dashboard_stats(dashboard_stats_before, dashboard_stats_after)

    placeholders_test = send_notification_to_one_recipient(
        driver, template_name, "sms", test=True, placeholders_number=2)
    assert list(placeholders_test[0].keys()) == ["name"]
    assert list(placeholders_test[1].keys()) == ["things"]

    delete_template(driver, template_name)
Ejemplo n.º 13
0
def do_user_can_add_sms_sender_to_service(driver):
    dashboard_page = DashboardPage(driver)
    dashboard_page.go_to_dashboard_for_service()

    service_id = dashboard_page.get_service_id()

    sms_sender_page = SmsSenderPage(driver)

    sms_sender_page.go_to_add_text_message_sender(service_id)
    sms_sender_page.insert_sms_sender('second')
    sms_sender_page.click_save_sms_sender()

    main_content = sms_sender_page.get_sms_senders()

    assert 'first \u2002 (default)' in main_content.text
    assert 'second' in main_content.text
    assert 'second \u2002 (default)' not in main_content.text

    dashboard_page.go_to_dashboard_for_service(service_id)
def test_send_csv(driver, login_seeded_user, seeded_client,
                  seeded_client_using_test_key, message_type):
    dashboard_page = DashboardPage(driver)
    dashboard_page.go_to_dashboard_for_service(
        service_id=config['service']['id'])

    template_id = {
        'email': config['service']['templates']['email'],
        'sms': config['service']['templates']['sms'],
        'letter': config['service']['templates']['letter'],
    }.get(message_type)

    dashboard_stats_before = get_dashboard_stats(dashboard_page, message_type,
                                                 template_id)

    upload_csv_page = UploadCsvPage(driver)
    notification_id = send_notification_via_csv(upload_csv_page,
                                                message_type,
                                                seeded=True)

    notification = retry_call(get_notification_by_id_via_api,
                              fargs=[
                                  seeded_client_using_test_key if message_type
                                  == 'letter' else seeded_client,
                                  notification_id,
                                  NotificationStatuses.ACCEPTED if message_type
                                  == 'letter' else NotificationStatuses.SENT
                              ],
                              tries=config['notification_retry_times'],
                              delay=config['notification_retry_interval'])
    assert_notification_body(notification_id, notification)

    # test the whole letter creation flow, by checking the PDF has been created
    if message_type == 'letter':
        retry_call(get_pdf_for_letter_via_api,
                   fargs=[seeded_client, notification_id],
                   tries=config['notification_retry_times'],
                   delay=config['notification_retry_interval'])

    dashboard_page.go_to_dashboard_for_service(
        service_id=config['service']['id'])

    dashboard_stats_after = get_dashboard_stats(dashboard_page, message_type,
                                                template_id)

    assert_dashboard_stats(dashboard_stats_before, dashboard_stats_after)
def do_user_can_update_reply_to_email_to_service(driver):
    if config["env"] != "preview":
        return True
    email_address = config['service']['email_reply_to']
    email_address2 = config['service']['email_reply_to_2']
    dashboard_page = DashboardPage(driver)
    dashboard_page.go_to_dashboard_for_service()

    service_id = dashboard_page.get_service_id()

    email_reply_to_page = EmailReplyTo(driver)

    email_reply_to_page.go_to_add_email_reply_to_address(service_id)
    email_reply_to_page.insert_email_reply_to_address(email_address2)
    email_reply_to_page.click_add_email_reply_to()

    email_reply_to_page.click_continue_button(time=120)

    body = email_reply_to_page.get_reply_to_email_addresses()

    assert email_address + default in body.text
    assert email_address2 in body.text

    sub_body = body.text[body.text.index(
        email_address2):]  # find the index of the email address
    # the id is the fifth entry [ 'email address, 'Change', 'email address', 'id label', id' ]
    email_reply_to_id = sub_body.split('\n')[4]

    email_reply_to_page.go_to_edit_email_reply_to_address(
        service_id, email_reply_to_id)
    email_reply_to_page.check_is_default_check_box()
    email_reply_to_page.click_add_email_reply_to()

    body = email_reply_to_page.get_reply_to_email_addresses()

    assert email_address in body.text
    assert email_address + default not in body.text
    assert email_address2 + default in body.text

    dashboard_page.go_to_dashboard_for_service(service_id)
def test_org_invite(driver, login_seeded_user):
    org_dashboard_page = OrganisationDashboardPage(driver)
    org_dashboard_page.go_to_dashboard_for_org(
        config['service']['organisation_id'])
    assert org_dashboard_page.is_current(config['service']['organisation_id'])
    org_dashboard_page.click_team_members_link()

    team_members_page = TeamMembersPage(driver)
    team_members_page.click_invite_user()

    # create a new user to log in to
    invited_user_email = generate_unique_email(config['user']['email'],
                                               uuid.uuid4())

    invitation = InviteUserToOrgPage(driver)
    invitation.fill_invitation_form(email=invited_user_email)
    invitation.send_invitation()

    # now log out and create account as invited user
    dashboard_page = DashboardPage(driver)
    dashboard_page.sign_out()
    dashboard_page.wait_until_url_is(config['notify_admin_url'])

    invite_link = get_link(
        config['notify_templates']['org_invitation_template_id'],
        invited_user_email)
    driver.get(invite_link)

    register_from_invite_page = RegisterFromInvite(driver)
    register_from_invite_page.fill_registration_form(
        invited_user_email.split('@')[0])
    register_from_invite_page.click_continue()

    do_verify(driver)

    org_dashboard_page = OrganisationDashboardPage(driver)

    # make sure we got to the dashboard page. It's their only account, so they'll be insta-redirected there.
    # They won't be able to see anything here tho since they're not a member of the service
    assert org_dashboard_page.is_current(config['service']['organisation_id'])
def test_change_service_name(driver, login_seeded_user):
    new_name = "Functional Tests {}".format(uuid.uuid4())
    dashboard_page = DashboardPage(driver)
    # make sure the service is actually named what we expect
    assert dashboard_page.get_service_name() == config['service']['name']
    dashboard_page.go_to_dashboard_for_service(config['service']['id'])
    dashboard_page.click_settings()
    service_settings = ServiceSettingsPage(driver)
    change_name = ChangeName(driver)
    change_name.go_to_change_service_name(config['service']['id'])
    change_name.enter_new_name(new_name)
    change_name.click_save()
    change_name.enter_password(config['service']['seeded_user']['password'])
    change_name.click_save()
    service_settings.check_service_name(new_name)

    dashboard_page.go_to_dashboard_for_service(config['service']['id'])
    assert dashboard_page.get_service_name() == new_name

    # change the name back
    change_name.go_to_change_service_name(config['service']['id'])
    change_name.enter_new_name(config['service']['name'])
    change_name.click_save()
    change_name.enter_password(config['service']['seeded_user']['password'])
    change_name.click_save()
    service_settings.check_service_name(config['service']['name'])

    dashboard_page.go_to_dashboard_for_service(config['service']['id'])
    assert dashboard_page.get_service_name() == config['service']['name']
def test_template_folder_permissions(driver, login_seeded_user):
    family_id = uuid.uuid4()
    folder_names = [
        'test-parent-folder {}'.format(family_id),
        'test-child-folder {}'.format(family_id),
        'test-grandchild-folder {}'.format(family_id),
    ]
    dashboard_page = DashboardPage(driver)
    dashboard_page.go_to_dashboard_for_service(config['service']['id'])
    dashboard_page.click_templates()
    show_templates_page = ShowTemplatesPage(driver)
    # a loop to create a folder structure with parent folder, child folder and grandchild folder,
    # each folder with one template in it
    for folder_name in folder_names:
        # create a new folder
        show_templates_page.click_add_new_folder(folder_name)

        show_templates_page.click_template_by_link_text(folder_name)
        # create a new template
        show_templates_page.click_add_new_template()
        show_templates_page.select_email()

        edit_template_page = EditEmailTemplatePage(driver)
        edit_template_page.create_template(name=(folder_name + "_template"))
        # go back to view folder page
        edit_template_page.click_folder_path(folder_name)

    # go to Team members page
    dashboard_page.click_team_members_link()
    team_members_page = TeamMembersPage(driver)
    # edit colleague's permissions so child folder is invisible
    team_members_page.click_edit_team_member(
        config['service']['email_auth_account'])
    edit_team_member_page = InviteUserPage(driver)
    edit_team_member_page.uncheck_folder_permission_checkbox(folder_names[1])
    edit_team_member_page.click_save()

    # check if permissions saved correctly
    dashboard_page.click_team_members_link()
    team_members_page.click_edit_team_member(
        config['service']['email_auth_account'])
    assert not edit_team_member_page.is_checkbox_checked(folder_names[1])
    # log out
    dashboard_page.sign_out()
    # log in as that colleague
    sign_in_email_auth(driver)
    # go to Templates
    dashboard_page.go_to_dashboard_for_service(config['service']['id'])
    dashboard_page.click_templates()
    # click through, see that child folder invisible
    show_templates_page.click_template_by_link_text(folder_names[0])
    child_folder = show_templates_page.get_folder_by_name(folder_names[1])
    name_of_folder_with_invisible_parent = folder_names[
        1] + " " + folder_names[2]
    assert child_folder.text == name_of_folder_with_invisible_parent
    # grandchild folder has folder path as a name
    show_templates_page.click_template_by_link_text(
        name_of_folder_with_invisible_parent)
    # click grandchild folder template to see that it's there
    show_templates_page.click_template_by_link_text(folder_names[2] +
                                                    "_template")
    dashboard_page.sign_out()
    # delete everything
    sign_in(driver, seeded=True)
    dashboard_page.go_to_dashboard_for_service(config['service']['id'])
    dashboard_page.click_templates()
    show_templates_page = ShowTemplatesPage(driver)
    show_templates_page.click_template_by_link_text(folder_names[0])

    view_folder_page = ViewFolderPage(driver)
    view_folder_page.click_template_by_link_text(folder_names[1])
    view_folder_page.click_template_by_link_text(folder_names[2])

    for folder_name in reversed(folder_names):
        view_folder_page.click_template_by_link_text(folder_name + "_template")
        template_page = EditEmailTemplatePage(driver)
        template_page.click_delete()

        view_folder_page.click_manage_folder()
        manage_folder_page = ManageFolderPage(driver)
        manage_folder_page.delete_folder()
        manage_folder_page.confirm_delete_folder()
def test_creating_moving_and_deleting_template_folders(driver,
                                                       login_seeded_user):
    # create new template
    template_name = 'template-for-folder-test {}'.format(uuid.uuid4())
    folder_name = 'test-folder {}'.format(uuid.uuid4())

    dashboard_page = DashboardPage(driver)
    dashboard_page.go_to_dashboard_for_service(config['service']['id'])
    dashboard_page.click_templates()

    show_templates_page = ShowTemplatesPage(driver)
    show_templates_page.click_add_new_template()
    show_templates_page.select_email()

    edit_template_page = EditEmailTemplatePage(driver)
    edit_template_page.create_template(name=template_name)
    template_id = edit_template_page.get_template_id()
    edit_template_page.click_templates()

    # create folder using add to new folder
    show_templates_page.select_template_checkbox(template_id)
    show_templates_page.add_to_new_folder(folder_name)

    # navigate into folder
    show_templates_page.click_template_by_link_text(folder_name)

    # rename folder step
    view_folder_page = ViewFolderPage(driver)
    view_folder_page.click_manage_folder()

    manage_folder_page = ManageFolderPage(driver)
    new_folder_name = folder_name + '-new'
    manage_folder_page.set_name(new_folder_name)
    view_folder_page.assert_name_equals(new_folder_name)

    # try to delete folder
    view_folder_page.click_manage_folder()
    manage_folder_page.delete_folder()  # fails due to not being empty

    # check error message visible
    assert manage_folder_page.get_errors(
    ) == 'You must empty this folder before you can delete it'

    # move template out of folder
    view_folder_page.select_template_checkbox(template_id)
    view_folder_page.move_to_root_template_folder()

    # delete folder
    view_folder_page.click_manage_folder()
    manage_folder_page.delete_folder()
    manage_folder_page.confirm_delete_folder()
    current_folders = [
        x.text
        for x in driver.find_elements_by_class_name('template-list-item-label')
    ]
    if len(current_folders) == 0:
        current_folders = [
            x.text for x in driver.find_elements_by_class_name('message-name')
        ]
    # assert folder not visible
    assert new_folder_name not in current_folders

    # delete template
    show_templates_page.click_template_by_link_text(template_name)
    edit_template_page.click_delete()

    assert template_name not in [
        x.text for x in driver.find_elements_by_class_name('message-name')
    ]
def go_to_templates_page(driver):
    dashboard_page = DashboardPage(driver)
    dashboard_page.go_to_dashboard_for_service(config['service']['id'])
    dashboard_page.click_templates()
def do_user_can_invite_someone_to_notify(driver, profile, base_url):

    dashboard_page = DashboardPage(driver)
    dashboard_page.click_team_members_link()

    team_members_page = TeamMembersPage(driver)
    assert team_members_page.h1_is_team_members()
    team_members_page.click_invite_user()

    invite_user_page = InviteUserPage(driver)

    invited_user_randomness = str(uuid.uuid1())
    invited_user_name = "Invited User " + invited_user_randomness
    invite_email = generate_unique_email(profile.email, invited_user_randomness)

    invite_user_page.fill_invitation_form(invite_email, send_messages=True)
    invite_user_page.send_invitation()
    invite_user_page.sign_out()
    invite_user_page.wait_until_url_is(base_url)

    # next part of interaction is from point of view of invitee
    # i.e. after visting invite_link we'll be registering using invite_email
    # but use same mobile number and password as profile

    invite_link = get_link(profile, profile.invitation_template_id, invite_email)
    driver.get(invite_link)
    register_from_invite_page = RegisterFromInvite(driver)
    register_from_invite_page.fill_registration_form(invited_user_name, profile)
    register_from_invite_page.click_continue()

    do_verify(driver, profile)
    dashboard_page = DashboardPage(driver)
    service_id = dashboard_page.get_service_id()
    dashboard_page.go_to_dashboard_for_service(service_id)

    assert dashboard_page.h2_is_service_name(profile.service_name)

    dashboard_page.sign_out()
    dashboard_page.wait_until_url_is(base_url)
def get_service_templates_and_api_key_for_tests(driver, test_profile):

    dashboard_page = DashboardPage(driver)
    dashboard_page.click_email_templates()
    service_id = dashboard_page.get_service_id()

    email_template_page = SendEmailTemplatePage(driver)
    email_template_page.click_add_a_new_template()

    new_email_template_page = EditEmailTemplatePage(driver)
    new_email_template_page.create_template()

    email_template_page = SendEmailTemplatePage(driver)
    email_template_page.click_edit_template()

    edit_email_template_page = EditEmailTemplatePage(driver)
    email_template_id = edit_email_template_page.get_id()

    dashboard_page = DashboardPage(driver)
    dashboard_page.go_to_dashboard_for_service()
    dashboard_page.click_sms_templates()

    sms_template_page = SendSmsTemplatePage(driver)
    sms_template_page.click_add_new_template()

    new_sms_template = EditSmsTemplatePage(driver)
    new_sms_template.create_template()

    sms_template_page = SendSmsTemplatePage(driver)
    sms_template_page.click_edit_template()

    edit_sms_template = EditSmsTemplatePage(driver)
    sms_template_id = edit_sms_template.get_id()

    dashboard_page = DashboardPage(driver)
    dashboard_page.go_to_dashboard_for_service()
    dashboard_page.click_api_keys_link()

    api_key_page = ApiKeyPage(driver)
    api_key_page.click_keys_link()
    api_key_page.click_create_key()

    api_key_page.click_key_type_radio(key_type='team')
    api_key_page.enter_key_name(key_type='team')

    api_key_page.click_continue()
    api_key = api_key_page.get_api_key()

    test_profile.service_id = service_id
    test_profile.email_template_id = email_template_id
    test_profile.sms_template_id = sms_template_id
    test_profile.api_key = api_key

    return {'service_id': service_id, 'email_template_id': email_template_id, 'sms_template_id': sms_template_id, 'api_key': api_key}  # noqa
def do_user_can_invite_someone_to_notify(driver, basic_view):

    dashboard_page = DashboardPage(driver)
    dashboard_page.click_team_members_link()

    team_members_page = TeamMembersPage(driver)
    assert team_members_page.h1_is_team_members()
    team_members_page.click_invite_user()

    invite_user_page = InviteUserPage(driver)

    invited_user_randomness = str(uuid.uuid1())
    invited_user_name = 'Invited User ' + invited_user_randomness
    invite_email = generate_unique_email(config['user']['email'], invited_user_randomness)
    if basic_view:
        invite_user_page.fill_invitation_form(invite_email, send_messages_only=True)
    else:
        invite_user_page.fill_invitation_form(invite_email, send_messages_only=False)

    invite_user_page.send_invitation()
    invite_user_page.sign_out()
    invite_user_page.wait_until_url_is(config['notify_admin_url'])

    # next part of interaction is from point of view of invitee
    # i.e. after visting invite_link we'll be registering using invite_email
    # but use same mobile number and password as profile

    invite_link = get_link(config['notify_templates']['invitation_template_id'], invite_email)
    driver.get(invite_link)
    register_from_invite_page = RegisterFromInvite(driver)
    register_from_invite_page.fill_registration_form(invited_user_name)
    register_from_invite_page.click_continue()

    do_verify(driver)
    dashboard_page = DashboardPage(driver)
    service_id = dashboard_page.get_service_id()
    dashboard_page.go_to_dashboard_for_service(service_id)

    assert dashboard_page.get_service_name() == config['service_name']
    if basic_view:
        is_basic_view(dashboard_page)
        dashboard_page.sign_out()
        dashboard_page.wait_until_url_is(config['notify_admin_url'])
    else:
        is_view_for_all_permissions(dashboard_page)