Skip to content

Commit

Permalink
LGA-2798: Announce we’re calling from CLA (#130)
Browse files Browse the repository at this point in the history
* WIP: LGA-2798 basic outline and structure for yes announce call path

* WIP: Updating docker-compose file to use correct development branches

* WIP: updated cla_backend git commit number to reflect correct branch

* LGA-2798 new steps for selecting values again announce call options

* LGA-2798 New steps to capture users reference number from contact us jounery. New step to search for a saved case.

* Added feature definitions for additional contact us journeys

* Updated search and save function to be named 'I search for and select a case using my saved reference number'

* Added tests to assert if the call announce warning is present

* WIP: removing imports for A11Y to prevent pre-commit lint issues

* LGA-2798 updated steps with new input values checks. Fixed step call issue. Changed H1 checks on confirm page.

* Added additional steps to the 'Call someone else instead of me' test

* Renamed tag on new features

* Reverted docker-compose commit tags

* Reverted changes to environment.py

* Reverted unintentional indentation

* LGA-2798 updating I'll call CLA to I will call you

* LGA-2798 user selects yes to announce call options

* Added namespace to orb.yml

* Updated orb-tools

* Revert "Updated orb-tools"

This reverts commit 376985a.

---------

Co-authored-by: psweeting <[email protected]>
  • Loading branch information
BenMillar-MOJ and psweeting1 authored Jan 3, 2024
1 parent b441d6c commit a94fa97
Show file tree
Hide file tree
Showing 9 changed files with 156 additions and 21 deletions.
65 changes: 64 additions & 1 deletion behave/features/cla_public/public_contact_us.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Scenario: contact us journey to contact civil legal advice page / form
And I click 'continue to contact CLA'
And I am taken to the "Contact Civil Legal Advice" page located on "/contact"
Then I enter a name in the 'Your full name' field
And I select the contact option 'I’ll call CLA'
And I select the contact option 'I will call you'
And I select 'Submit details'
Then I am taken to the "Your details have been submitted" page located on "/result/confirmation"

Expand All @@ -32,3 +32,66 @@ Scenario: contact us journey, selecting 'call someone else instead of me' option
And I select the next available "thirdparty" time slot
And I select 'Submit details'
Then I am taken to the "We will call you back" page located on "/result/confirmation"


# Ticket (LGA-2798, LGA-2799)
@cla-contact-us-announce-cla-call @a11y-check
Scenario: contact us journey, saying 'Yes' for CLA to announce who's calling
Given I am on the Contact Civil Legal Advice page
When I enter a name in the 'Your full name' field
And I select the contact option 'Call me back'
And I enter my phone number
And I select the next available "callback" time slot
And I select 'Yes' to announce call options
And I select 'Submit details'
Then I am taken to the "We will call you back" page located on "/result/confirmation"
And I save the reference number
When I am logged in as "CHS_GENERAL_USER"
When I search for and select a case using my saved reference number
Then the 'do not announce the call is from CLA' warning is not present


@cla-contact-us-announce-cla-call @a11y-check
Scenario: contact us journey, saying 'No' for CLA to announce who's calling
Given I am on the Contact Civil Legal Advice page
When I enter a name in the 'Your full name' field
And I select the contact option 'Call me back'
And I enter my phone number
And I select the next available "callback" time slot
And I select 'No' to announce call options
And I select 'Submit details'
Then I am taken to the "We will call you back" page located on "/result/confirmation"
And I save the reference number
And I am logged in as "CHS_GENERAL_USER"
And I search for and select a case using my saved reference number
Then the 'do not announce the call is from CLA' warning is present


@cla-contact-us-announce-cla-call @a11y-check
Scenario: contact us journey, selecting 'I will call you'
Given I am on the Contact Civil Legal Advice page
When I enter a name in the 'Your full name' field
And I select the contact option 'I will call you'
And I select 'Submit details'
Then I am taken to the "Your details have been submitted" page located on "/result/confirmation"
And I save the reference number
And I am logged in as "CHS_GENERAL_USER"
And I search for and select a case using my saved reference number
Then the 'do not announce the call is from CLA' warning is not present


@cla-contact-us-announce-cla-call @a11y-check
Scenario: contact us journey, selecting 'Call someone else instead of me'
Given I am on the Contact Civil Legal Advice page
When I enter a name in the 'Your full name' field
And I select the contact option 'Call someone else instead of me'
And I enter the full name of the person to call
And I select "Family member or friend" from the 'Relationship to you' drop down options
And I enter the phone number of the person to call back
And I select the next available "thirdparty" time slot
And I select 'Submit details'
Then I am taken to the "We will call you back" page located on "/result/confirmation"
And I save the reference number
And I am logged in as "CHS_GENERAL_USER"
And I search for and select a case using my saved reference number
Then the 'do not announce the call is from CLA' warning is not present
3 changes: 2 additions & 1 deletion behave/features/cla_public/public_eligible.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Scenario: Complete callback form asking for callback
And I enter my phone number for the callback
And I select "Call on another day"
And I select an available day and time
And I select 'Yes' to announce call options
# # All steps that are clicking continue written in identical format so can reuse code
And I click continue
Then I am taken to the "We will call you back" page located on "/result/confirmation"
Expand All @@ -26,7 +27,7 @@ Scenario: Complete callback form asking for callback
Scenario: Complete callback form
Given I have passed the means test
And I enter my personal details
And I select the contact option 'I’ll call CLA'
And I select the contact option 'I will call you'
# All steps that are clicking continue written in identical format so can reuse code
And I click continue
Then I am taken to the "Your details have been submitted" page located on "/result/confirmation"
Expand Down
9 changes: 9 additions & 0 deletions behave/features/steps/common_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,15 @@ def step_check_page(context, page, header):
assert_header_on_page(header, context)


@step("I save the reference number")
def step_save_reference_number(context):
reference_number = context.helperfunc.find_by_xpath(
'//div[@class="govuk-panel__body"]/strong'
)
context.reference_number = reference_number.text.strip()
assert reference_number is not None


@step('I am taken to the "{header}" page for the case located at "{sub_page}"')
def step_impl_taken_to_page(context, sub_page, header):
# can't use the above step because there is a case reference in the url
Expand Down
30 changes: 30 additions & 0 deletions behave/features/steps/frontend_announce.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import logging
from behave import step
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException, NoSuchElementException
from selenium.webdriver.common.by import By

CALL_ANNOUNCE_WARNING_ID = "cla-call-announce-warning"


@step("The 'do not announce the call is from CLA' warning is present")
def step_impl_cla_announce_warning_present(context):
try:
element = context.helperfunc.find_by_id(CALL_ANNOUNCE_WARNING_ID)
except TimeoutException:
logging.error("The call announce warning element is not present.")
assert element is not None


@step("the 'do not announce the call is from CLA' warning is not present")
def step_impl_cla_announce_warning_not_present(context):
try:
WebDriverWait(context.helperfunc.driver(), 5).until(
EC.invisibility_of_element((By.ID, CALL_ANNOUNCE_WARNING_ID))
)
except TimeoutException:
logging.error("The call announce warning element is present.")
except NoSuchElementException:
# Pass because this is expected result.
pass
6 changes: 6 additions & 0 deletions behave/features/steps/frontend_specialist_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ def step_impl_search_and_select_case(context, case):
search_and_select_case(context, case_ref)


@step("I search for and select a case using my saved reference number")
def step_impl_search_and_select_saved_case(context):
# This test is dependent on `I save the reference number` step in order to work
search_and_select_case(context, context.reference_number)


def select_a_case(context, case_reference, check_only_unaccepted_cases):
table = context.helperfunc.find_by_css_selector(".ListTable")
unaccepted_check = "unaccepted" if check_only_unaccepted_cases else ""
Expand Down
44 changes: 37 additions & 7 deletions behave/features/steps/public_contact_us.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
ClA_CONTACT_US_USER,
CLA_CONTACT_US_USER_PERSON_TO_CALL,
CLA_NUMBER,
ClA_CONTACT_US_OPTIONS,
)
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import (
Expand Down Expand Up @@ -69,24 +70,31 @@ def step_impl_contact_cla_page(context):
)


