From 79b2772f62fa9d10deba6484b2382da77df59161 Mon Sep 17 00:00:00 2001 From: Patrick Sweeting Date: Thu, 14 Nov 2024 13:32:00 +0000 Subject: [PATCH] EL-1825 Removing FALA tests and docker set up (#146) * EL-1825 Removing FALA tests and docker set up * EL-1825 Removing circleci pull for FALA and updated wrapper.sh to not use FALA tags * EL-1825 Removing circleci pull for FALA and updated wrapper.sh to not use FALA tags * EL-1825 Removing FALA constants and orbs --- .circleci/config.yml | 7 - README.md | 4 +- behave/README.md | 4 - behave/docker-compose.local.yml | 2 - behave/docker-compose.yml | 35 --- .../cla_fala/fala_end_to_end_tests.feature | 86 ------- .../features/steps/fala_end_to_end_tests.py | 212 ------------------ behave/helper/constants.py | 2 - behave/wrapper.sh | 9 +- orb.yml | 9 - 10 files changed, 3 insertions(+), 367 deletions(-) delete mode 100644 behave/features/cla_fala/fala_end_to_end_tests.feature delete mode 100644 behave/features/steps/fala_end_to_end_tests.py diff --git a/.circleci/config.yml b/.circleci/config.yml index 00c2e1a7..8c5df8bc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -46,13 +46,6 @@ jobs: - run: | ./.circleci/pull_images clasocketserver - # Pull fala image - - aws-cli/setup: - role_arn: $FALA_ECR_ROLE_TO_ASSUME - region: $ECR_REGION - - run: | - ./.circleci/pull_images fala - - run: name: Build / Check services are up command: | diff --git a/README.md b/README.md index 39d8c1cd..329b8d86 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # cla-end-to-end-tests -This is the behave end to end test suite which covers the CLA applications for the laa-cla-fala team. +This is the behave end-to-end test suite which covers the CLA applications for the laa-cla-fala team. This repository defines a Circlei CI orb and a docker image alongside the `behave` test suite itself, allowing portability to the CI pipelines of the other applications. @@ -15,7 +15,7 @@ of the `ministryofjustice` organisation, which you should be from github. ``` circleci orb publish orb.yml ministryofjustice/cla-end-to-end-tests@dev:first ``` -To incorporate orb publishing into the CI pipeline in future, we may want to use the `circleci/orb-tools` orb +To incorporate orb publishing into the CI pipeline in the future, we may want to use the `circleci/orb-tools` orb ### Job and command The orb exposes a `behave` job and a `behave` command. The command should not need to be used directly: diff --git a/behave/README.md b/behave/README.md index f0a14d5e..155209ad 100644 --- a/behave/README.md +++ b/behave/README.md @@ -27,10 +27,6 @@ Cla_public feature files: `behave > features > cla_public` -fala feature files: - -`behave > features > fala` - ## How to run tests If you are working on an M1 machine, please add the below to your behave/.env file. There is an example file at .env.m1.example that you can rename to .env to avoid doing this. diff --git a/behave/docker-compose.local.yml b/behave/docker-compose.local.yml index 453c155a..127c521a 100644 --- a/behave/docker-compose.local.yml +++ b/behave/docker-compose.local.yml @@ -18,5 +18,3 @@ services: ALPINE_BASE_IMAGE: ${ALPINE_BASE_IMAGE:-alpine:3.15} clasocketserver: build: https://github.com/ministryofjustice/cla_frontend.git#master:cla_socketserver - fala: - build: https://github.com/ministryofjustice/fala.git#master diff --git a/behave/docker-compose.yml b/behave/docker-compose.yml index 15a7686b..facef053 100644 --- a/behave/docker-compose.yml +++ b/behave/docker-compose.yml @@ -9,7 +9,6 @@ services: -wait tcp://clasocketserver:8005 -wait tcp://clabackend:8000 -wait tcp://clapublic:8000 - -wait tcp://fala:8000 -wait tcp://seleniumchrome:4444 -wait tcp://clabackendooh:8000 -wait tcp://clabackendsecurity:8000 @@ -22,7 +21,6 @@ services: - clabackend - seleniumchrome - clasocketserver - - fala - prev_db - clabackendooh - clabackendsecurity @@ -43,7 +41,6 @@ services: CLA_E2E_PUBLIC_URL: ${CLA_E2E_PUBLIC_URL:-http://clapublic:8000} CLA_E2E_BACKEND_URL: ${CLA_E2E_BACKEND_URL:-http://clabackend:8000} CLA_E2E_FRONTEND_URL: ${CLA_E2E_FRONTEND_URL:-http://clafrontend:8000} - CLA_E2E_FALA_URL: ${CLA_E2E_FALA_URL:-http://fala:8000} CLA_E2E_SELENIUM_WEB_DRIVER_URL: ${CLA_E2E_SELENIUM_WEB_DRIVER_URL:-http://seleniumchrome:4444/wd/hub} CALL_CENTRE_CLIENT_ID: b4b9220ffcb11ebfdab1 CALL_CENTRE_SECRET_ID: 2df71313bdd38a2e1b815015e1b14387e7681d41 @@ -51,7 +48,6 @@ services: CLA_PROVIDER_CLIENT_ID: 59657ed22d980251cdd3 CLA_PROVIDER_SECRET_ID: 0494287c65bdf61d29f0eeed467ec8e090f0d80f DATABASE_SNAPSHOT_ENABLED: ${DATABASE_SNAPSHOT_ENABLED:-false} - FALA_TESTS_ONLY: ${FALA_TESTS_ONLY:-false} PGPASSWORD: postgres PGUSER: postgres PGHOST: db @@ -236,34 +232,3 @@ services: TESTING: "True" depends_on: - clabackend - - fala: - image: ${FALA_IMAGE:-754256621582.dkr.ecr.eu-west-2.amazonaws.com/laa-get-access/fala:master} - ports: - - "8013:8000" - environment: - HOST_NAME: "fala" - SECRET_KEY: CHANGE_ME - LAALAA_API_HOST: https://laa-legal-adviser-api-staging.apps.live-1.cloud-platform.service.justice.gov.uk - CLA_ENV: dev - DB_PORT: 5440 - DB_HOST: fala_db - DB_NAME: fala_db - DB_USER: postgres - DB_PASSWORD: postgres - depends_on: - - fala_db - - fala_db: - image: postgres:16.3 - ports: - - "5440:5432" - environment: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - POSTGRES_DB: fala_db - healthcheck: - test: ["CMD-SHELL", "sh -c 'pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}'"] - interval: 10s - timeout: 3s - retries: 3 diff --git a/behave/features/cla_fala/fala_end_to_end_tests.feature b/behave/features/cla_fala/fala_end_to_end_tests.feature deleted file mode 100644 index f670ddd1..00000000 --- a/behave/features/cla_fala/fala_end_to_end_tests.feature +++ /dev/null @@ -1,86 +0,0 @@ -@fala -Feature: FALA end to end tests - - Testing the search tool - - Testing to apply filters to the search tool - - Testing the translation - - Background: Homepage page - Given I am on the Find a legal aid adviser homepage - - @fala-search-postcode @a11y-check - Scenario Outline: Search for legal advisers via postcode - Given I provide the "" details - When I select the "search" button on the FALA homepage - Then I am taken to the page corresponding to "" result - Examples: - | location | - | SW1H 9AJ | - - - @fala-search-not-valid @a11y-check - Scenario Outline: Search for legal advisers via invalid postcode or city returns error - Given I provide the "" details - When I select the "search" button on the FALA homepage - Then A "Postcode not found" error is returned - Examples: - | location | - | London | - | SWP 9AJ | - - - @fala-apply-filter-after-search @a11y-check - Scenario Outline: Applying filters on the result page provide a new result list of legal advisers - Given I provide the "" details - When I select the "search" button on the FALA homepage - Then I am taken to the page corresponding to "" result - When I browse through the filter categories and select "" - And I select the "Apply filter" button - Then the result page containing "" is updated to apply a filter "" - And there are less results visible on the results page - Examples: - | location | filter_label | - | SW1H 9AJ | crm | - - - @fala-search-no-results @a11y-check - Scenario: I search for a town that does not have any solicitors and fails - Given I am on the Find a legal aid adviser homepage - And I provide an organisation name "Non existent org" - When I select the "search" button on the FALA homepage - Then no results are returned - - - @fala-search-organisation @a11y-check - Scenario Outline: Search by organisation name - Given I provide the "" details - And I provide an organisation name "" - When I select the "search" button on the FALA homepage - Then I am taken to the page corresponding to the "" "" search result - And 1 result is visible on the results page - Examples: - | location | organisation | - | SW1H 9AJ | Boothroyds LLP | - - - @fala-dom-translation @a11y-check - Scenario Outline: Selecting a language correctly updates the DOM - When I select the language "" with value "" - Then the page is updated to "" and the title starts with "" - Examples: - | code_indicator | language | title_starts_with | - | cy | Welsh | Dewch | - | gd | Scots Gaelic | Lorg | - - - @fala-apply-filter-on-homepage @a11y-check - Scenario Outline: Applying filters specifically on the homepage, filters correctly - Given I collect the resulting number for a generic "" search - When I am on the Find a legal aid adviser homepage - And I provide the "" details - And I browse through the filter categories and select "" - And I select the "Apply filter" button - Then the result page containing "" is updated to apply a filter "" - And there are less results visible on the results page - Examples: - | location | filter_label | - | SW1H 9AJ | edu | diff --git a/behave/features/steps/fala_end_to_end_tests.py b/behave/features/steps/fala_end_to_end_tests.py deleted file mode 100644 index 0732d2c7..00000000 --- a/behave/features/steps/fala_end_to_end_tests.py +++ /dev/null @@ -1,212 +0,0 @@ -from helper.constants import ( - CLA_FALA_URL, - FALA_HEADER, - MINIMUM_SLEEP_SECONDS, - ERROR_TITLE, -) -from behave import step -from selenium.webdriver.common.by import By -from selenium.webdriver.support.select import Select -from selenium.webdriver.support.ui import WebDriverWait -from selenium.common.exceptions import StaleElementReferenceException - - -def assert_result_page(context, expected_url, expected_title, expected_results=False): - current_url = context.helperfunc.driver().current_url - title_xpath = context.helperfunc.find_by_xpath( - "//html/body/div/main/div/div/h1" - ).text.replace("\n", " ") - result_container_xpath = context.helperfunc.find_by_xpath( - '//div[@class="search-results-container"]' - ) - result_count = context.helperfunc.find_by_xpath('//section/p[@class="govuk-body"]') - - assert ( - current_url == expected_url - ), f" actual URL {current_url} does not match expected value {expected_url}" - assert ( - title_xpath == expected_title - ), f"Page title {title_xpath} does not match expected value {expected_title}" - assert ( - result_container_xpath is not None - ), "Could not find search results container element" - assert result_count is not None, "Could not find result number paragraph element" - - if expected_results: - context.results = int(result_count.text.split()[0]) - - -@step("I am on the Find a legal aid adviser homepage") -def step_impl_homepage(context): - homepage_url = f"{CLA_FALA_URL}" - context.helperfunc.open(homepage_url) - title_xpath = context.helperfunc.find_by_xpath( - "//html/body/div/main/div/div/h1" - ).text.replace("\n", " ") - - assert title_xpath == FALA_HEADER - - -@step('I provide the "{location}" details') -def step_impl_input_location_provided(context, location): - input_location_id = context.helperfunc.find_by_id("id_postcode") - input_location_id.send_keys(location) - - assert input_location_id.get_attribute("value") == location - - -@step('I provide an organisation name "{organisation}"') -def step_impl_input_organisation_provided(context, organisation): - input_organisation_id = context.helperfunc.find_by_id("id_name") - input_organisation_id.send_keys(organisation) - - assert input_organisation_id.get_attribute("value") == organisation - - -@step('I select the "search" button on the FALA homepage') -def step_impl_search_clicked(context): - context.helperfunc.click_button(By.ID, "searchButton") - - -@step('I am taken to the page corresponding to "{location}" result') -def step_impl_result_page_with_location_only(context, location): - expected_url = ( - f"{CLA_FALA_URL}/?postcode={location.replace(' ', '+')}&name=&search=" - ) - expected_title = FALA_HEADER - - assert_result_page(context, expected_url, expected_title, expected_results=True) - - -@step('I browse through the filter categories and select "{filter_label}"') -def step_impl_checkbox_filter_clicked(context, filter_label): - checkbox_id = context.helperfunc.find_by_css_selector_without_wait( - f"input[type='checkbox'][value='{filter_label}']" - ).get_attribute("id") - # click the label for the checkbox rather than the checkbox itself - context.helperfunc.find_by_css_selector(f"label[for='{checkbox_id}']").click() - - -@step('I select the "Apply filter" button') -def step_impl_apply_filter_on_homepage(context): - context.helperfunc.click_button(By.NAME, "filter") - - -@step( - 'the result page containing "{location}" is updated to apply a filter "{filter_label}"' -) -def step_impl_apply_filter_on_result_page(context, location, filter_label): - location_format = location.replace(" ", "+") - expected_url = f"{CLA_FALA_URL}/?postcode={location_format}&name=&categories={filter_label}&filter=" - expected_title = FALA_HEADER - - assert_result_page(context, expected_url, expected_title) - - -@step("no results are returned") -def step_impl_error_shown_on_page(context): - alert = context.helperfunc.find_by_css_selector(".alert-message") - assert alert is not None - - expected_text = "No results\nThere are no results matching your search criteria." - assert alert.text == expected_text - - -@step( - 'I am taken to the page corresponding to the "{location}" "{organisation}" search result' -) -def step_impl_result_page_with_location_organisation_provided( - context, location, organisation -): - organisation_format = organisation.replace(" ", "+") - location_format = location.replace(" ", "+") - expected_url = ( - f"{CLA_FALA_URL}/?postcode={location_format}&name={organisation_format}&search=" - ) - expected_title = FALA_HEADER - - assert_result_page(context, expected_url, expected_title) - - -@step("{count:d} result is visible on the results page") -def step_impl_count_results_displayed_on_results_page(context, count): - count = int(count) - list_results_items = context.helperfunc.find_many_by_xpath( - "//ul[@Class='org-list']/li" - ) - assert list_results_items is not None - - list_count = len(list_results_items) - assert list_count == count, f"actual count is {list_count}" - - -@step('I select the language "{language}" with value "{code_indicator}"') -def step_impl_language_selection(context, language, code_indicator): - def select_text(*args): - Select(context.helperfunc.find_by_xpath("//select")).select_by_visible_text( - f"{language}" - ) - return True - - def check_first_option(*args): - select_chosen_language = Select( - context.helperfunc.find_by_xpath("//select") - ).first_selected_option - assert select_chosen_language.get_attribute("text") == f"{language}" - assert select_chosen_language.get_attribute("value") == f"{code_indicator}" - return True - - wait = WebDriverWait(context.helperfunc.driver(), MINIMUM_SLEEP_SECONDS) - wait.until(select_text) - - wait = WebDriverWait( - context.helperfunc.driver(), - MINIMUM_SLEEP_SECONDS, - ignored_exceptions=[StaleElementReferenceException], - ) - wait.until(check_first_option) - - -@step( - 'the page is updated to "{code_indicator}" and the title starts with "{title_starts_with}"' -) -def step_impl_page_translated(context, code_indicator, title_starts_with): - updated_page = context.helperfunc.find_by_xpath("/html").get_attribute("lang") - dom_updated_title = context.helperfunc.find_by_xpath( - "//html/body/div/main/div/div/h1" - ).text - - assert updated_page == f"{code_indicator}" - assert dom_updated_title.startswith(f"{title_starts_with}") - - -@step("There are less results visible on the results page") -def step_impl_less_results_returned(context): - total_results = context.helperfunc.find_by_xpath( - '//section/p[@class="govuk-body"]' - ).text.split()[0] - - assert int(total_results) < context.results - - -@step('I collect the resulting number for a generic "{location}" search') -def step_impl_resulting_generic_search(context, location): - context.execute_steps( - f""" - Given I provide the "{location}" details - And I select the "search" button on the FALA homepage - And I am taken to the page corresponding to "{location}" result - """ - ) - - -@step('A "{message}" error is returned') -def step_impl_postcode_not_found_error_returned(context, message): - error_title = context.helperfunc.find_by_css_selector(".govuk-error-summary__title") - error_message = context.helperfunc.find_by_css_selector( - ".govuk-error-summary__body" - ) - - assert error_title, error_message is not None - assert error_title.text == ERROR_TITLE - assert error_message.text == message, f"actual error message is {error_message}" diff --git a/behave/helper/constants.py b/behave/helper/constants.py index 34abc2ef..5325f630 100644 --- a/behave/helper/constants.py +++ b/behave/helper/constants.py @@ -13,7 +13,6 @@ CLA_FRONTEND_OOH_URL = "http://clafrontendooh:8000" CLA_FRONTEND_CSV_URL = "/provider/csvupload/" CLA_PUBLIC_URL = os.environ.get("CLA_E2E_PUBLIC_URL") -CLA_FALA_URL = os.environ.get("CLA_E2E_FALA_URL") SELENIUM_WEB_DRIVER_URL = os.environ.get("CLA_E2E_SELENIUM_WEB_DRIVER_URL") MINIMUM_WAIT_UNTIL_TIME = 10 CLA_NUMBER = "0345 345 4 345" @@ -221,7 +220,6 @@ MINIMUM_SLEEP_SECONDS = 2 -FALA_HEADER = "Find a legal aid adviser or family mediator" ERROR_TITLE = "There is a problem" BBC_WEBSITE = "https://www.bbc.co.uk/weather" BBC_INTERNATIONAL_WEBSITE = "https://www.bbc.com/weather" diff --git a/behave/wrapper.sh b/behave/wrapper.sh index 013d58b9..4d459bd4 100755 --- a/behave/wrapper.sh +++ b/behave/wrapper.sh @@ -5,14 +5,7 @@ export A11Y=${A11Y_ENABLED:-false} echo "A11Y is $A11Y" -TAGS="" -# Run only FALA tagged tests -if [ "$FALA_TESTS_ONLY" = "true" ] -then - TAGS="--tags=@fala" -fi -echo "TAGS is $TAGS" -exec behave "-D a11y=$A11Y" $TAGS +exec behave "-D a11y=$A11Y" # Clean up downloads rm -rf data/downloads/* diff --git a/orb.yml b/orb.yml index ed66286a..d99afd61 100644 --- a/orb.yml +++ b/orb.yml @@ -49,15 +49,6 @@ commands: - run: | cd $E2E_WORKING_DIRECTORY ./.circleci/pull_images clasocketserver - - # Pull fala image - - aws-cli/setup: - role_arn: $FALA_ECR_ROLE_TO_ASSUME - region: ECR_REGION - - run: | - cd $E2E_WORKING_DIRECTORY - ./.circleci/pull_images fala - - run: name: Check services are up command: |