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 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 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)