@step("I select the contact option 'Call someone else instead of me'")
def step_impl_select_call_someone_else(context):
@step("I select the contact option '{option}'")
def step_impl_select_call_someone_else(context, option):
radio_option = ""

for key, value in ClA_CONTACT_US_OPTIONS.items():
if key in option:
radio_option = value
break

# input can not be found without first finding form
context.callback_form = context.helperfunc.find_by_xpath("//form")
callback_element = context.callback_form.find_element_by_xpath(
'//input[@value="thirdparty"]'
f'//input[@value="{radio_option}"]'
)
assert callback_element is not None
callback_element.click()
assert callback_element.get_attribute("value") == "thirdparty"
assert callback_element.get_attribute("value") == f"{radio_option}"


@step('I select the next available "{option}" time slot')
def step_impl_select_next_available_time_slot(context, option):
def is_call_today_option_visible(*args):
try:
context.callback_form.find_element_by_xpath(
'//input[@value="today"]' '[@id="thirdparty-time-specific_day-0"]'
f"//input[@value='today'][@id='{option}-time-specific_day-0']"
)
return True
except NoSuchElementException:
Expand All @@ -95,7 +103,7 @@ def is_call_today_option_visible(*args):
context.callback_form = context.helperfunc.find_by_xpath("//form")
if is_call_today_option_visible() is True:
call_today = context.callback_form.find_element_by_xpath(
'//input[@value="today"]' '[@id="thirdparty-time-specific_day-0"]'
f"//input[@value='today'][@id='{option}-time-specific_day-0']"
)
call_today.click()
assert call_today.get_attribute("value") == "today"
Expand All @@ -104,7 +112,7 @@ def is_call_today_option_visible(*args):
)
else:
specific_day = context.callback_form.find_element_by_xpath(
'//input[@value="specific_day"]' '[@id="thirdparty-time-specific_day-1"]'
f"//input[@value='specific_day'][@id='{option}-time-specific_day-1']"
)
specific_day.click()
assert specific_day.get_attribute("value") == "specific_day"
Expand Down Expand Up @@ -147,6 +155,18 @@ def step_impl_enter_phone_number(context):
assert full_name_input.get_attribute("value") == value


# the users phone number
@step("I enter my phone number")
def step_impl_enter_my_phone_number(context):
value = CLA_NUMBER
callback_form = context.helperfunc.find_by_xpath("//form")
full_name_input = callback_form.find_element_by_xpath(
"//input[@id='callback-contact_number']"
)
full_name_input.send_keys(value)
assert full_name_input.get_attribute("value") == value


@step("I select \"{option}\" from the 'Relationship to you' drop down options")
def step_impl_select_relationship_option(context, option):
context.callback_form = context.helperfunc.find_by_xpath("//form")
Expand All @@ -160,3 +180,13 @@ def step_impl_select_relationship_option(context, option):
select.select_by_visible_text(option)
except StaleElementReferenceException:
assert False, f"Could find {option} in 'Relationship to you select' options"


@step("I select '{option}' to announce call options")
def step_impl_select_announce_call_option(context, option):
value_option = "0" if option == "Yes" else "1"
context.callback_form = context.helperfunc.find_by_xpath("//form")
announce_call_radio = context.callback_form.find_element_by_xpath(
f'//*[@id="callback-announce_call_from_cla-{value_option}"]'
)
announce_call_radio.click()
11 changes: 0 additions & 11 deletions behave/features/steps/public_eligibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,6 @@ def step_impl_enter_details(context):
)


@step("I select the contact option 'I’ll call CLA'")
def step_impl_select_contact_option(context):
context.callback_form = context.helperfunc.find_by_xpath("//form")
callback_element = context.callback_form.find_element_by_xpath(
'//input[@value="call"]'
)
assert callback_element is not None
callback_element.click()
assert callback_element.get_attribute("value") == "call"


@step("I should be shown the CLA number")
def step_impl_cla_number_shown(context):
confirmation_text_element = context.helperfunc.find_by_css_selector(
Expand Down
6 changes: 6 additions & 0 deletions behave/helper/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,9 @@
ERROR_TITLE = "There is a problem"
BBC_WEBSITE = "https://www.bbc.co.uk/weather"
BBC_INTERNATIONAL_WEBSITE = "https://www.bbc.com/weather"

ClA_CONTACT_US_OPTIONS = {
"I will call you": "call",
"Call me back": "callback",
"Call someone else instead of me": "thirdparty",
}
3 changes: 2 additions & 1 deletion orb.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
version: 2.1
description: The end-to-end test suite for use in CLA app pipelines
namespace: cla-end-to-end-tests
orbs:
aws-cli: circleci/[email protected]
aws-ecr: circleci/[email protected] # this orb doesn't support OIDC v2, so we use aws-cli to authenticate
Expand Down Expand Up @@ -80,4 +81,4 @@ commands:
when: always
- store_artifacts:
path: /tmp/end-to-end-data
destination: data
destination: data

0 comments on commit a94fa97

Please sign in to comment.