From 4e63a601e97833cf115f0570decfdbdd5c322a0d Mon Sep 17 00:00:00 2001 From: Jonathan Bobel Date: Wed, 31 Jan 2024 11:10:46 -0500 Subject: [PATCH 01/64] Bug - very small content update on pricing page --- app/templates/views/pricing/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/views/pricing/index.html b/app/templates/views/pricing/index.html index 436da7735..73c67770e 100644 --- a/app/templates/views/pricing/index.html +++ b/app/templates/views/pricing/index.html @@ -30,7 +30,7 @@ more parts towards the allowance if you:

Long text messages

-

If a text message is longer than 160 characters (including spaces), it counts as more than one message.

+

If a text message is longer than 160 characters (including spaces), it counts as more than one message part.

{% call mapping_table( From e3ff679b5ed15099b32e9f40c3330ba48acdf38b Mon Sep 17 00:00:00 2001 From: Beverly Nguyen Date: Tue, 20 Feb 2024 11:32:05 -0800 Subject: [PATCH 02/64] added padding to td --- app/assets/sass/uswds/_uswds-theme-custom-styles.scss | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/assets/sass/uswds/_uswds-theme-custom-styles.scss b/app/assets/sass/uswds/_uswds-theme-custom-styles.scss index addf9cc7a..1236eaf5b 100644 --- a/app/assets/sass/uswds/_uswds-theme-custom-styles.scss +++ b/app/assets/sass/uswds/_uswds-theme-custom-styles.scss @@ -405,6 +405,9 @@ td.table-empty-message { th { padding: 0.5rem 0.5rem; } + td { + padding: 0.8rem; + } } #template-list { From 60bcd9ddbd7c228efe8a04732ac06f3eb9f2ca8b Mon Sep 17 00:00:00 2001 From: Beverly Nguyen Date: Tue, 20 Feb 2024 11:56:26 -0800 Subject: [PATCH 03/64] added padding to td --- app/assets/sass/uswds/_uswds-theme-custom-styles.scss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/sass/uswds/_uswds-theme-custom-styles.scss b/app/assets/sass/uswds/_uswds-theme-custom-styles.scss index 1236eaf5b..1d55791df 100644 --- a/app/assets/sass/uswds/_uswds-theme-custom-styles.scss +++ b/app/assets/sass/uswds/_uswds-theme-custom-styles.scss @@ -403,10 +403,10 @@ td.table-empty-message { width: 5%; } th { - padding: 0.5rem 0.5rem; + padding: 0.5rem 1rem } td { - padding: 0.8rem; + padding: 0.5rem 1rem } } From 4b39d5ffe927e157de7a09fcd04f8bb17f1efef7 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 15 Sep 2023 10:12:01 -0400 Subject: [PATCH 04/64] Re-enable E2E GitHub action jobs This changeset re-enables the GitHub action jobs we had to disable to make it possible to deploy recent changes. Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 42 ++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 99ef30c3b..880427912 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -44,29 +44,29 @@ jobs: run: npm test - name: Run py tests with coverage run: poetry run coverage run --omit=*/notifications_utils/* -m pytest --maxfail=10 --ignore=tests/end_to_end tests/ - # - name: Run E2E tests - # run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end - # env: - # NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} - # NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - # NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - # NOTIFY_E2E_TEST_URI: ${{ secrets.NOTIFY_E2E_TEST_URI }} + - name: Run E2E tests + run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end + env: + NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} + NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + NOTIFY_E2E_TEST_URI: ${{ secrets.NOTIFY_E2E_TEST_URI }} - name: Check coverage threshold run: poetry run coverage report --fail-under=90 - # - name: Health check - # run: | - # response=$(curl -url ${{secrets.NOTIFY_E2E_TEST_URI}}_status) - # if grep -q "ok" <<< "$response"; then - # echo "Health check passed" - # else - # echo "Health check failed" - # exit 1 - # fi - # env: - # NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} - # NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - # NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - # NOTIFY_E2E_TEST_URI: ${{ secrets.NOTIFY_E2E_TEST_URI }} + - name: Health check + run: | + response=$(curl -url ${{secrets.NOTIFY_E2E_TEST_URI}}_status) + if grep -q "ok" <<< "$response"; then + echo "Health check passed" + else + echo "Health check failed" + exit 1 + fi + env: + NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} + NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + NOTIFY_E2E_TEST_URI: ${{ secrets.NOTIFY_E2E_TEST_URI }} validate-new-relic-config: runs-on: ubuntu-latest From d25f0869e017733e75bd0f3e805e79ca492fcf90 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 22 Dec 2023 14:14:06 -0500 Subject: [PATCH 05/64] First attempt at getting the API to run for E2E tests Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 71 +++++++++++++++++++++++++++++------- 1 file changed, 57 insertions(+), 14 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 880427912..a29937511 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -44,6 +44,62 @@ jobs: run: npm test - name: Run py tests with coverage run: poetry run coverage run --omit=*/notifications_utils/* -m pytest --maxfail=10 --ignore=tests/end_to_end tests/ + - name: Check coverage threshold + run: poetry run coverage report --fail-under=90 + + end-to-end-tests: + permissions: + checks: write + pull-requests: write + contents: write + runs-on: ubuntu-latest + services: + postgres: + image: postgres + env: + POSTGRES_USER: user + POSTGRES_PASSWORD: password + POSTGRES_DB: test_notification_api + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + # Maps tcp port 5432 on service container to the host + - 5432:5432 + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/setup-project + - uses: jwalton/gh-find-current-pr@v1 + id: findPr + - uses: ArtiomTr/jest-coverage-report-action@v2 + with: + test-script: npm test + output: report-markdown + annotations: failed-tests + prnumber: ${{ steps.findPr.outputs.number }} + - name: Clone API + uses: actions/checkout@v3 + with: + repository: GSA/notifications-api + path: './notifications-api' + - name: Install API dependencies + with: + path: './notifications-api' + run: make bootstrap + env: + SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + - name: Run API server + with: + path: './notifications-api' + run: make run-procfile & + env: + SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - name: Run E2E tests run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end env: @@ -51,22 +107,9 @@ jobs: NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} NOTIFY_E2E_TEST_URI: ${{ secrets.NOTIFY_E2E_TEST_URI }} + API_HOST_NAME: http://localhost:6011 - name: Check coverage threshold run: poetry run coverage report --fail-under=90 - - name: Health check - run: | - response=$(curl -url ${{secrets.NOTIFY_E2E_TEST_URI}}_status) - if grep -q "ok" <<< "$response"; then - echo "Health check passed" - else - echo "Health check failed" - exit 1 - fi - env: - NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} - NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - NOTIFY_E2E_TEST_URI: ${{ secrets.NOTIFY_E2E_TEST_URI }} validate-new-relic-config: runs-on: ubuntu-latest From 89b6e13afb25cf826e068060accd64b272caedcf Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 22 Dec 2023 14:34:12 -0500 Subject: [PATCH 06/64] Just trying to get the workflow to run Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 126 +++++++++++++++++------------------ 1 file changed, 63 insertions(+), 63 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index a29937511..736323589 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -47,69 +47,69 @@ jobs: - name: Check coverage threshold run: poetry run coverage report --fail-under=90 - end-to-end-tests: - permissions: - checks: write - pull-requests: write - contents: write - runs-on: ubuntu-latest - services: - postgres: - image: postgres - env: - POSTGRES_USER: user - POSTGRES_PASSWORD: password - POSTGRES_DB: test_notification_api - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - # Maps tcp port 5432 on service container to the host - - 5432:5432 - steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/setup-project - - uses: jwalton/gh-find-current-pr@v1 - id: findPr - - uses: ArtiomTr/jest-coverage-report-action@v2 - with: - test-script: npm test - output: report-markdown - annotations: failed-tests - prnumber: ${{ steps.findPr.outputs.number }} - - name: Clone API - uses: actions/checkout@v3 - with: - repository: GSA/notifications-api - path: './notifications-api' - - name: Install API dependencies - with: - path: './notifications-api' - run: make bootstrap - env: - SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api - NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - - name: Run API server - with: - path: './notifications-api' - run: make run-procfile & - env: - SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api - NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - - name: Run E2E tests - run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end - env: - NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} - NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - NOTIFY_E2E_TEST_URI: ${{ secrets.NOTIFY_E2E_TEST_URI }} - API_HOST_NAME: http://localhost:6011 - - name: Check coverage threshold - run: poetry run coverage report --fail-under=90 + # end-to-end-tests: + # permissions: + # checks: write + # pull-requests: write + # contents: write + # runs-on: ubuntu-latest + # services: + # postgres: + # image: postgres + # env: + # POSTGRES_USER: user + # POSTGRES_PASSWORD: password + # POSTGRES_DB: test_notification_api + # options: >- + # --health-cmd pg_isready + # --health-interval 10s + # --health-timeout 5s + # --health-retries 5 + # ports: + # # Maps tcp port 5432 on service container to the host + # - 5432:5432 + # steps: + # - uses: actions/checkout@v3 + # - uses: ./.github/actions/setup-project + # - uses: jwalton/gh-find-current-pr@v1 + # id: findPr + # - uses: ArtiomTr/jest-coverage-report-action@v2 + # with: + # test-script: npm test + # output: report-markdown + # annotations: failed-tests + # prnumber: ${{ steps.findPr.outputs.number }} + # - name: Clone API + # uses: actions/checkout@v3 + # with: + # repository: GSA/notifications-api + # path: './notifications-api' + # - name: Install API dependencies + # with: + # path: './notifications-api' + # run: make bootstrap + # env: + # SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + # NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + # NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + # - name: Run API server + # with: + # path: './notifications-api' + # run: make run-procfile & + # env: + # SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + # NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + # NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + # - name: Run E2E tests + # run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end + # env: + # NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} + # NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + # NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + # NOTIFY_E2E_TEST_URI: ${{ secrets.NOTIFY_E2E_TEST_URI }} + # API_HOST_NAME: http://localhost:6011 + # - name: Check coverage threshold + # run: poetry run coverage report --fail-under=90 validate-new-relic-config: runs-on: ubuntu-latest From 891cec530035f135920aea0a1c8d23e7a2b5feb1 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 22 Dec 2023 14:42:55 -0500 Subject: [PATCH 07/64] Uncommenting E2E test job Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 126 +++++++++++++++++------------------ 1 file changed, 63 insertions(+), 63 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 736323589..a29937511 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -47,69 +47,69 @@ jobs: - name: Check coverage threshold run: poetry run coverage report --fail-under=90 - # end-to-end-tests: - # permissions: - # checks: write - # pull-requests: write - # contents: write - # runs-on: ubuntu-latest - # services: - # postgres: - # image: postgres - # env: - # POSTGRES_USER: user - # POSTGRES_PASSWORD: password - # POSTGRES_DB: test_notification_api - # options: >- - # --health-cmd pg_isready - # --health-interval 10s - # --health-timeout 5s - # --health-retries 5 - # ports: - # # Maps tcp port 5432 on service container to the host - # - 5432:5432 - # steps: - # - uses: actions/checkout@v3 - # - uses: ./.github/actions/setup-project - # - uses: jwalton/gh-find-current-pr@v1 - # id: findPr - # - uses: ArtiomTr/jest-coverage-report-action@v2 - # with: - # test-script: npm test - # output: report-markdown - # annotations: failed-tests - # prnumber: ${{ steps.findPr.outputs.number }} - # - name: Clone API - # uses: actions/checkout@v3 - # with: - # repository: GSA/notifications-api - # path: './notifications-api' - # - name: Install API dependencies - # with: - # path: './notifications-api' - # run: make bootstrap - # env: - # SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api - # NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - # NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - # - name: Run API server - # with: - # path: './notifications-api' - # run: make run-procfile & - # env: - # SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api - # NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - # NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - # - name: Run E2E tests - # run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end - # env: - # NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} - # NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - # NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - # NOTIFY_E2E_TEST_URI: ${{ secrets.NOTIFY_E2E_TEST_URI }} - # API_HOST_NAME: http://localhost:6011 - # - name: Check coverage threshold - # run: poetry run coverage report --fail-under=90 + end-to-end-tests: + permissions: + checks: write + pull-requests: write + contents: write + runs-on: ubuntu-latest + services: + postgres: + image: postgres + env: + POSTGRES_USER: user + POSTGRES_PASSWORD: password + POSTGRES_DB: test_notification_api + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + # Maps tcp port 5432 on service container to the host + - 5432:5432 + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/setup-project + - uses: jwalton/gh-find-current-pr@v1 + id: findPr + - uses: ArtiomTr/jest-coverage-report-action@v2 + with: + test-script: npm test + output: report-markdown + annotations: failed-tests + prnumber: ${{ steps.findPr.outputs.number }} + - name: Clone API + uses: actions/checkout@v3 + with: + repository: GSA/notifications-api + path: './notifications-api' + - name: Install API dependencies + with: + path: './notifications-api' + run: make bootstrap + env: + SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + - name: Run API server + with: + path: './notifications-api' + run: make run-procfile & + env: + SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + - name: Run E2E tests + run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end + env: + NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} + NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + NOTIFY_E2E_TEST_URI: ${{ secrets.NOTIFY_E2E_TEST_URI }} + API_HOST_NAME: http://localhost:6011 + - name: Check coverage threshold + run: poetry run coverage report --fail-under=90 validate-new-relic-config: runs-on: ubuntu-latest From 5a39165644795358bcd16a8798122d9fd79e342a Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 22 Dec 2023 14:45:19 -0500 Subject: [PATCH 08/64] Just trying to get the new job to run Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 50 ++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index a29937511..a57d3615c 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -73,33 +73,27 @@ jobs: - uses: ./.github/actions/setup-project - uses: jwalton/gh-find-current-pr@v1 id: findPr - - uses: ArtiomTr/jest-coverage-report-action@v2 - with: - test-script: npm test - output: report-markdown - annotations: failed-tests - prnumber: ${{ steps.findPr.outputs.number }} - - name: Clone API - uses: actions/checkout@v3 - with: - repository: GSA/notifications-api - path: './notifications-api' - - name: Install API dependencies - with: - path: './notifications-api' - run: make bootstrap - env: - SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api - NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - - name: Run API server - with: - path: './notifications-api' - run: make run-procfile & - env: - SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api - NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + # - name: Clone API + # uses: actions/checkout@v3 + # with: + # repository: GSA/notifications-api + # path: './notifications-api' + # - name: Install API dependencies + # with: + # path: './notifications-api' + # run: make bootstrap + # env: + # SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + # NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + # NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + # - name: Run API server + # with: + # path: './notifications-api' + # run: make run-procfile & + # env: + # SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + # NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + # NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - name: Run E2E tests run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end env: @@ -107,7 +101,7 @@ jobs: NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} NOTIFY_E2E_TEST_URI: ${{ secrets.NOTIFY_E2E_TEST_URI }} - API_HOST_NAME: http://localhost:6011 + # API_HOST_NAME: http://localhost:6011 - name: Check coverage threshold run: poetry run coverage report --fail-under=90 From 3003f822235f9e7496d54dded9a6e4c3360c3314 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 22 Dec 2023 14:56:38 -0500 Subject: [PATCH 09/64] Attempting to get the API cloned at least Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index a57d3615c..f638f5e65 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -73,11 +73,11 @@ jobs: - uses: ./.github/actions/setup-project - uses: jwalton/gh-find-current-pr@v1 id: findPr - # - name: Clone API - # uses: actions/checkout@v3 - # with: - # repository: GSA/notifications-api - # path: './notifications-api' + - name: Clone API + uses: actions/checkout@v3 + with: + repository: GSA/notifications-api + path: './notifications-api' # - name: Install API dependencies # with: # path: './notifications-api' @@ -102,8 +102,6 @@ jobs: NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} NOTIFY_E2E_TEST_URI: ${{ secrets.NOTIFY_E2E_TEST_URI }} # API_HOST_NAME: http://localhost:6011 - - name: Check coverage threshold - run: poetry run coverage report --fail-under=90 validate-new-relic-config: runs-on: ubuntu-latest From f8c48f77119be8083524dd81cd8d4cebf77d85ed Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 22 Dec 2023 15:11:02 -0500 Subject: [PATCH 10/64] Now trying to install API dependencies... Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index f638f5e65..dde423fd9 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -78,14 +78,14 @@ jobs: with: repository: GSA/notifications-api path: './notifications-api' - # - name: Install API dependencies - # with: - # path: './notifications-api' - # run: make bootstrap - # env: - # SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api - # NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - # NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + - name: Install API dependencies + with: + path: './notifications-api' + run: make bootstrap + env: + SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} # - name: Run API server # with: # path: './notifications-api' From bb242dc7d71cb124fb1022ce896f6f7f70b7b374 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 22 Dec 2023 15:29:03 -0500 Subject: [PATCH 11/64] Adjusted API clone and working directory Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index dde423fd9..5cfc170d5 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -77,10 +77,9 @@ jobs: uses: actions/checkout@v3 with: repository: GSA/notifications-api - path: './notifications-api' + path: 'notifications-api' - name: Install API dependencies - with: - path: './notifications-api' + working-directory: 'notifications-api' run: make bootstrap env: SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api From b8b330f55be27eac1adb03cd3d82af5c429cb84c Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 22 Dec 2023 15:52:55 -0500 Subject: [PATCH 12/64] Attempting to get API up and running Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 5cfc170d5..61b2c0696 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -13,6 +13,9 @@ env: WERKZEUG_DEBUG_PIN: off REDIS_ENABLED: 0 NODE_VERSION: 16.15.1 + AWS_US_TOLL_FREE_NUMBER: "+18556438890" + ADMIN_BASE_URL: http://localhost:6012 + API_HOST_NAME: http://localhost:6011 jobs: build: @@ -85,14 +88,13 @@ jobs: SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - # - name: Run API server - # with: - # path: './notifications-api' - # run: make run-procfile & - # env: - # SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api - # NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - # NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + - name: Run API server + working-directory: 'notifications-api' + run: make run-flask & + env: + SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - name: Run E2E tests run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end env: @@ -100,7 +102,6 @@ jobs: NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} NOTIFY_E2E_TEST_URI: ${{ secrets.NOTIFY_E2E_TEST_URI }} - # API_HOST_NAME: http://localhost:6011 validate-new-relic-config: runs-on: ubuntu-latest From d544d7c8f854409dbd03b3840321affb0216818a Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 22 Dec 2023 16:00:37 -0500 Subject: [PATCH 13/64] Now trying to run the Admin server with PR code... Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 61b2c0696..f547d367b 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -95,13 +95,16 @@ jobs: SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + - name: Run Admin server + run: make run-flask & - name: Run E2E tests run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end env: NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - NOTIFY_E2E_TEST_URI: ${{ secrets.NOTIFY_E2E_TEST_URI }} + # Run the E2E tests against the code found in this PR. + NOTIFY_E2E_TEST_URI: http://localhost:6012 validate-new-relic-config: runs-on: ubuntu-latest From 5e7319cbac434e53b54a3df155bee2310ad7be0a Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 22 Dec 2023 16:17:01 -0500 Subject: [PATCH 14/64] Testing to see if we can connect to the local server. Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index f547d367b..dd0b6baaa 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -98,7 +98,10 @@ jobs: - name: Run Admin server run: make run-flask & - name: Run E2E tests - run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end + # run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end + run: | + curl --request GET --url "http://localhost:6012" + curl --request GET --url "http://127.0.0.1:6012" env: NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} From 92b33834e86b715775583585c5bade2dc8840a8c Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 22 Dec 2023 16:38:26 -0500 Subject: [PATCH 15/64] Trying to discern if there is a difference in local URLs Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index dd0b6baaa..0e8876e17 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -97,10 +97,19 @@ jobs: NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - name: Run Admin server run: make run-flask & - - name: Run E2E tests + - name: Run E2E tests 1 # run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end - run: | + run: curl --request GET --url "http://localhost:6012" + env: + NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} + NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + # Run the E2E tests against the code found in this PR. + NOTIFY_E2E_TEST_URI: http://localhost:6012 + - name: Run E2E tests 2 + # run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end + run: curl --request GET --url "http://127.0.0.1:6012" env: NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} From b60dc00f0e435ced7db44d10389e6ee34cb1b51a Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 22 Dec 2023 16:42:53 -0500 Subject: [PATCH 16/64] A bit of cleanup and debugging comment to resume after holidays! Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 0e8876e17..c7e7cb9e5 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -97,20 +97,10 @@ jobs: NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - name: Run Admin server run: make run-flask & - - name: Run E2E tests 1 + - name: Run E2E tests # run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end - run: - curl --request GET --url "http://localhost:6012" - env: - NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} - NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - # Run the E2E tests against the code found in this PR. - NOTIFY_E2E_TEST_URI: http://localhost:6012 - - name: Run E2E tests 2 - # run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end - run: - curl --request GET --url "http://127.0.0.1:6012" + # Debugging for now to troubleshoot a connectivity issue to the local servers + run: curl --request GET --url "http://localhost:6012" env: NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} From 9c32fa2d4e7d085ff330409cd32094e23d9ddefa Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 4 Jan 2024 11:47:20 -0500 Subject: [PATCH 17/64] Adding in missing DATABASE_URL environment variable Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index c7e7cb9e5..ab1ee085e 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -85,6 +85,7 @@ jobs: working-directory: 'notifications-api' run: make bootstrap env: + DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} @@ -92,6 +93,7 @@ jobs: working-directory: 'notifications-api' run: make run-flask & env: + DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} From 91527f32f29ced3de2a7e4fc6c5fedb25df76285 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 4 Jan 2024 11:54:46 -0500 Subject: [PATCH 18/64] Changing DB name to match Makefile bootstrap command Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index ab1ee085e..943e11efc 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -62,7 +62,7 @@ jobs: env: POSTGRES_USER: user POSTGRES_PASSWORD: password - POSTGRES_DB: test_notification_api + POSTGRES_DB: notification_api options: >- --health-cmd pg_isready --health-interval 10s @@ -85,16 +85,16 @@ jobs: working-directory: 'notifications-api' run: make bootstrap env: - DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api - SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + DATABASE_URL: postgresql://user:password@localhost:5432/notification_api + SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/notification_api NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - name: Run API server working-directory: 'notifications-api' run: make run-flask & env: - DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api - SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + DATABASE_URL: postgresql://user:password@localhost:5432/notification_api + SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/notification_api NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - name: Run Admin server From 6b98cf7c35f115df636f697aced454d240211869 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 4 Jan 2024 12:01:20 -0500 Subject: [PATCH 19/64] Reverting previous change of the DB name Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 943e11efc..ab1ee085e 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -62,7 +62,7 @@ jobs: env: POSTGRES_USER: user POSTGRES_PASSWORD: password - POSTGRES_DB: notification_api + POSTGRES_DB: test_notification_api options: >- --health-cmd pg_isready --health-interval 10s @@ -85,16 +85,16 @@ jobs: working-directory: 'notifications-api' run: make bootstrap env: - DATABASE_URL: postgresql://user:password@localhost:5432/notification_api - SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/notification_api + DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api + SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - name: Run API server working-directory: 'notifications-api' run: make run-flask & env: - DATABASE_URL: postgresql://user:password@localhost:5432/notification_api - SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/notification_api + DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api + SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - name: Run Admin server From 57cd123f4e5ef3793422350ecb08651745e4a08b Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 4 Jan 2024 12:37:34 -0500 Subject: [PATCH 20/64] Adding Redis for running the API Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index ab1ee085e..8d981cb27 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -71,6 +71,16 @@ jobs: ports: # Maps tcp port 5432 on service container to the host - 5432:5432 + redis: + image: redis + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + # Maps tcp port 6379 on service container to the host + - 6379:6379 steps: - uses: actions/checkout@v3 - uses: ./.github/actions/setup-project @@ -87,14 +97,16 @@ jobs: env: DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + REDIS_URL: redis://localhost:6379 NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - name: Run API server working-directory: 'notifications-api' - run: make run-flask & + run: make run-procfile & env: DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + REDIS_URL: redis://localhost:6379 NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - name: Run Admin server From 3ba9a858457e4ed4f4ea9ac4036b4457da00407e Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 4 Jan 2024 13:17:49 -0500 Subject: [PATCH 21/64] Adjusting API environment to development Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 8d981cb27..e6c123a2f 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -100,6 +100,7 @@ jobs: REDIS_URL: redis://localhost:6379 NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + NOTIFY_ENVIRONMENT: development - name: Run API server working-directory: 'notifications-api' run: make run-procfile & @@ -109,6 +110,7 @@ jobs: REDIS_URL: redis://localhost:6379 NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + NOTIFY_ENVIRONMENT: development - name: Run Admin server run: make run-flask & - name: Run E2E tests From 558296684c84dc79f980fcfa09eacaeb96f971c5 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 4 Jan 2024 15:43:26 -0500 Subject: [PATCH 22/64] Attempting to run actual E2E tests again to see real errors Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index e6c123a2f..1ec912f6a 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -114,9 +114,9 @@ jobs: - name: Run Admin server run: make run-flask & - name: Run E2E tests - # run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end + run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end # Debugging for now to troubleshoot a connectivity issue to the local servers - run: curl --request GET --url "http://localhost:6012" + # run: curl --request GET --url "http://localhost:6012" env: NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} From b9a7e48e780a2b43ed83423a5c6a0f12a8aecf0d Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 4 Jan 2024 16:29:10 -0500 Subject: [PATCH 23/64] Attempting to work against staging API Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 107 ++++++++++++++++++----------------- 1 file changed, 54 insertions(+), 53 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 1ec912f6a..30b492a7a 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -15,7 +15,8 @@ env: NODE_VERSION: 16.15.1 AWS_US_TOLL_FREE_NUMBER: "+18556438890" ADMIN_BASE_URL: http://localhost:6012 - API_HOST_NAME: http://localhost:6011 + #API_HOST_NAME: http://localhost:6011 + API_HOST_NAME: https://notify-api-staging.app.cloud.gov jobs: build: @@ -56,67 +57,67 @@ jobs: pull-requests: write contents: write runs-on: ubuntu-latest - services: - postgres: - image: postgres - env: - POSTGRES_USER: user - POSTGRES_PASSWORD: password - POSTGRES_DB: test_notification_api - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - # Maps tcp port 5432 on service container to the host - - 5432:5432 - redis: - image: redis - options: >- - --health-cmd "redis-cli ping" - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - # Maps tcp port 6379 on service container to the host - - 6379:6379 + # services: + # postgres: + # image: postgres + # env: + # POSTGRES_USER: user + # POSTGRES_PASSWORD: password + # POSTGRES_DB: test_notification_api + # options: >- + # --health-cmd pg_isready + # --health-interval 10s + # --health-timeout 5s + # --health-retries 5 + # ports: + # # Maps tcp port 5432 on service container to the host + # - 5432:5432 + # redis: + # image: redis + # options: >- + # --health-cmd "redis-cli ping" + # --health-interval 10s + # --health-timeout 5s + # --health-retries 5 + # ports: + # # Maps tcp port 6379 on service container to the host + # - 6379:6379 steps: - uses: actions/checkout@v3 - uses: ./.github/actions/setup-project - uses: jwalton/gh-find-current-pr@v1 id: findPr - - name: Clone API - uses: actions/checkout@v3 - with: - repository: GSA/notifications-api - path: 'notifications-api' - - name: Install API dependencies - working-directory: 'notifications-api' - run: make bootstrap - env: - DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api - SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api - REDIS_URL: redis://localhost:6379 - NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - NOTIFY_ENVIRONMENT: development - - name: Run API server - working-directory: 'notifications-api' - run: make run-procfile & - env: - DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api - SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api - REDIS_URL: redis://localhost:6379 - NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - NOTIFY_ENVIRONMENT: development + # - name: Clone API + # uses: actions/checkout@v3 + # with: + # repository: GSA/notifications-api + # path: 'notifications-api' + # - name: Install API dependencies + # working-directory: 'notifications-api' + # run: make bootstrap + # env: + # DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api + # SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + # REDIS_URL: redis://localhost:6379 + # NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + # NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + # NOTIFY_ENVIRONMENT: development + # - name: Run API server + # working-directory: 'notifications-api' + # run: make run-procfile & + # env: + # DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api + # SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + # REDIS_URL: redis://localhost:6379 + # NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + # NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + # NOTIFY_ENVIRONMENT: development - name: Run Admin server run: make run-flask & - name: Run E2E tests - run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end + # run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end # Debugging for now to troubleshoot a connectivity issue to the local servers - # run: curl --request GET --url "http://localhost:6012" + run: curl --request GET --url "http://localhost:6012" env: NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} From 84559e05741ff0ac88ebddfe413f535a85c41ad5 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 4 Jan 2024 16:34:46 -0500 Subject: [PATCH 24/64] Switch Admin site environment to development Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 30b492a7a..4a5be3670 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -114,6 +114,8 @@ jobs: # NOTIFY_ENVIRONMENT: development - name: Run Admin server run: make run-flask & + env: + NOTIFY_ENVIRONMENT: development - name: Run E2E tests # run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end # Debugging for now to troubleshoot a connectivity issue to the local servers From 2201c16a2b89b3c3cf7739972b3d82dda2682756 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 4 Jan 2024 16:39:12 -0500 Subject: [PATCH 25/64] Now try to run the E2E tests! Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 4a5be3670..9dfd779d4 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -117,9 +117,9 @@ jobs: env: NOTIFY_ENVIRONMENT: development - name: Run E2E tests - # run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end + run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end # Debugging for now to troubleshoot a connectivity issue to the local servers - run: curl --request GET --url "http://localhost:6012" + # run: curl --request GET --url "http://localhost:6012" env: NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} From 46be3cd7b3b6e8bbc18281adc5ffcff0a59898e8 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 4 Jan 2024 16:44:49 -0500 Subject: [PATCH 26/64] Add a missing slash in the test URI Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 9dfd779d4..fd9372e17 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -125,7 +125,7 @@ jobs: NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} # Run the E2E tests against the code found in this PR. - NOTIFY_E2E_TEST_URI: http://localhost:6012 + NOTIFY_E2E_TEST_URI: http://localhost:6012/ validate-new-relic-config: runs-on: ubuntu-latest From c652c176177cf1eccb0e38fd6303c61b6bb722b4 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 4 Jan 2024 17:30:47 -0500 Subject: [PATCH 27/64] Clean up and fix the E2E tests so that they run Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 2 +- tests/conftest.py | 14 ++++++----- tests/end_to_end/test_accounts_page.py | 23 +++++-------------- .../test_landing_and_sign_in_pages.py | 9 +++++--- 4 files changed, 21 insertions(+), 27 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index fd9372e17..9dfd779d4 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -125,7 +125,7 @@ jobs: NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} # Run the E2E tests against the code found in this PR. - NOTIFY_E2E_TEST_URI: http://localhost:6012/ + NOTIFY_E2E_TEST_URI: http://localhost:6012 validate-new-relic-config: runs-on: ubuntu-latest diff --git a/tests/conftest.py b/tests/conftest.py index 122b76826..48ea3c5fa 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -36,6 +36,8 @@ from . import ( load_dotenv() +E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI") + class ElementNotFound(Exception): pass @@ -529,7 +531,7 @@ def mock_update_service(mocker): "sms_sender", "permissions", ] - } + }, ) return {"data": service} @@ -2353,7 +2355,7 @@ def client_request(logged_in_client, mocker, service_one): # noqa (C901 too com _test_page_title=True, _test_for_elements_without_class=True, _optional_args="", - **endpoint_kwargs + **endpoint_kwargs, ): return ClientRequest.get_url( url_for(endpoint, **(endpoint_kwargs or {})) + _optional_args, @@ -2372,7 +2374,7 @@ def client_request(logged_in_client, mocker, service_one): # noqa (C901 too com _expected_redirect=None, _test_page_title=True, _test_for_elements_without_class=True, - **endpoint_kwargs + **endpoint_kwargs, ): resp = logged_in_client.get( url, @@ -2414,7 +2416,7 @@ def client_request(logged_in_client, mocker, service_one): # noqa (C901 too com _follow_redirects=False, _expected_redirect=None, _content_type=None, - **endpoint_kwargs + **endpoint_kwargs, ): return ClientRequest.post_url( url_for(endpoint, **(endpoint_kwargs or {})), @@ -2473,7 +2475,7 @@ def client_request(logged_in_client, mocker, service_one): # noqa (C901 too com _expected_status=302, _optional_args="", _content_type=None, - **endpoint_kwargs + **endpoint_kwargs, ): return ClientRequest.post_response_from_url( url_for(endpoint, **(endpoint_kwargs or {})) + _optional_args, @@ -3523,7 +3525,7 @@ def login_for_end_to_end_testing(browser): # Open a new page and go to the staging site. context = browser.new_context() page = context.new_page() - page.goto(os.getenv("NOTIFY_E2E_TEST_URI")) + page.goto(f"{E2E_TEST_URI}/") sign_in_button = page.get_by_role("link", name="Sign in") diff --git a/tests/end_to_end/test_accounts_page.py b/tests/end_to_end/test_accounts_page.py index c8c8d5a6a..070e5d08d 100644 --- a/tests/end_to_end/test_accounts_page.py +++ b/tests/end_to_end/test_accounts_page.py @@ -4,12 +4,14 @@ import re from playwright.sync_api import expect +E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI") + def _bypass_sign_in(end_to_end_context): # Open a new page and go to the staging site. page = end_to_end_context.new_page() - page.goto(os.getenv("NOTIFY_E2E_TEST_URI")) + page.goto(f"{E2E_TEST_URI}/") sign_in_button = page.get_by_role("link", name="Sign in") @@ -24,7 +26,7 @@ def _bypass_sign_in(end_to_end_context): def test_add_new_service_workflow(end_to_end_context): # page = end_to_end_context.new_page() page = _bypass_sign_in(end_to_end_context) - page.goto(os.getenv("NOTIFY_E2E_TEST_URI")) + page.goto(f"{E2E_TEST_URI}/") # sign_in_button = page.get_by_role("link", name="Sign in") # @@ -41,9 +43,7 @@ def test_add_new_service_workflow(end_to_end_context): browser_type=end_to_end_context.browser.browser_type.name, ) - accounts_uri = "{}accounts".format(os.getenv("NOTIFY_E2E_TEST_URI")) - - page.goto(accounts_uri) + page.goto(f"{E2E_TEST_URI}/accounts") # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") @@ -82,24 +82,13 @@ def test_add_new_service_workflow(end_to_end_context): # Retrieve some prominent elements on the page for testing. service_name_input = page.locator('xpath=//input[@name="name"]') - federal_radio_button = page.locator('xpath=//input[@value="federal"]') - state_radio_button = page.locator('xpath=//input[@value="state"]') - other_radio_button = page.locator('xpath=//input[@value="other"]') add_service_button = page.get_by_role("button", name=re.compile("Add service")) expect(service_name_input).to_be_visible() - expect(federal_radio_button).to_be_visible() - expect(state_radio_button).to_be_visible() - expect(other_radio_button).to_be_visible() expect(add_service_button).to_be_visible() # Fill in the form. service_name_input.fill(new_service_name) - expect(federal_radio_button).to_be_enabled() - # Trying to click directly on the radio button resulted in a "not in viewport error" and this is the - # suggested workaround. Googling, the reason seems to be that there might be some (invisible?) css positioned - # above the radio button itself. - page.click("text='Federal government'") # Click on add service. add_service_button.click() @@ -108,7 +97,7 @@ def test_add_new_service_workflow(end_to_end_context): page.wait_for_load_state("domcontentloaded") # Check for the service name title and heading. - service_heading = page.get_by_text(new_service_name) + service_heading = page.get_by_text(new_service_name, exact=True) expect(service_heading).to_be_visible() expect(page).to_have_title(re.compile(new_service_name)) diff --git a/tests/end_to_end/test_landing_and_sign_in_pages.py b/tests/end_to_end/test_landing_and_sign_in_pages.py index 895b3851f..dd6a70beb 100644 --- a/tests/end_to_end/test_landing_and_sign_in_pages.py +++ b/tests/end_to_end/test_landing_and_sign_in_pages.py @@ -3,11 +3,13 @@ import re from playwright.sync_api import expect +E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI") + def test_landing_page(end_to_end_context): # Open a new page and go to the staging site. page = end_to_end_context.browser.new_page() - page.goto(os.getenv("NOTIFY_E2E_TEST_URI")) + page.goto(f"{E2E_TEST_URI}/") # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") @@ -17,7 +19,8 @@ def test_landing_page(end_to_end_context): # Retrieve some prominent elements on the page for testing. main_header = page.get_by_role( - "heading", name="Send text messages to your participants" + "heading", + name="Reach people where they are with government-powered text messages", ) sign_in_button = page.get_by_role("link", name="Sign in") benefits_studio_email = page.get_by_role("link", name="tts-benefits-studio@gsa.gov") @@ -51,7 +54,7 @@ def test_landing_page(end_to_end_context): # def test_sign_in_and_mfa_pages(end_to_end_context): # # Open a new page and go to the staging site. # page = end_to_end_context.new_page() -# page.goto(os.getenv("NOTIFY_E2E_TEST_URI")) +# page.goto(f"{E2E_TEST_URI}/") # print(f"test_sign_in_and_mfa_pages initial {page}") # # sign_in_button = page.get_by_role("link", name="Sign in") From 997aa8e72f0d93f7a0c81c4241f9d8e3a04928df Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 4 Jan 2024 17:42:54 -0500 Subject: [PATCH 28/64] Added missing environment variables for the server process Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 3 +++ tests/conftest.py | 11 +++++------ tests/end_to_end/test_accounts_page.py | 5 ----- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 9dfd779d4..498a9f273 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -116,6 +116,9 @@ jobs: run: make run-flask & env: NOTIFY_ENVIRONMENT: development + NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} + NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - name: Run E2E tests run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end # Debugging for now to troubleshoot a connectivity issue to the local servers diff --git a/tests/conftest.py b/tests/conftest.py index 48ea3c5fa..269bf5282 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3576,12 +3576,11 @@ def login_for_end_to_end_testing(browser): # page.wait_for_load_state('domcontentloaded') - # # Save storage state into the file. - # auth_state_path = os.path.join( - # os.getenv('NOTIFY_E2E_AUTH_STATE_PATH'), - # 'state.json' - # ) - # context.storage_state(path=auth_state_path) + # Save storage state into the file. + auth_state_path = os.path.join( + os.getenv("NOTIFY_E2E_AUTH_STATE_PATH"), "state.json" + ) + context.storage_state(path=auth_state_path) @pytest.fixture(scope="session") diff --git a/tests/end_to_end/test_accounts_page.py b/tests/end_to_end/test_accounts_page.py index 070e5d08d..498242743 100644 --- a/tests/end_to_end/test_accounts_page.py +++ b/tests/end_to_end/test_accounts_page.py @@ -28,11 +28,6 @@ def test_add_new_service_workflow(end_to_end_context): page = _bypass_sign_in(end_to_end_context) page.goto(f"{E2E_TEST_URI}/") - # sign_in_button = page.get_by_role("link", name="Sign in") - # - # Test trying to sign in. Because we are loading the email and password - # sign_in_button.click() - # # Wait for the next page to fully load. page.wait_for_load_state("domcontentloaded") From e8e23e3ac0de177f74f9f22b9886f5f0d9a89957 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 4 Jan 2024 17:55:19 -0500 Subject: [PATCH 29/64] A little more cleanup Signed-off-by: Carlo Costino --- tests/end_to_end/test_accounts_page.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/end_to_end/test_accounts_page.py b/tests/end_to_end/test_accounts_page.py index 498242743..6df6ec5be 100644 --- a/tests/end_to_end/test_accounts_page.py +++ b/tests/end_to_end/test_accounts_page.py @@ -24,7 +24,6 @@ def _bypass_sign_in(end_to_end_context): def test_add_new_service_workflow(end_to_end_context): - # page = end_to_end_context.new_page() page = _bypass_sign_in(end_to_end_context) page.goto(f"{E2E_TEST_URI}/") From 9987946f9296672e86c99c68385ddd3be5a18d5b Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 4 Jan 2024 17:58:56 -0500 Subject: [PATCH 30/64] Trying one more environment variable for auth Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 498a9f273..389e373b3 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -119,6 +119,7 @@ jobs: NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + NOTIFY_E2E_TEST_URI: http://localhost:6012 - name: Run E2E tests run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end # Debugging for now to troubleshoot a connectivity issue to the local servers From 87ca03f6d8e84055b769b12d593173ce933c321f Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 5 Jan 2024 09:36:06 -0500 Subject: [PATCH 31/64] Switch back to using the API locally in the CI/CD job Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 103 +++++++++++++++++------------------ 1 file changed, 51 insertions(+), 52 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 389e373b3..d9ad358fe 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -15,8 +15,7 @@ env: NODE_VERSION: 16.15.1 AWS_US_TOLL_FREE_NUMBER: "+18556438890" ADMIN_BASE_URL: http://localhost:6012 - #API_HOST_NAME: http://localhost:6011 - API_HOST_NAME: https://notify-api-staging.app.cloud.gov + API_HOST_NAME: http://localhost:6011 jobs: build: @@ -57,61 +56,61 @@ jobs: pull-requests: write contents: write runs-on: ubuntu-latest - # services: - # postgres: - # image: postgres - # env: - # POSTGRES_USER: user - # POSTGRES_PASSWORD: password - # POSTGRES_DB: test_notification_api - # options: >- - # --health-cmd pg_isready - # --health-interval 10s - # --health-timeout 5s - # --health-retries 5 - # ports: - # # Maps tcp port 5432 on service container to the host - # - 5432:5432 - # redis: - # image: redis - # options: >- - # --health-cmd "redis-cli ping" - # --health-interval 10s - # --health-timeout 5s - # --health-retries 5 - # ports: - # # Maps tcp port 6379 on service container to the host - # - 6379:6379 + services: + postgres: + image: postgres + env: + POSTGRES_USER: user + POSTGRES_PASSWORD: password + POSTGRES_DB: test_notification_api + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + # Maps tcp port 5432 on service container to the host + - 5432:5432 + redis: + image: redis + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + # Maps tcp port 6379 on service container to the host + - 6379:6379 steps: - uses: actions/checkout@v3 - uses: ./.github/actions/setup-project - uses: jwalton/gh-find-current-pr@v1 id: findPr - # - name: Clone API - # uses: actions/checkout@v3 - # with: - # repository: GSA/notifications-api - # path: 'notifications-api' - # - name: Install API dependencies - # working-directory: 'notifications-api' - # run: make bootstrap - # env: - # DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api - # SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api - # REDIS_URL: redis://localhost:6379 - # NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - # NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - # NOTIFY_ENVIRONMENT: development - # - name: Run API server - # working-directory: 'notifications-api' - # run: make run-procfile & - # env: - # DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api - # SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api - # REDIS_URL: redis://localhost:6379 - # NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - # NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - # NOTIFY_ENVIRONMENT: development + - name: Clone API + uses: actions/checkout@v3 + with: + repository: GSA/notifications-api + path: 'notifications-api' + - name: Install API dependencies + working-directory: 'notifications-api' + run: make bootstrap + env: + DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api + SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + REDIS_URL: redis://localhost:6379 + NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + NOTIFY_ENVIRONMENT: development + - name: Run API server + working-directory: 'notifications-api' + run: make run-procfile & + env: + DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api + SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + REDIS_URL: redis://localhost:6379 + NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + NOTIFY_ENVIRONMENT: development - name: Run Admin server run: make run-flask & env: From 95bdd335ebb0552dcdfe35d7329291ab1ebd4837 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 5 Jan 2024 10:29:02 -0500 Subject: [PATCH 32/64] Changing back to staging API; trying to get E2E auth working Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 104 +++++++++++++++++------------------ 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index d9ad358fe..d99e54b9c 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -15,7 +15,7 @@ env: NODE_VERSION: 16.15.1 AWS_US_TOLL_FREE_NUMBER: "+18556438890" ADMIN_BASE_URL: http://localhost:6012 - API_HOST_NAME: http://localhost:6011 + API_HOST_NAME: https://notify-api-staging.app.cloud.gov jobs: build: @@ -56,61 +56,61 @@ jobs: pull-requests: write contents: write runs-on: ubuntu-latest - services: - postgres: - image: postgres - env: - POSTGRES_USER: user - POSTGRES_PASSWORD: password - POSTGRES_DB: test_notification_api - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - # Maps tcp port 5432 on service container to the host - - 5432:5432 - redis: - image: redis - options: >- - --health-cmd "redis-cli ping" - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - # Maps tcp port 6379 on service container to the host - - 6379:6379 + # services: + # postgres: + # image: postgres + # env: + # POSTGRES_USER: user + # POSTGRES_PASSWORD: password + # POSTGRES_DB: test_notification_api + # options: >- + # --health-cmd pg_isready + # --health-interval 10s + # --health-timeout 5s + # --health-retries 5 + # ports: + # # Maps tcp port 5432 on service container to the host + # - 5432:5432 + # redis: + # image: redis + # options: >- + # --health-cmd "redis-cli ping" + # --health-interval 10s + # --health-timeout 5s + # --health-retries 5 + # ports: + # # Maps tcp port 6379 on service container to the host + # - 6379:6379 steps: - uses: actions/checkout@v3 - uses: ./.github/actions/setup-project - uses: jwalton/gh-find-current-pr@v1 id: findPr - - name: Clone API - uses: actions/checkout@v3 - with: - repository: GSA/notifications-api - path: 'notifications-api' - - name: Install API dependencies - working-directory: 'notifications-api' - run: make bootstrap - env: - DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api - SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api - REDIS_URL: redis://localhost:6379 - NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - NOTIFY_ENVIRONMENT: development - - name: Run API server - working-directory: 'notifications-api' - run: make run-procfile & - env: - DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api - SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api - REDIS_URL: redis://localhost:6379 - NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - NOTIFY_ENVIRONMENT: development + # - name: Clone API + # uses: actions/checkout@v3 + # with: + # repository: GSA/notifications-api + # path: 'notifications-api' + # - name: Install API dependencies + # working-directory: 'notifications-api' + # run: make bootstrap + # env: + # DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api + # SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + # REDIS_URL: redis://localhost:6379 + # NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + # NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + # NOTIFY_ENVIRONMENT: development + # - name: Run API server + # working-directory: 'notifications-api' + # run: make run-procfile & + # env: + # DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api + # SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + # REDIS_URL: redis://localhost:6379 + # NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + # NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + # NOTIFY_ENVIRONMENT: development - name: Run Admin server run: make run-flask & env: @@ -120,6 +120,7 @@ jobs: NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} NOTIFY_E2E_TEST_URI: http://localhost:6012 - name: Run E2E tests + # Run the E2E tests against the code found in this PR. run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end # Debugging for now to troubleshoot a connectivity issue to the local servers # run: curl --request GET --url "http://localhost:6012" @@ -127,7 +128,6 @@ jobs: NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - # Run the E2E tests against the code found in this PR. NOTIFY_E2E_TEST_URI: http://localhost:6012 validate-new-relic-config: From aec20b5e731a18ab659858694010760a65aa7f4b Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 5 Jan 2024 17:17:40 -0500 Subject: [PATCH 33/64] Add API access to Admin server Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index d99e54b9c..15c820b8d 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -114,6 +114,8 @@ jobs: - name: Run Admin server run: make run-flask & env: + ADMIN_CLIENT_SECRET: ${{ secrets.ADMIN_CLIENT_SECRET }} + ADMIN_CLIENT_USERNAME: ${{ secrets.ADMIN_CLIENT_USERNAME }} NOTIFY_ENVIRONMENT: development NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} From 136403a263ef504a4a73f48aa5a59578e976abf1 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 5 Jan 2024 17:22:21 -0500 Subject: [PATCH 34/64] Adding a couple more missing env vars for the admin server Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 15c820b8d..3c1845c63 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -116,6 +116,8 @@ jobs: env: ADMIN_CLIENT_SECRET: ${{ secrets.ADMIN_CLIENT_SECRET }} ADMIN_CLIENT_USERNAME: ${{ secrets.ADMIN_CLIENT_USERNAME }} + DANGEROUS_SALT: ${{ secrets.DANGEROUS_SALT }} + SECRET_KEY: ${{ secrets.SECRET_KEY }} NOTIFY_ENVIRONMENT: development NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} From c2e7b4897de34a31b408ce3534fc8e0c10fa9a05 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 5 Jan 2024 17:28:00 -0500 Subject: [PATCH 35/64] Adjusting a couple of other environment variables Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 3c1845c63..3a1e41728 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -115,10 +115,10 @@ jobs: run: make run-flask & env: ADMIN_CLIENT_SECRET: ${{ secrets.ADMIN_CLIENT_SECRET }} - ADMIN_CLIENT_USERNAME: ${{ secrets.ADMIN_CLIENT_USERNAME }} + ADMIN_CLIENT_USERNAME: notify-admin DANGEROUS_SALT: ${{ secrets.DANGEROUS_SALT }} SECRET_KEY: ${{ secrets.SECRET_KEY }} - NOTIFY_ENVIRONMENT: development + NOTIFY_ENVIRONMENT: staging NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} From 5aacdcbc356c785c0262bde7272d603c2f044096 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Tue, 9 Jan 2024 10:55:37 -0500 Subject: [PATCH 36/64] Slight adjustments to make sure no typos are present Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 3a1e41728..befe91c71 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -15,7 +15,6 @@ env: NODE_VERSION: 16.15.1 AWS_US_TOLL_FREE_NUMBER: "+18556438890" ADMIN_BASE_URL: http://localhost:6012 - API_HOST_NAME: https://notify-api-staging.app.cloud.gov jobs: build: @@ -114,10 +113,11 @@ jobs: - name: Run Admin server run: make run-flask & env: - ADMIN_CLIENT_SECRET: ${{ secrets.ADMIN_CLIENT_SECRET }} - ADMIN_CLIENT_USERNAME: notify-admin + API_HOST_NAME: https://notify-api-staging.app.cloud.gov DANGEROUS_SALT: ${{ secrets.DANGEROUS_SALT }} SECRET_KEY: ${{ secrets.SECRET_KEY }} + ADMIN_CLIENT_SECRET: ${{ secrets.ADMIN_CLIENT_SECRET }} + ADMIN_CLIENT_USERNAME: notify-admin NOTIFY_ENVIRONMENT: staging NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} From 29c20a0ee9d03aec676b2770e3932c966984c29c Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Tue, 9 Jan 2024 11:57:58 -0500 Subject: [PATCH 37/64] Trying to see if New Relic needs to be in place Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index befe91c71..b57a516e4 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -119,6 +119,8 @@ jobs: ADMIN_CLIENT_SECRET: ${{ secrets.ADMIN_CLIENT_SECRET }} ADMIN_CLIENT_USERNAME: notify-admin NOTIFY_ENVIRONMENT: staging + NEW_RELIC_LICENSE_KEY: ${{ secrets.NEW_RELIC_LICENSE_KEY }} + NR_BROWSER_KEY: ${{ secrets.NR_BROWSER_KEY }} NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} From 1b6446e213c95be211bcd3f9c34cf6fe98d67ee4 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 25 Jan 2024 13:00:39 -0500 Subject: [PATCH 38/64] Added a new E2ETest config and adjusted a couple of things Signed-off-by: Carlo Costino --- app/config.py | 23 +++++++++++++++++++++-- tests/conftest.py | 2 +- tests/end_to_end/test_accounts_page.py | 2 +- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/app/config.py b/app/config.py index f424076fa..c46ddf725 100644 --- a/app/config.py +++ b/app/config.py @@ -81,8 +81,7 @@ class Config(object): "IBAN": "GB33BUKB20201555555555", "swift": "ABCDEF12", "notify_billing_email_addresses": [ - "generic@digital.cabinet-office.gov.uk", - "first.last@digital.cabinet-office.gov.uk", + "tts-benefits-studio@gsa.gov", ], } @@ -152,6 +151,25 @@ class Staging(Production): HEADER_COLOUR = "#00ff00" # $green +class E2ETest(Staging): + """ + An environment config that is intended to operate as if it were in the + staging environment but with the configuration of the development and test + environments so the E2E tests work. + """ + + # Borrowed from development environment + SESSION_COOKIE_SECURE = False + SESSION_PROTECTION = None + HTTP_PROTOCOL = "http" + ASSET_DOMAIN = "" + ASSET_PATH = "/static/" + + # Borrowed from test environment + TESTING = True + WTF_CSRF_ENABLED = False + + class Demo(Staging): HEADER_COLOUR = "#6F72AF" # $mauve @@ -173,6 +191,7 @@ class Scanning(Production): configs = { "development": Development, "test": Test, + "e2etest": E2ETest, "scanning": Scanning, "staging": Staging, "demo": Demo, diff --git a/tests/conftest.py b/tests/conftest.py index 269bf5282..4a397b7ec 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3593,7 +3593,7 @@ def end_to_end_context(browser): def end_to_end_authenticated_context(browser): # Create and load a previously authenticated context for Playwright E2E # tests. - login_for_end_to_end_testing(browser) + # login_for_end_to_end_testing(browser) auth_state_path = os.path.join( os.getenv("NOTIFY_E2E_AUTH_STATE_PATH"), "state.json" diff --git a/tests/end_to_end/test_accounts_page.py b/tests/end_to_end/test_accounts_page.py index 6df6ec5be..8484e58b0 100644 --- a/tests/end_to_end/test_accounts_page.py +++ b/tests/end_to_end/test_accounts_page.py @@ -15,7 +15,7 @@ def _bypass_sign_in(end_to_end_context): sign_in_button = page.get_by_role("link", name="Sign in") - # Test trying to sign in. Because we are loading the email and password + # Sign in to the site - E2E test accounts are set to flow through. sign_in_button.click() # Wait for the next page to fully load. From 719ecfe8f6de1b3128bc861d3eec0616db293106 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 25 Jan 2024 13:06:21 -0500 Subject: [PATCH 39/64] Modified E2E test job environment Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index b57a516e4..12d39def8 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -118,7 +118,7 @@ jobs: SECRET_KEY: ${{ secrets.SECRET_KEY }} ADMIN_CLIENT_SECRET: ${{ secrets.ADMIN_CLIENT_SECRET }} ADMIN_CLIENT_USERNAME: notify-admin - NOTIFY_ENVIRONMENT: staging + NOTIFY_ENVIRONMENT: e2etest NEW_RELIC_LICENSE_KEY: ${{ secrets.NEW_RELIC_LICENSE_KEY }} NR_BROWSER_KEY: ${{ secrets.NR_BROWSER_KEY }} NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} From c790d8b84439c8a578738d16f727b92127b00939 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 25 Jan 2024 13:23:19 -0500 Subject: [PATCH 40/64] Added some additional environment variables to E2E command Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 12d39def8..fb67bfd5a 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -131,6 +131,11 @@ jobs: # Debugging for now to troubleshoot a connectivity issue to the local servers # run: curl --request GET --url "http://localhost:6012" env: + DANGEROUS_SALT: ${{ secrets.DANGEROUS_SALT }} + SECRET_KEY: ${{ secrets.SECRET_KEY }} + ADMIN_CLIENT_SECRET: ${{ secrets.ADMIN_CLIENT_SECRET }} + ADMIN_CLIENT_USERNAME: notify-admin + NOTIFY_ENVIRONMENT: e2etest NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} From 534daa2d82e4ed29f51efe46f9d54eed181462f8 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 25 Jan 2024 17:22:19 -0500 Subject: [PATCH 41/64] Attempting to match local E2E config with CI/CD Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 9 +-------- app/config.py | 8 ++++++++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index fb67bfd5a..22b3b8ae7 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -7,8 +7,6 @@ permissions: env: NOTIFY_ENVIRONMENT: test - NEW_RELIC_CONFIG_FILE: newrelic.ini - NEW_RELIC_ENVIRONMENT: test FLASK_APP: application.py WERKZEUG_DEBUG_PIN: off REDIS_ENABLED: 0 @@ -119,8 +117,6 @@ jobs: ADMIN_CLIENT_SECRET: ${{ secrets.ADMIN_CLIENT_SECRET }} ADMIN_CLIENT_USERNAME: notify-admin NOTIFY_ENVIRONMENT: e2etest - NEW_RELIC_LICENSE_KEY: ${{ secrets.NEW_RELIC_LICENSE_KEY }} - NR_BROWSER_KEY: ${{ secrets.NR_BROWSER_KEY }} NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} @@ -131,10 +127,6 @@ jobs: # Debugging for now to troubleshoot a connectivity issue to the local servers # run: curl --request GET --url "http://localhost:6012" env: - DANGEROUS_SALT: ${{ secrets.DANGEROUS_SALT }} - SECRET_KEY: ${{ secrets.SECRET_KEY }} - ADMIN_CLIENT_SECRET: ${{ secrets.ADMIN_CLIENT_SECRET }} - ADMIN_CLIENT_USERNAME: notify-admin NOTIFY_ENVIRONMENT: e2etest NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }} NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} @@ -149,6 +141,7 @@ jobs: - uses: ./.github/actions/setup-project - name: Validate NewRelic config env: + NEW_RELIC_CONFIG_FILE: newrelic.ini NEW_RELIC_LICENSE_KEY: ${{ secrets.NEW_RELIC_LICENSE_KEY }} # Need to set a NEW_RELIC_ENVIRONMENT with monitor_mode: true NEW_RELIC_ENVIRONMENT: staging diff --git a/app/config.py b/app/config.py index c46ddf725..091dd35fd 100644 --- a/app/config.py +++ b/app/config.py @@ -169,6 +169,14 @@ class E2ETest(Staging): TESTING = True WTF_CSRF_ENABLED = False + # buckets - mirror staging + CSV_UPLOAD_BUCKET = cloud_config.s3_credentials( + "notify-api-csv-upload-bucket-staging" + ) + LOGO_UPLOAD_BUCKET = cloud_config.s3_credentials( + "notify-admin-logo-upload-bucket-staging" + ) + class Demo(Staging): HEADER_COLOUR = "#6F72AF" # $mauve From bd41dfc1c2bcb48e90397f18b471ac5369abf411 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 25 Jan 2024 17:31:59 -0500 Subject: [PATCH 42/64] Attempting to get E2E work with local API Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 103 ++++++++++++++++++----------------- 1 file changed, 52 insertions(+), 51 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 22b3b8ae7..d68df41ad 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -53,65 +53,66 @@ jobs: pull-requests: write contents: write runs-on: ubuntu-latest - # services: - # postgres: - # image: postgres - # env: - # POSTGRES_USER: user - # POSTGRES_PASSWORD: password - # POSTGRES_DB: test_notification_api - # options: >- - # --health-cmd pg_isready - # --health-interval 10s - # --health-timeout 5s - # --health-retries 5 - # ports: - # # Maps tcp port 5432 on service container to the host - # - 5432:5432 - # redis: - # image: redis - # options: >- - # --health-cmd "redis-cli ping" - # --health-interval 10s - # --health-timeout 5s - # --health-retries 5 - # ports: - # # Maps tcp port 6379 on service container to the host - # - 6379:6379 + services: + postgres: + image: postgres + env: + POSTGRES_USER: user + POSTGRES_PASSWORD: password + POSTGRES_DB: test_notification_api + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + # Maps tcp port 5432 on service container to the host + - 5432:5432 + redis: + image: redis + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + # Maps tcp port 6379 on service container to the host + - 6379:6379 steps: - uses: actions/checkout@v3 - uses: ./.github/actions/setup-project - uses: jwalton/gh-find-current-pr@v1 id: findPr - # - name: Clone API - # uses: actions/checkout@v3 - # with: - # repository: GSA/notifications-api - # path: 'notifications-api' - # - name: Install API dependencies - # working-directory: 'notifications-api' - # run: make bootstrap - # env: - # DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api - # SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api - # REDIS_URL: redis://localhost:6379 - # NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - # NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - # NOTIFY_ENVIRONMENT: development - # - name: Run API server - # working-directory: 'notifications-api' - # run: make run-procfile & - # env: - # DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api - # SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api - # REDIS_URL: redis://localhost:6379 - # NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} - # NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - # NOTIFY_ENVIRONMENT: development + - name: Clone API + uses: actions/checkout@v3 + with: + repository: GSA/notifications-api + path: 'notifications-api' + - name: Install API dependencies + working-directory: 'notifications-api' + run: make bootstrap + env: + DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api + SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + REDIS_URL: redis://localhost:6379 + NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + NOTIFY_ENVIRONMENT: staging + - name: Run API server + working-directory: 'notifications-api' + run: make run-procfile & + env: + DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api + SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api + REDIS_URL: redis://localhost:6379 + NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} + NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} + NOTIFY_ENVIRONMENT: staging - name: Run Admin server run: make run-flask & env: - API_HOST_NAME: https://notify-api-staging.app.cloud.gov + # API_HOST_NAME: https://notify-api-staging.app.cloud.gov + API_HOST_NAME: http://localhost:6011 DANGEROUS_SALT: ${{ secrets.DANGEROUS_SALT }} SECRET_KEY: ${{ secrets.SECRET_KEY }} ADMIN_CLIENT_SECRET: ${{ secrets.ADMIN_CLIENT_SECRET }} From 3a6eeb229277a10c096d8664c3330e4a6f2e330e Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 25 Jan 2024 17:37:22 -0500 Subject: [PATCH 43/64] Swapping API back to development environment Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index d68df41ad..f5d614280 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -97,7 +97,7 @@ jobs: REDIS_URL: redis://localhost:6379 NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - NOTIFY_ENVIRONMENT: staging + NOTIFY_ENVIRONMENT: development - name: Run API server working-directory: 'notifications-api' run: make run-procfile & @@ -107,7 +107,7 @@ jobs: REDIS_URL: redis://localhost:6379 NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }} NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }} - NOTIFY_ENVIRONMENT: staging + NOTIFY_ENVIRONMENT: development - name: Run Admin server run: make run-flask & env: From fd5cd36959e59d324c240c7b7521ec5fcef9199a Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 25 Jan 2024 17:52:32 -0500 Subject: [PATCH 44/64] Remove webkit testing for now Signed-off-by: Carlo Costino --- Makefile | 4 ++-- app/config.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 8f950dbf6..aa9b404af 100644 --- a/Makefile +++ b/Makefile @@ -80,8 +80,8 @@ dead-code: .PHONY: e2e-test e2e-test: export NEW_RELIC_ENVIRONMENT=test -e2e-test: ## Run end-to-end integration tests - poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end +e2e-test: ## Run end-to-end integration tests; note that --browser webkit isn't currently working + poetry run pytest -v --browser chromium --browser firefox tests/end_to_end .PHONY: js-lint js-lint: ## Run javascript linting scanners diff --git a/app/config.py b/app/config.py index 091dd35fd..58623f426 100644 --- a/app/config.py +++ b/app/config.py @@ -159,6 +159,7 @@ class E2ETest(Staging): """ # Borrowed from development environment + DEBUG = True SESSION_COOKIE_SECURE = False SESSION_PROTECTION = None HTTP_PROTOCOL = "http" From 7259d617eebedfafcbc8c8523709b3382867ac66 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Thu, 25 Jan 2024 18:04:07 -0500 Subject: [PATCH 45/64] Actually disable webkit in CI/CD E2E tests Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index f5d614280..179615e89 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -124,7 +124,9 @@ jobs: NOTIFY_E2E_TEST_URI: http://localhost:6012 - name: Run E2E tests # Run the E2E tests against the code found in this PR. - run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end + # run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end + # --browser webkit doesn't work at this time. + run: poetry run pytest -v --browser chromium --browser firefox tests/end_to_end # Debugging for now to troubleshoot a connectivity issue to the local servers # run: curl --request GET --url "http://localhost:6012" env: From 9c392bca78cfda193694a0dab0bd4d7c4cb3225b Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 26 Jan 2024 09:26:23 -0500 Subject: [PATCH 46/64] Switch E2E test command to use Makefile Signed-off-by: Carlo Costino --- .github/workflows/checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 179615e89..53af0de2d 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -126,7 +126,7 @@ jobs: # Run the E2E tests against the code found in this PR. # run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end # --browser webkit doesn't work at this time. - run: poetry run pytest -v --browser chromium --browser firefox tests/end_to_end + run: make e2e-test # Debugging for now to troubleshoot a connectivity issue to the local servers # run: curl --request GET --url "http://localhost:6012" env: From 4180dca164540c7ec5653e2bed7c56c3b1fbc5ac Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 23 Feb 2024 11:24:03 -0500 Subject: [PATCH 47/64] Last bits of cleanup with pytest configuration for E2E tests Signed-off-by: Carlo Costino --- tests/conftest.py | 85 -------------------- tests/end_to_end/__init__.py | 0 tests/end_to_end/conftest.py | 105 +++++++++++++++++++++++++ tests/end_to_end/test_accounts_page.py | 20 +---- 4 files changed, 107 insertions(+), 103 deletions(-) create mode 100644 tests/end_to_end/__init__.py create mode 100644 tests/end_to_end/conftest.py diff --git a/tests/conftest.py b/tests/conftest.py index 4a397b7ec..6c4f94b4f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,7 +1,6 @@ import copy import json import os -import re from contextlib import contextmanager from datetime import date, datetime, timedelta from unittest.mock import Mock, PropertyMock @@ -36,8 +35,6 @@ from . import ( load_dotenv() -E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI") - class ElementNotFound(Exception): pass @@ -3521,88 +3518,6 @@ def mock_get_invited_org_user_by_id(mocker, sample_org_invite): ) -def login_for_end_to_end_testing(browser): - # Open a new page and go to the staging site. - context = browser.new_context() - page = context.new_page() - page.goto(f"{E2E_TEST_URI}/") - - sign_in_button = page.get_by_role("link", name="Sign in") - - # Test trying to sign in. - sign_in_button.click() - - # Wait for the next page to fully load. - page.wait_for_load_state("domcontentloaded") - - # Check for the sign in form elements. - # NOTE: Playwright cannot find input elements by role and recommends using - # get_by_label() instead; however, hidden form elements do not have - # labels associated with them, hence the XPath! - # See https://playwright.dev/python/docs/api/class-page#page-get-by-label - # and https://playwright.dev/python/docs/locators#locate-by-css-or-xpath - # for more information. - email_address_input = page.get_by_label("Email address") - password_input = page.get_by_label("Password") - continue_button = page.get_by_role("button", name=re.compile("Continue")) - - # Sign in to the site. - email_address_input.fill(os.getenv("NOTIFY_E2E_TEST_EMAIL")) - password_input.fill(os.getenv("NOTIFY_E2E_TEST_PASSWORD")) - continue_button.click() - - # Wait for the next page to fully load. - page.wait_for_load_state("domcontentloaded") - - # Check for the sign in form elements. - # NOTE: Playwright cannot find input elements by role and recommends using - # get_by_label() instead; however, hidden form elements do not have - # labels associated with them, hence the XPath! - # See https://playwright.dev/python/docs/api/class-page#page-get-by-label - # and https://playwright.dev/python/docs/locators#locate-by-css-or-xpath - # for more information. - # mfa_input = page.get_by_label('Text message code') - # continue_button = page.get_by_role('button', name=re.compile('Continue')) - - # # Enter MFA code and continue. - # TODO: Revisit this at a later point in time. - # totp = pyotp.TOTP( - # os.getenv('MFA_TOTP_SECRET'), - # digits=int(os.getenv('MFA_TOTP_LENGTH')) - # ) - - # mfa_input.fill(totp.now()) - # continue_button.click() - - # page.wait_for_load_state('domcontentloaded') - - # Save storage state into the file. - auth_state_path = os.path.join( - os.getenv("NOTIFY_E2E_AUTH_STATE_PATH"), "state.json" - ) - context.storage_state(path=auth_state_path) - - -@pytest.fixture(scope="session") -def end_to_end_context(browser): - context = browser.new_context() - return context - - -@pytest.fixture(scope="session") -def end_to_end_authenticated_context(browser): - # Create and load a previously authenticated context for Playwright E2E - # tests. - # login_for_end_to_end_testing(browser) - - auth_state_path = os.path.join( - os.getenv("NOTIFY_E2E_AUTH_STATE_PATH"), "state.json" - ) - context = browser.new_context(storage_state=auth_state_path) - - return context - - @pytest.fixture() def fake_markdown_file(): input = "#Test" diff --git a/tests/end_to_end/__init__.py b/tests/end_to_end/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/end_to_end/conftest.py b/tests/end_to_end/conftest.py new file mode 100644 index 000000000..6abd2e231 --- /dev/null +++ b/tests/end_to_end/conftest.py @@ -0,0 +1,105 @@ +import os +import re + +import pytest + +E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI") + + +def login_for_end_to_end_testing(browser): + # Open a new page and go to the staging site. + context = browser.new_context() + page = context.new_page() + page.goto(f"{E2E_TEST_URI}/") + + sign_in_button = page.get_by_role("link", name="Sign in") + + # Test trying to sign in. + sign_in_button.click() + + # Wait for the next page to fully load. + page.wait_for_load_state("domcontentloaded") + + # Check for the sign in form elements. + # NOTE: Playwright cannot find input elements by role and recommends using + # get_by_label() instead; however, hidden form elements do not have + # labels associated with them, hence the XPath! + # See https://playwright.dev/python/docs/api/class-page#page-get-by-label + # and https://playwright.dev/python/docs/locators#locate-by-css-or-xpath + # for more information. + email_address_input = page.get_by_label("Email address") + password_input = page.get_by_label("Password") + continue_button = page.get_by_role("button", name=re.compile("Continue")) + + # Sign in to the site. + email_address_input.fill(os.getenv("NOTIFY_E2E_TEST_EMAIL")) + password_input.fill(os.getenv("NOTIFY_E2E_TEST_PASSWORD")) + continue_button.click() + + # Wait for the next page to fully load. + page.wait_for_load_state("domcontentloaded") + + # Check for the sign in form elements. + # NOTE: Playwright cannot find input elements by role and recommends using + # get_by_label() instead; however, hidden form elements do not have + # labels associated with them, hence the XPath! + # See https://playwright.dev/python/docs/api/class-page#page-get-by-label + # and https://playwright.dev/python/docs/locators#locate-by-css-or-xpath + # for more information. + # mfa_input = page.get_by_label('Text message code') + # continue_button = page.get_by_role('button', name=re.compile('Continue')) + + # # Enter MFA code and continue. + # TODO: Revisit this at a later point in time. + # totp = pyotp.TOTP( + # os.getenv('MFA_TOTP_SECRET'), + # digits=int(os.getenv('MFA_TOTP_LENGTH')) + # ) + + # mfa_input.fill(totp.now()) + # continue_button.click() + + # page.wait_for_load_state('domcontentloaded') + + # Save storage state into the file. + auth_state_path = os.path.join( + os.getenv("NOTIFY_E2E_AUTH_STATE_PATH"), "state.json" + ) + context.storage_state(path=auth_state_path) + + +@pytest.fixture(scope="session") +def end_to_end_context(browser): + context = browser.new_context() + return context + + +@pytest.fixture(scope="session") +def end_to_end_authenticated_context(browser): + # Create and load a previously authenticated context for Playwright E2E + # tests. + # login_for_end_to_end_testing(browser) + + auth_state_path = os.path.join( + os.getenv("NOTIFY_E2E_AUTH_STATE_PATH"), "state.json" + ) + context = browser.new_context(storage_state=auth_state_path) + + return context + + +@pytest.fixture(scope="session") +def bypass_sign_in(end_to_end_context): + # Open a new page and go to the staging site. + page = end_to_end_context.new_page() + + page.goto(f"{E2E_TEST_URI}/") + + sign_in_button = page.get_by_role("link", name="Sign in") + + # Sign in to the site - E2E test accounts are set to flow through. + sign_in_button.click() + + # Wait for the next page to fully load. + page.wait_for_load_state("domcontentloaded") + return page diff --git a/tests/end_to_end/test_accounts_page.py b/tests/end_to_end/test_accounts_page.py index 8484e58b0..89357c7ed 100644 --- a/tests/end_to_end/test_accounts_page.py +++ b/tests/end_to_end/test_accounts_page.py @@ -7,24 +7,8 @@ from playwright.sync_api import expect E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI") -def _bypass_sign_in(end_to_end_context): - # Open a new page and go to the staging site. - page = end_to_end_context.new_page() - - page.goto(f"{E2E_TEST_URI}/") - - sign_in_button = page.get_by_role("link", name="Sign in") - - # Sign in to the site - E2E test accounts are set to flow through. - sign_in_button.click() - - # Wait for the next page to fully load. - page.wait_for_load_state("domcontentloaded") - return page - - -def test_add_new_service_workflow(end_to_end_context): - page = _bypass_sign_in(end_to_end_context) +def test_add_new_service_workflow(bypass_sign_in, end_to_end_context): + page = bypass_sign_in(end_to_end_context) page.goto(f"{E2E_TEST_URI}/") # Wait for the next page to fully load. From 4741b381c2545bff5857ff1cd835c8bf1fd23e2e Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 23 Feb 2024 11:39:14 -0500 Subject: [PATCH 48/64] Adjusting authenticated page fixture Signed-off-by: Carlo Costino --- tests/end_to_end/conftest.py | 2 +- tests/end_to_end/test_accounts_page.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/end_to_end/conftest.py b/tests/end_to_end/conftest.py index 6abd2e231..48d1bcd35 100644 --- a/tests/end_to_end/conftest.py +++ b/tests/end_to_end/conftest.py @@ -89,7 +89,7 @@ def end_to_end_authenticated_context(browser): @pytest.fixture(scope="session") -def bypass_sign_in(end_to_end_context): +def authenticated_page(end_to_end_context): # Open a new page and go to the staging site. page = end_to_end_context.new_page() diff --git a/tests/end_to_end/test_accounts_page.py b/tests/end_to_end/test_accounts_page.py index 89357c7ed..411728e33 100644 --- a/tests/end_to_end/test_accounts_page.py +++ b/tests/end_to_end/test_accounts_page.py @@ -7,8 +7,8 @@ from playwright.sync_api import expect E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI") -def test_add_new_service_workflow(bypass_sign_in, end_to_end_context): - page = bypass_sign_in(end_to_end_context) +def test_add_new_service_workflow(authenticated_page, end_to_end_context): + page = authenticated_page page.goto(f"{E2E_TEST_URI}/") # Wait for the next page to fully load. From 25646c2e2f26e8b92f78320e7ec4d4ab4f42f78b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 23 Feb 2024 17:18:04 +0000 Subject: [PATCH 49/64] Bump notifications-python-client from 8.2.0 to 9.0.0 Bumps [notifications-python-client](https://github.com/alphagov/notifications-python-client) from 8.2.0 to 9.0.0. - [Changelog](https://github.com/alphagov/notifications-python-client/blob/main/CHANGELOG.md) - [Commits](https://github.com/alphagov/notifications-python-client/compare/8.2.0...9.0.0) --- updated-dependencies: - dependency-name: notifications-python-client dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- poetry.lock | 6 +++--- pyproject.toml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/poetry.lock b/poetry.lock index a7e09cf85..74a0b0ac6 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1672,12 +1672,12 @@ setuptools = "*" [[package]] name = "notifications-python-client" -version = "8.2.0" +version = "9.0.0" description = "Python API client for GOV.UK Notify." optional = false python-versions = ">=3.7" files = [ - {file = "notifications_python_client-8.2.0-py3-none-any.whl", hash = "sha256:8cd8bd01ae603a972a5413c430ca42b16f6481f37d98406c3e9b68c1c192f59e"}, + {file = "notifications_python_client-9.0.0-py3-none-any.whl", hash = "sha256:664a5b5da2aa1a00efa8106bfa4855db04da95d79586e5edfb0411637d20d2d9"}, ] [package.dependencies] @@ -3075,4 +3075,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = ">=3.9,<3.12" -content-hash = "1021999aefa9b1f83453706c25c87226b61da5d07b58bf2593dbd97eb5db844c" +content-hash = "30e3f9f8e1a094e67cc780b496641dfbe33e639cefccf35ee3b1553c9a683b71" diff --git a/pyproject.toml b/pyproject.toml index e1f2ae143..5aed7711a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,7 +22,7 @@ humanize = "~=4.9" itsdangerous = "~=2.1" jinja2 = "~=3.1" newrelic = "*" -notifications-python-client = "==8.2.0" +notifications-python-client = "==9.0.0" notifications-utils = {git = "https://github.com/GSA/notifications-utils.git"} pyexcel = "==0.7.0" pyexcel-io = "==0.6.6" From e71351d94938779145a1478c6683e3eafcc5a327 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 23 Feb 2024 16:02:16 -0500 Subject: [PATCH 50/64] Add E2E documentation and clean E2E tests This changeset adds additional documentation for how to write new E2E tests and cleans up the two existing tests slightly to make better use of the fixtures that are defined. Signed-off-by: Carlo Costino --- docs/end_to_end_tests.md | 99 +++++++++++++++++++ tests/end_to_end/conftest.py | 21 +++- tests/end_to_end/test_accounts_page.py | 4 - .../test_landing_and_sign_in_pages.py | 9 +- 4 files changed, 118 insertions(+), 15 deletions(-) diff --git a/docs/end_to_end_tests.md b/docs/end_to_end_tests.md index 02eec2e8b..557bdf327 100644 --- a/docs/end_to_end_tests.md +++ b/docs/end_to_end_tests.md @@ -106,6 +106,105 @@ All of the E2E tests are found in the `tests/end_to_end` folder and are written as `pytest` scripts using [Playwright's Python Framework](https://playwright.dev/python/docs/writing-tests). +Inside the `tests/end_to_end` folder you'll see a `conftest.py` file, +which is similar to the one found in the root `tests` folder but is +specific to the E2E tests. + +There a few fixtures defined in here, but the three most important at +this time are these: + +- `end_to_end_context`: A Playwright context object needed to interact + with a browser instance. +- `authenticated_page`: A Playwright page object that has gone through + the sign in process the E2E user is authenticated. +- `unauthenticated_page`: A Playwright page object that has only loaded + the home page; no authentication done. + +In short, if you're starting a test from scratch and testing pages that +do not require authentication, you'll start with the +`unauthenticated_page` fixture and work from there. + +Any test that requires you to be authenticated, you'll start with the +`authenticated_page` object as that'll have taken care of getting +everything set for you and logged into the site with the E2E test user. + +The `end_to_end_context` fixture is there more for the two page than for +direct use, but there may be instances where it's easier to get data +or manipulate tests in ways that are better done with the context object +instead of working back from the page object. + + +### Creating a new test file + +If you want to create a new test file to help organize tests (a great +idea!), it will be handy to import the Playwright `expect` and set the +base URL/URI for yourself, like this: + +```python +from playwright.sync_api import expect + +E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI") +``` + +By importing Playwright's `expect` object for tests and setting +something like `E2E_TEST_URI` for yourself, it will make writing tests +much easier. + + +### Using the fixtures + +To use the `authenticated_page` or `unauthenticated_page` fixtures, you +start by defining a test function and then passing in the fixture you +need as a positional argument. This works the same as the other +functions defined to create a test for pytest. + +For example, the test for the landing page starts with this: + +```python +def test_landing_page(unauthenticated_page): + page = unauthenticated_page + ... +``` + +Note the passing in of the `unauthenticated_page` fixture - there is no +need to import this or anything, just pass it into the function. pytest +takes care of everything else for you. + +The second line that defines a `page` variable is a convenience, since +you'll be referencing the page object a lot. This is recommended to +help keep tests readable while keeping fixture names descriptive. + +If you need to test an authenticate page, such as the accounts page, +use the `authenticated_page` fixture instead, like so: + +```python +def test_add_new_service_workflow(authenticated_page): + page = authenticated_page + ... +``` + +Again, it's helpful to assign the fixture to a `page` variable for easy +reference throughout the test. + +Lastly, if you need want access to the Playwright context object that is +used behind the page fixtures, you can reference it directly as well: + +```python +def test_add_new_service_workflow(authenticated_page, end_to_end_context): + page = authenticated_page + + # Prepare for adding a new service later in the test. + current_date_time = datetime.datetime.now() + new_service_name = "E2E Federal Test Service {now} - {browser_type}".format( + now=current_date_time.strftime("%m/%d/%Y %H:%M:%S"), + browser_type=end_to_end_context.browser.browser_type.name, + ) + ... +``` + +In this example, I've used the context to get to the browser object +itself to get the name of the browser for test data. + ## Maintaining E2E Tests with GitHub diff --git a/tests/end_to_end/conftest.py b/tests/end_to_end/conftest.py index 48d1bcd35..4819ec007 100644 --- a/tests/end_to_end/conftest.py +++ b/tests/end_to_end/conftest.py @@ -89,17 +89,30 @@ def end_to_end_authenticated_context(browser): @pytest.fixture(scope="session") -def authenticated_page(end_to_end_context): - # Open a new page and go to the staging site. +def unauthenticated_page(end_to_end_context): page = end_to_end_context.new_page() - page.goto(f"{E2E_TEST_URI}/") - sign_in_button = page.get_by_role("link", name="Sign in") + # Wait for the next page to fully load. + page.wait_for_load_state("domcontentloaded") + + return page + + +@pytest.fixture(scope="session") +def authenticated_page(end_to_end_context): + # Open a new page and go to the site. + page = end_to_end_context.new_page() + page.goto(f"{E2E_TEST_URI}/") + + # Wait for the next page to fully load. + page.wait_for_load_state("domcontentloaded") # Sign in to the site - E2E test accounts are set to flow through. + sign_in_button = page.get_by_role("link", name="Sign in") sign_in_button.click() # Wait for the next page to fully load. page.wait_for_load_state("domcontentloaded") + return page diff --git a/tests/end_to_end/test_accounts_page.py b/tests/end_to_end/test_accounts_page.py index 411728e33..b6fe8c5ac 100644 --- a/tests/end_to_end/test_accounts_page.py +++ b/tests/end_to_end/test_accounts_page.py @@ -9,10 +9,6 @@ E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI") def test_add_new_service_workflow(authenticated_page, end_to_end_context): page = authenticated_page - page.goto(f"{E2E_TEST_URI}/") - - # Wait for the next page to fully load. - page.wait_for_load_state("domcontentloaded") # Prepare for adding a new service later in the test. current_date_time = datetime.datetime.now() diff --git a/tests/end_to_end/test_landing_and_sign_in_pages.py b/tests/end_to_end/test_landing_and_sign_in_pages.py index dd6a70beb..8b0f04f86 100644 --- a/tests/end_to_end/test_landing_and_sign_in_pages.py +++ b/tests/end_to_end/test_landing_and_sign_in_pages.py @@ -6,13 +6,8 @@ from playwright.sync_api import expect E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI") -def test_landing_page(end_to_end_context): - # Open a new page and go to the staging site. - page = end_to_end_context.browser.new_page() - page.goto(f"{E2E_TEST_URI}/") - - # Check to make sure that we've arrived at the next page. - page.wait_for_load_state("domcontentloaded") +def test_landing_page(unauthenticated_page): + page = unauthenticated_page # Check the page title exists and matches what we expect. expect(page).to_have_title(re.compile("Notify.gov")) From 34d20c4d65cb6a23d10b7bf5df02adb3122e8ff0 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 23 Feb 2024 16:53:39 -0500 Subject: [PATCH 51/64] Trying to get landing page test working again Signed-off-by: Carlo Costino --- tests/end_to_end/test_landing_and_sign_in_pages.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/end_to_end/test_landing_and_sign_in_pages.py b/tests/end_to_end/test_landing_and_sign_in_pages.py index 8b0f04f86..ab1f885b1 100644 --- a/tests/end_to_end/test_landing_and_sign_in_pages.py +++ b/tests/end_to_end/test_landing_and_sign_in_pages.py @@ -7,7 +7,12 @@ E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI") def test_landing_page(unauthenticated_page): + # Open a new page and go to the staging site. page = unauthenticated_page + page.goto(f"{E2E_TEST_URI}/") + + # Check to make sure that we've arrived at the next page. + page.wait_for_load_state("domcontentloaded") # Check the page title exists and matches what we expect. expect(page).to_have_title(re.compile("Notify.gov")) From c891bc1b3f800c60dc5bef7b9392dbdf394e256d Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 23 Feb 2024 17:02:18 -0500 Subject: [PATCH 52/64] Another attempt at fixing the landing page test Signed-off-by: Carlo Costino --- tests/end_to_end/conftest.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/end_to_end/conftest.py b/tests/end_to_end/conftest.py index 4819ec007..91e52ac40 100644 --- a/tests/end_to_end/conftest.py +++ b/tests/end_to_end/conftest.py @@ -91,11 +91,6 @@ def end_to_end_authenticated_context(browser): @pytest.fixture(scope="session") def unauthenticated_page(end_to_end_context): page = end_to_end_context.new_page() - page.goto(f"{E2E_TEST_URI}/") - - # Wait for the next page to fully load. - page.wait_for_load_state("domcontentloaded") - return page From 5c6a23c87342f5ea50b4c438a92db9bdb2d2ae34 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 23 Feb 2024 17:10:41 -0500 Subject: [PATCH 53/64] Undo changes to the landing page test Signed-off-by: Carlo Costino --- tests/end_to_end/conftest.py | 11 +++-------- tests/end_to_end/test_landing_and_sign_in_pages.py | 6 +++--- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/tests/end_to_end/conftest.py b/tests/end_to_end/conftest.py index 91e52ac40..f21fbe0fc 100644 --- a/tests/end_to_end/conftest.py +++ b/tests/end_to_end/conftest.py @@ -68,11 +68,6 @@ def login_for_end_to_end_testing(browser): context.storage_state(path=auth_state_path) -@pytest.fixture(scope="session") -def end_to_end_context(browser): - context = browser.new_context() - return context - @pytest.fixture(scope="session") def end_to_end_authenticated_context(browser): @@ -89,9 +84,9 @@ def end_to_end_authenticated_context(browser): @pytest.fixture(scope="session") -def unauthenticated_page(end_to_end_context): - page = end_to_end_context.new_page() - return page +def end_to_end_context(browser): + context = browser.new_context() + return context @pytest.fixture(scope="session") diff --git a/tests/end_to_end/test_landing_and_sign_in_pages.py b/tests/end_to_end/test_landing_and_sign_in_pages.py index ab1f885b1..a9148cb31 100644 --- a/tests/end_to_end/test_landing_and_sign_in_pages.py +++ b/tests/end_to_end/test_landing_and_sign_in_pages.py @@ -6,9 +6,9 @@ from playwright.sync_api import expect E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI") -def test_landing_page(unauthenticated_page): - # Open a new page and go to the staging site. - page = unauthenticated_page +def test_landing_page(end_to_end_context): + # Open a new page and go to the site. + page = end_to_end_context.browser.new_page() page.goto(f"{E2E_TEST_URI}/") # Check to make sure that we've arrived at the next page. From 564fc7352120829ad28320eb9897736efaaa3f3e Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Fri, 23 Feb 2024 17:38:47 -0500 Subject: [PATCH 54/64] Fixed up documentation to match current state; blackened formatting Signed-off-by: Carlo Costino --- docs/end_to_end_tests.md | 29 +++++++++---------- tests/app/main/views/test_manage_users.py | 6 ++-- tests/app/main/views/test_template_folders.py | 8 +++-- tests/conftest.py | 14 +++++---- tests/end_to_end/conftest.py | 1 - 5 files changed, 30 insertions(+), 28 deletions(-) diff --git a/docs/end_to_end_tests.md b/docs/end_to_end_tests.md index 557bdf327..11758a16e 100644 --- a/docs/end_to_end_tests.md +++ b/docs/end_to_end_tests.md @@ -110,29 +110,22 @@ Inside the `tests/end_to_end` folder you'll see a `conftest.py` file, which is similar to the one found in the root `tests` folder but is specific to the E2E tests. -There a few fixtures defined in here, but the three most important at -this time are these: +There a few fixtures defined in here, but the two most important at this +time are these: - `end_to_end_context`: A Playwright context object needed to interact with a browser instance. - `authenticated_page`: A Playwright page object that has gone through the sign in process the E2E user is authenticated. -- `unauthenticated_page`: A Playwright page object that has only loaded - the home page; no authentication done. In short, if you're starting a test from scratch and testing pages that do not require authentication, you'll start with the -`unauthenticated_page` fixture and work from there. +`end_to_end_context` fixture and work from there. Any test that requires you to be authenticated, you'll start with the `authenticated_page` object as that'll have taken care of getting everything set for you and logged into the site with the E2E test user. -The `end_to_end_context` fixture is there more for the two page than for -direct use, but there may be instances where it's easier to get data -or manipulate tests in ways that are better done with the context object -instead of working back from the page object. - ### Creating a new test file @@ -153,7 +146,7 @@ much easier. ### Using the fixtures -To use the `authenticated_page` or `unauthenticated_page` fixtures, you +To use the `authenticated_page` or `end_to_end_context` fixtures, you start by defining a test function and then passing in the fixture you need as a positional argument. This works the same as the other functions defined to create a test for pytest. @@ -161,12 +154,17 @@ functions defined to create a test for pytest. For example, the test for the landing page starts with this: ```python -def test_landing_page(unauthenticated_page): - page = unauthenticated_page +def test_landing_page(end_to_end_context): + # Open a new page and go to the site. + page = end_to_end_context.browser.new_page() + page.goto(f"{E2E_TEST_URI}/") + + # Check to make sure that we've arrived at the next page. + page.wait_for_load_state("domcontentloaded") ... ``` -Note the passing in of the `unauthenticated_page` fixture - there is no +Note the passing in of the `end_to_end_context` fixture - there is no need to import this or anything, just pass it into the function. pytest takes care of everything else for you. @@ -187,7 +185,8 @@ Again, it's helpful to assign the fixture to a `page` variable for easy reference throughout the test. Lastly, if you need want access to the Playwright context object that is -used behind the page fixtures, you can reference it directly as well: +used behind the page fixtures, you can reference it directly as well +using the `end_to_end_context` fixture: ```python def test_add_new_service_workflow(authenticated_page, end_to_end_context): diff --git a/tests/app/main/views/test_manage_users.py b/tests/app/main/views/test_manage_users.py index 9bdabf925..c3d128155 100644 --- a/tests/app/main/views/test_manage_users.py +++ b/tests/app/main/views/test_manage_users.py @@ -862,9 +862,9 @@ def test_should_show_page_if_prefilled_user_is_already_invited( mock_get_invites_for_service, platform_admin_user, ): - active_user_with_permission_to_other_service[ - "email_address" - ] = "user_1@testnotify.gsa.gov" + active_user_with_permission_to_other_service["email_address"] = ( + "user_1@testnotify.gsa.gov" + ) client_request.login(platform_admin_user) mocker.patch( "app.models.user.user_api_client.get_user", diff --git a/tests/app/main/views/test_template_folders.py b/tests/app/main/views/test_template_folders.py index fae020e58..0bf2fcb08 100644 --- a/tests/app/main/views/test_template_folders.py +++ b/tests/app/main/views/test_template_folders.py @@ -31,9 +31,11 @@ def _folder(name, folder_id=None, parent=None, users_with_permission=None): "name": name, "id": folder_id or str(uuid.uuid4()), "parent_id": parent, - "users_with_permission": users_with_permission - if users_with_permission is not None - else [sample_uuid()], + "users_with_permission": ( + users_with_permission + if users_with_permission is not None + else [sample_uuid()] + ), } diff --git a/tests/conftest.py b/tests/conftest.py index 6c4f94b4f..4c2ceeea9 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -904,9 +904,11 @@ def create_service_templates(service_id, number_of_templates=4): "{}_template_{}".format(template_type, template_number), template_type, "{} template {} content".format(template_type, template_number), - subject="{} template {} subject".format(template_type, template_number) - if template_type == "email" - else None, + subject=( + "{} template {} subject".format(template_type, template_number) + if template_type == "email" + else None + ), ) ) @@ -1101,9 +1103,9 @@ def active_user_with_permission_to_other_service( active_user_with_permission_to_two_services["permissions"].pop(SERVICE_ONE_ID) active_user_with_permission_to_two_services["services"].pop(0) active_user_with_permission_to_two_services["name"] = "Service Two User" - active_user_with_permission_to_two_services[ - "email_address" - ] = "service-two-user@test.gsa.gov" + active_user_with_permission_to_two_services["email_address"] = ( + "service-two-user@test.gsa.gov" + ) return active_user_with_permission_to_two_services diff --git a/tests/end_to_end/conftest.py b/tests/end_to_end/conftest.py index f21fbe0fc..16940d4e0 100644 --- a/tests/end_to_end/conftest.py +++ b/tests/end_to_end/conftest.py @@ -68,7 +68,6 @@ def login_for_end_to_end_testing(browser): context.storage_state(path=auth_state_path) - @pytest.fixture(scope="session") def end_to_end_authenticated_context(browser): # Create and load a previously authenticated context for Playwright E2E From 66909e96249a56385b8454c25505a31a731a7762 Mon Sep 17 00:00:00 2001 From: Beverly Nguyen Date: Fri, 23 Feb 2024 17:50:25 -0800 Subject: [PATCH 55/64] added conditional --- app/main/views/dashboard.py | 1 + 1 file changed, 1 insertion(+) diff --git a/app/main/views/dashboard.py b/app/main/views/dashboard.py index 24b3e0490..4d5aca14d 100644 --- a/app/main/views/dashboard.py +++ b/app/main/views/dashboard.py @@ -76,6 +76,7 @@ def service_dashboard(service_id): "notifications": aggregate_notifications_by_job.get(job["id"], []), } for job in job_response + if aggregate_notifications_by_job.get(job["id"], []) ] return render_template( "views/dashboard/dashboard.html", From 470574e1971b47fe4e6329c8f701323c2116569e Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Tue, 20 Feb 2024 08:28:26 -0800 Subject: [PATCH 56/64] enable login.gov link on demo and production and adjust test --- app/main/views/sign_in.py | 2 +- tests/app/main/views/test_sign_in.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/main/views/sign_in.py b/app/main/views/sign_in.py index be313c59b..853b33648 100644 --- a/app/main/views/sign_in.py +++ b/app/main/views/sign_in.py @@ -198,7 +198,7 @@ def sign_in(): form=form, again=bool(redirect_url), other_device=other_device, - login_gov_enabled=bool(notify_env in ["development", "staging"]), + login_gov_enabled=True, password_reset_url=password_reset_url, initial_signin_url=initial_signin_url, ) diff --git a/tests/app/main/views/test_sign_in.py b/tests/app/main/views/test_sign_in.py index 7970afa08..453790536 100644 --- a/tests/app/main/views/test_sign_in.py +++ b/tests/app/main/views/test_sign_in.py @@ -21,8 +21,8 @@ def test_render_sign_in_template_for_new_user(client_request): # Removing for the pilot # assert page.select('main a')[0].text == 'create one now' # assert page.select('main a')[0]['href'] == url_for('main.register') - assert page.select("main a")[0].text == "Forgot your password?" - assert page.select("main a")[0]["href"] == url_for("main.forgot_password") + assert page.select("main a")[1].text == "Forgot your password?" + assert page.select("main a")[1]["href"] == url_for("main.forgot_password") assert "Sign in again" not in normalize_spaces(page.text) From 4e32ef37b6515e04d3215e0ed8b39d6f8e93954b Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Tue, 20 Feb 2024 12:43:31 -0500 Subject: [PATCH 57/64] Adjust connectivity to Login.gov - Adds Login.gov to remaining egress proxies (both prototype and production URLs) - Swaps links to Login.gov to production environment Signed-off-by: Carlo Costino --- .github/workflows/deploy-demo.yml | 10 +++++----- .github/workflows/deploy.yml | 10 +++++----- deploy-config/egress_proxy/notify-admin-demo.allow.acl | 2 ++ .../egress_proxy/notify-admin-production.allow.acl | 2 ++ 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/.github/workflows/deploy-demo.yml b/.github/workflows/deploy-demo.yml index e1d76775a..bf9757493 100644 --- a/.github/workflows/deploy-demo.yml +++ b/.github/workflows/deploy-demo.yml @@ -56,12 +56,12 @@ jobs: NR_BROWSER_KEY: ${{ secrets.NR_BROWSER_KEY }} LOGIN_PEM: ${{ secrets.LOGIN_PEM }} LOGIN_DOT_GOV_CLIENT_ID: "urn:gov:gsa:openidconnect.profiles:sp:sso:gsa:notify-gov" - LOGIN_DOT_GOV_USER_INFO_URL: "https://idp.int.identitysandbox.gov/api/openid_connect/userinfo" - LOGIN_DOT_GOV_ACCESS_TOKEN_URL: "https://idp.int.identitysandbox.gov/api/openid_connect/token" - LOGIN_DOT_GOV_LOGOUT_URL: "https://idp.int.identitysandbox.gov/openid_connect/logout?client_id=urn:gov:gsa:openidconnect.profiles:sp:sso:gsa:notify-gov&post_logout_redirect_uri=https://notify-demo.app.cloud.gov/sign-out" - LOGIN_DOT_GOV_BASE_LOGOUT_URL: "https://idp.int.identitysandbox.gov/openid_connect/logout?" + LOGIN_DOT_GOV_USER_INFO_URL: "https://secure.login.gov/api/openid_connect/userinfo" + LOGIN_DOT_GOV_ACCESS_TOKEN_URL: "https://secure.login.gov/api/openid_connect/token" + LOGIN_DOT_GOV_LOGOUT_URL: "https://secure.login.gov/openid_connect/logout?client_id=urn:gov:gsa:openidconnect.profiles:sp:sso:gsa:notify-gov&post_logout_redirect_uri=https://notify-demo.app.cloud.gov/sign-out" + LOGIN_DOT_GOV_BASE_LOGOUT_URL: "https://secure.login.gov/openid_connect/logout?" LOGIN_DOT_GOV_SIGNOUT_REDIRECT: "https://notify-demo.app.cloud.gov/sign-out" - LOGIN_DOT_GOV_INITIAL_SIGNIN_URL: "https://idp.int.identitysandbox.gov/openid_connect/authorize?acr_values=http%3A%2F%2Fidmanagement.gov%2Fns%2Fassurance%2Fial%2F1&client_id=urn:gov:gsa:openidconnect.profiles:sp:sso:gsa:notify-gov&nonce=01234567890123456789012345&prompt=select_account&redirect_uri=https://notify-demo.app.cloud.gov/sign-in&response_type=code&scope=openid+email&state=abcdefghijklmnopabcdefghijklmnop" + LOGIN_DOT_GOV_INITIAL_SIGNIN_URL: "https://secure.login.gov/openid_connect/authorize?acr_values=http%3A%2F%2Fidmanagement.gov%2Fns%2Fassurance%2Fial%2F1&client_id=urn:gov:gsa:openidconnect.profiles:sp:sso:gsa:notify-gov&nonce=01234567890123456789012345&prompt=select_account&redirect_uri=https://notify-demo.app.cloud.gov/sign-in&response_type=code&scope=openid+email&state=abcdefghijklmnopabcdefghijklmnop" with: cf_username: ${{ secrets.CLOUDGOV_USERNAME }} cf_password: ${{ secrets.CLOUDGOV_PASSWORD }} diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 767acae72..915994d58 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -62,12 +62,12 @@ jobs: NR_BROWSER_KEY: ${{ secrets.NR_BROWSER_KEY }} LOGIN_PEM: ${{ secrets.LOGIN_PEM }} LOGIN_DOT_GOV_CLIENT_ID: "urn:gov:gsa:openidconnect.profiles:sp:sso:gsa:notify-gov" - LOGIN_DOT_GOV_USER_INFO_URL: "https://idp.int.identitysandbox.gov/api/openid_connect/userinfo" - LOGIN_DOT_GOV_ACCESS_TOKEN_URL: "https://idp.int.identitysandbox.gov/api/openid_connect/token" - LOGIN_DOT_GOV_LOGOUT_URL: "https://idp.int.identitysandbox.gov/openid_connect/logout?client_id=urn:gov:gsa:openidconnect.profiles:sp:sso:gsa:notify-gov&post_logout_redirect_uri=https://notify-staging.app.cloud.gov/sign-out" - LOGIN_DOT_GOV_BASE_LOGOUT_URL: "https://idp.int.identitysandbox.gov/openid_connect/logout?" + LOGIN_DOT_GOV_USER_INFO_URL: "https://secure.login.gov/api/openid_connect/userinfo" + LOGIN_DOT_GOV_ACCESS_TOKEN_URL: "https://secure.login.gov/api/openid_connect/token" + LOGIN_DOT_GOV_LOGOUT_URL: "https://secure.login.gov/openid_connect/logout?client_id=urn:gov:gsa:openidconnect.profiles:sp:sso:gsa:notify-gov&post_logout_redirect_uri=https://notify-staging.app.cloud.gov/sign-out" + LOGIN_DOT_GOV_BASE_LOGOUT_URL: "https://secure.login.gov/openid_connect/logout?" LOGIN_DOT_GOV_SIGNOUT_REDIRECT: "https://notify-staging.app.cloud.gov/sign-out" - LOGIN_DOT_GOV_INITIAL_SIGNIN_URL: "https://idp.int.identitysandbox.gov/openid_connect/authorize?acr_values=http%3A%2F%2Fidmanagement.gov%2Fns%2Fassurance%2Fial%2F1&client_id=urn:gov:gsa:openidconnect.profiles:sp:sso:gsa:notify-gov&nonce=01234567890123456789012345&prompt=select_account&redirect_uri=https://notify-staging.app.cloud.gov/sign-in&response_type=code&scope=openid+email&state=abcdefghijklmnopabcdefghijklmnop" + LOGIN_DOT_GOV_INITIAL_SIGNIN_URL: "https://secure.login.gov/openid_connect/authorize?acr_values=http%3A%2F%2Fidmanagement.gov%2Fns%2Fassurance%2Fial%2F1&client_id=urn:gov:gsa:openidconnect.profiles:sp:sso:gsa:notify-gov&nonce=01234567890123456789012345&prompt=select_account&redirect_uri=https://notify-staging.app.cloud.gov/sign-in&response_type=code&scope=openid+email&state=abcdefghijklmnopabcdefghijklmnop" with: cf_username: ${{ secrets.CLOUDGOV_USERNAME }} cf_password: ${{ secrets.CLOUDGOV_PASSWORD }} diff --git a/deploy-config/egress_proxy/notify-admin-demo.allow.acl b/deploy-config/egress_proxy/notify-admin-demo.allow.acl index 4718f99e7..41bf3a365 100644 --- a/deploy-config/egress_proxy/notify-admin-demo.allow.acl +++ b/deploy-config/egress_proxy/notify-admin-demo.allow.acl @@ -1,2 +1,4 @@ gov-collector.newrelic.com egress-proxy-notify-admin-demo.apps.internal +idp.int.identitysandbox.gov +secure.login.gov diff --git a/deploy-config/egress_proxy/notify-admin-production.allow.acl b/deploy-config/egress_proxy/notify-admin-production.allow.acl index 2173a6b4b..8103b0915 100644 --- a/deploy-config/egress_proxy/notify-admin-production.allow.acl +++ b/deploy-config/egress_proxy/notify-admin-production.allow.acl @@ -1,2 +1,4 @@ gov-collector.newrelic.com egress-proxy-notify-admin-production.apps.internal +idp.int.identitysandbox.gov +secure.login.gov From 92fc35b6f60b2349f7a83f47d84c6f3d85022ba2 Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Mon, 26 Feb 2024 17:39:33 -0500 Subject: [PATCH 58/64] Only enable Login.gov link for demo right now We are holding off on production until we have a chance to share more information with pilot partners. Signed-off-by: Carlo Costino --- app/main/views/sign_in.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/main/views/sign_in.py b/app/main/views/sign_in.py index 853b33648..c6eaee87e 100644 --- a/app/main/views/sign_in.py +++ b/app/main/views/sign_in.py @@ -198,7 +198,7 @@ def sign_in(): form=form, again=bool(redirect_url), other_device=other_device, - login_gov_enabled=True, + login_gov_enabled=bool(notify_env in ["development", "staging", "demo"]), password_reset_url=password_reset_url, initial_signin_url=initial_signin_url, ) From f8b8dd5fb3018f428c57563d08d1b9e187347c5b Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Mon, 26 Feb 2024 17:59:18 -0500 Subject: [PATCH 59/64] Fix broken test and include note about why Signed-off-by: Carlo Costino --- tests/app/main/views/test_sign_in.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/app/main/views/test_sign_in.py b/tests/app/main/views/test_sign_in.py index 453790536..5675946dc 100644 --- a/tests/app/main/views/test_sign_in.py +++ b/tests/app/main/views/test_sign_in.py @@ -21,8 +21,10 @@ def test_render_sign_in_template_for_new_user(client_request): # Removing for the pilot # assert page.select('main a')[0].text == 'create one now' # assert page.select('main a')[0]['href'] == url_for('main.register') - assert page.select("main a")[1].text == "Forgot your password?" - assert page.select("main a")[1]["href"] == url_for("main.forgot_password") + # TODO: Fix this test to be less brittle! If the Login.gov link is enabled, + # then these indices need to be 1 instead of 0. + assert page.select("main a")[0].text == "Forgot your password?" + assert page.select("main a")[0]["href"] == url_for("main.forgot_password") assert "Sign in again" not in normalize_spaces(page.text) From 6ec0de4b63abc456c0f491f942094005c85f26cd Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Mon, 26 Feb 2024 18:07:26 -0500 Subject: [PATCH 60/64] One final note about why the test is brittle Signed-off-by: Carlo Costino --- tests/app/main/views/test_sign_in.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/app/main/views/test_sign_in.py b/tests/app/main/views/test_sign_in.py index 5675946dc..f85c756ea 100644 --- a/tests/app/main/views/test_sign_in.py +++ b/tests/app/main/views/test_sign_in.py @@ -23,6 +23,7 @@ def test_render_sign_in_template_for_new_user(client_request): # assert page.select('main a')[0]['href'] == url_for('main.register') # TODO: Fix this test to be less brittle! If the Login.gov link is enabled, # then these indices need to be 1 instead of 0. + # Currently it's not enabled for the test or production environments. assert page.select("main a")[0].text == "Forgot your password?" assert page.select("main a")[0]["href"] == url_for("main.forgot_password") assert "Sign in again" not in normalize_spaces(page.text) From 2c6e02137bbdcdf1ccceeee49877c743dc518fce Mon Sep 17 00:00:00 2001 From: Jonathan Bobel Date: Thu, 1 Feb 2024 12:09:43 -0500 Subject: [PATCH 61/64] Updates per Meghan --- app/templates/views/guidance/index.html | 4 +-- app/templates/views/roadmap.html | 4 +-- app/templates/views/security.html | 37 ++----------------------- app/templates/views/support/index.html | 6 ++-- 4 files changed, 9 insertions(+), 42 deletions(-) diff --git a/app/templates/views/guidance/index.html b/app/templates/views/guidance/index.html index e754ef245..b7d6ffa1a 100644 --- a/app/templates/views/guidance/index.html +++ b/app/templates/views/guidance/index.html @@ -41,7 +41,7 @@

To create and format your message

  1. All messages start from a template
  2. -
  3. Click “Send Messages”. You’ll see existing templates.
  4. +
  5. Click “Send Messages”. You’ll see existing templates.
  6. Add a new template or choose an existing template and select Edit.
@@ -120,7 +120,7 @@ {# Identify your program #} -

Identify your program

+

Identify your program

You can help your recipients identify your texts as legitimate by customizing your messages to clearly state who they are from. Consider using the program or benefit name that is most familiar to your recipients.

diff --git a/app/templates/views/roadmap.html b/app/templates/views/roadmap.html index 6ea2e7cfb..58c9ad4d1 100644 --- a/app/templates/views/roadmap.html +++ b/app/templates/views/roadmap.html @@ -50,9 +50,9 @@
  • Message send/failure analytics
  • - Next +

    Next

    -

    If the pilot is successful, we hope to recruit additional high-impact partners to improve outcomes for low-income individuals and families.

    +

    If the pilot is successful, we hope to recruit additional partners to improve outcomes for low-income individuals and families.

    Goals during this stage:

    diff --git a/app/templates/views/security.html b/app/templates/views/security.html index d676b37bf..35abece07 100644 --- a/app/templates/views/security.html +++ b/app/templates/views/security.html @@ -65,9 +65,9 @@

    Protect sensitive information

    Some messages include sensitive information like security codes or password reset links.

    If you’re sending a message with sensitive information, you can choose to hide those details on the Notify dashboard once the message has been sent. This means that only the message recipient will be able to see that information.

    + Screenshot of a teat message in review with the link to 'hide personalization after sending' circled. -

    User permissions and signing in

    -

    You can set different user permissions in Notify. This lets you control who in your team has access to certain parts of the service.

    Two-factor authentication

    To sign in to Notify, you’ll need to enter:

      @@ -76,11 +76,6 @@

    If signing in with a text message is a problem for your team, contact us to find out about using an email link instead.

    - Screenshot of a teat message in review with the link to 'hide personalization after sending' circled. - -

    How to hide PII after sending a message

    -

    User permissions and signing in

    You can set different user permissions in Notify. This lets you control who in your team has access to certain parts of the service.

    @@ -93,32 +88,4 @@

    If signing in with a text message is a problem for your team, contact us to find out about using an email link instead.

    - - - - - - {% endblock %} diff --git a/app/templates/views/support/index.html b/app/templates/views/support/index.html index d9d6abd53..dd5ad9c10 100644 --- a/app/templates/views/support/index.html +++ b/app/templates/views/support/index.html @@ -13,9 +13,9 @@

    Contact us

    Notify is designed to be easy to use.

      -
    • For information on personalization and data preparation, see Guidance.
    • -
    • For help interpreting delivery reports, see Delivery Status.
    • -
    • For details on pricing and what counts as a message part, see Pricing.
    • +
    • For information on personalization and data preparation, see Guidance.
    • +
    • For help interpreting delivery reports, see Delivery Status.
    • +
    • For details on pricing and what counts as a message part, see Pricing.

    If you have other questions, we are available at notify-support@gsa.gov.

    From e9f96332870e9e0f59769dbbcf1cce9c5386938a Mon Sep 17 00:00:00 2001 From: Carlo Costino Date: Tue, 27 Feb 2024 11:01:37 -0500 Subject: [PATCH 62/64] Fix typo --- app/templates/views/security.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/views/security.html b/app/templates/views/security.html index 35abece07..6d0b3e67d 100644 --- a/app/templates/views/security.html +++ b/app/templates/views/security.html @@ -66,7 +66,7 @@

    Some messages include sensitive information like security codes or password reset links.

    If you’re sending a message with sensitive information, you can choose to hide those details on the Notify dashboard once the message has been sent. This means that only the message recipient will be able to see that information.

    Screenshot of a teat message in review with the link to 'hide personalization after sending' circled. + alt="Screenshot of a test message in review with the link to 'hide personalization after sending' circled.">

    Two-factor authentication

    To sign in to Notify, you’ll need to enter:

    From 8661a2235356827b42379f9a5906893bfc99455c Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Thu, 29 Feb 2024 08:24:53 -0800 Subject: [PATCH 63/64] fix date format in batch review (notify-admin-1171) --- app/main/forms.py | 16 ++++++++------ app/main/views/api_keys.py | 22 +++++++++++-------- app/main/views/manage_users.py | 22 ++++++++++--------- app/main/views/performance.py | 6 +++--- app/main/views/send.py | 28 ++++++++++++++----------- app/main/views/service_settings.py | 24 +++++++++++++-------- app/templates/components/table.html | 4 ++-- app/templates/partials/jobs/status.html | 6 +++--- tests/app/main/views/test_activity.py | 24 ++++++++++----------- tests/app/main/views/test_jobs.py | 12 +++++------ 10 files changed, 92 insertions(+), 72 deletions(-) diff --git a/app/main/forms.py b/app/main/forms.py index c01ce8fcc..2e6655cc5 100644 --- a/app/main/forms.py +++ b/app/main/forms.py @@ -1781,12 +1781,16 @@ class TemplateAndFoldersSelectionForm(Form): None, [ # ('email', 'Email') if 'email' in available_template_types else None, - ("sms", "Start with a blank template") - if "sms" in available_template_types - else None, - ("copy-existing", "Copy an existing template") - if allow_adding_copy_of_template - else None, + ( + ("sms", "Start with a blank template") + if "sms" in available_template_types + else None + ), + ( + ("copy-existing", "Copy an existing template") + if allow_adding_copy_of_template + else None + ), ], ) ) diff --git a/app/main/views/api_keys.py b/app/main/views/api_keys.py index 4f8c3b29e..8cb28ba59 100644 --- a/app/main/views/api_keys.py +++ b/app/main/views/api_keys.py @@ -168,12 +168,14 @@ def api_callbacks(service_id): return render_template( "views/api/callbacks.html", - received_text_messages_callback=received_text_messages_callback["url"] - if received_text_messages_callback - else None, - delivery_status_callback=delivery_status_callback["url"] - if delivery_status_callback - else None, + received_text_messages_callback=( + received_text_messages_callback["url"] + if received_text_messages_callback + else None + ), + delivery_status_callback=( + delivery_status_callback["url"] if delivery_status_callback else None + ), ) @@ -262,9 +264,11 @@ def received_text_messages_callback(service_id): received_text_messages_callback = get_received_text_messages_callback() form = CallbackForm( - url=received_text_messages_callback.get("url") - if received_text_messages_callback - else "", + url=( + received_text_messages_callback.get("url") + if received_text_messages_callback + else "" + ), bearer_token=dummy_bearer_token if received_text_messages_callback else "", ) diff --git a/app/main/views/manage_users.py b/app/main/views/manage_users.py index 4ab20f363..1b80c659e 100644 --- a/app/main/views/manage_users.py +++ b/app/main/views/manage_users.py @@ -122,16 +122,18 @@ def edit_user_permissions(service_id, user_id): form = form_class.from_user( user, service_id, - folder_permissions=None - if user.platform_admin - else [ - f["id"] - for f in current_service.all_template_folders - if user.has_template_folder_permission(f) - ], - all_template_folders=None - if user.platform_admin - else current_service.all_template_folders, + folder_permissions=( + None + if user.platform_admin + else [ + f["id"] + for f in current_service.all_template_folders + if user.has_template_folder_permission(f) + ] + ), + all_template_folders=( + None if user.platform_admin else current_service.all_template_folders + ), ) if form.validate_on_submit(): diff --git a/app/main/views/performance.py b/app/main/views/performance.py index 13445967b..1d2a4d1bc 100644 --- a/app/main/views/performance.py +++ b/app/main/views/performance.py @@ -34,8 +34,8 @@ def performance(): stats["average_percentage_under_10_seconds"] = mean( [row["percentage_under_10_seconds"] for row in stats["processing_time"]] or [0] ) - stats[ - "count_of_live_services_and_organizations" - ] = status_api_client.get_count_of_live_services_and_organizations() + stats["count_of_live_services_and_organizations"] = ( + status_api_client.get_count_of_live_services_and_organizations() + ) return render_template("views/performance.html", **stats) diff --git a/app/main/views/send.py b/app/main/views/send.py index 4332c7ddb..6c786e3ac 100644 --- a/app/main/views/send.py +++ b/app/main/views/send.py @@ -52,12 +52,14 @@ def get_example_csv_fields(column_headers, use_example_as_example, submitted_fie def get_example_csv_rows(template, use_example_as_example=True, submitted_fields=False): return { - "email": ["test@example.com"] - if use_example_as_example - else [current_user.email_address], - "sms": ["12223334444"] - if use_example_as_example - else [current_user.mobile_number], + "email": ( + ["test@example.com"] + if use_example_as_example + else [current_user.email_address] + ), + "sms": ( + ["12223334444"] if use_example_as_example else [current_user.mobile_number] + ), }[template.template_type] + get_example_csv_fields( ( placeholder @@ -511,12 +513,14 @@ def _check_messages(service_id, template_id, upload_id, preview_row): template=template, max_initial_rows_shown=50, max_errors_shown=50, - guestlist=itertools.chain.from_iterable( - [user.name, user.mobile_number, user.email_address] - for user in Users(service_id) - ) - if current_service.trial_mode - else None, + guestlist=( + itertools.chain.from_iterable( + [user.name, user.mobile_number, user.email_address] + for user in Users(service_id) + ) + if current_service.trial_mode + else None + ), remaining_messages=remaining_messages, allow_international_sms=current_service.has_permission("international_sms"), ) diff --git a/app/main/views/service_settings.py b/app/main/views/service_settings.py index 1cac1410c..628ac59e5 100644 --- a/app/main/views/service_settings.py +++ b/app/main/views/service_settings.py @@ -477,9 +477,11 @@ def service_edit_email_reply_to(service_id, reply_to_email_id): current_service.id, reply_to_email_id=reply_to_email_id, email_address=form.email_address.data, - is_default=True - if reply_to_email_address["is_default"] - else form.is_default.data, + is_default=( + True + if reply_to_email_address["is_default"] + else form.is_default.data + ), ) return redirect(url_for(".service_email_reply_to", service_id=service_id)) try: @@ -499,9 +501,11 @@ def service_edit_email_reply_to(service_id, reply_to_email_id): ".service_verify_reply_to_address", service_id=service_id, notification_id=notification_id, - is_default=True - if reply_to_email_address["is_default"] - else form.is_default.data, + is_default=( + True + if reply_to_email_address["is_default"] + else form.is_default.data + ), replace=reply_to_email_id, ) ) @@ -702,9 +706,11 @@ def service_edit_sms_sender(service_id, sms_sender_id): service_api_client.update_sms_sender( current_service.id, sms_sender_id=sms_sender_id, - sms_sender=sms_sender["sms_sender"] - if is_inbound_number - else form.sms_sender.data.replace("\r", ""), + sms_sender=( + sms_sender["sms_sender"] + if is_inbound_number + else form.sms_sender.data.replace("\r", "") + ), is_default=True if sms_sender["is_default"] else form.is_default.data, ) return redirect(url_for(".service_sms_senders", service_id=service_id)) diff --git a/app/templates/components/table.html b/app/templates/components/table.html index 50eb73d9a..a76f2c6bd 100644 --- a/app/templates/components/table.html +++ b/app/templates/components/table.html @@ -171,8 +171,8 @@ {% endif %}

    {{ notification.status|format_notification_status_as_time( - notification.created_at|format_datetime_short, - (notification.sent_at or notification.created_at)|format_datetime_short + notification.created_at|format_datetime_short_america, + (notification.sent_at or notification.created_at)|format_datetime_short_america ) }}

    {% if displayed_on_single_line %}{% endif %} diff --git a/app/templates/partials/jobs/status.html b/app/templates/partials/jobs/status.html index 703050e8d..b24051211 100644 --- a/app/templates/partials/jobs/status.html +++ b/app/templates/partials/jobs/status.html @@ -2,12 +2,12 @@

    {% if job.scheduled_for %} {% if job.processing_started %} - Sent by {{ job.created_by.name }} on {{ job.processing_started|format_datetime_short }} + Sent by {{ job.created_by.name }} on {{ job.processing_started|format_datetime_short_america }} {% else %} - Uploaded by {{ job.created_by.name }} on {{ job.created_at|format_datetime_short }} + Uploaded by {{ job.created_by.name }} on {{ job.created_at|format_datetime_short_america }} {% endif %} {% else %} - Sent by {{ job.created_by.name }} on {{ job.created_at|format_datetime_short }} + Sent by {{ job.created_by.name }} on {{ job.created_at|format_datetime_short_america }} {% endif %}

    {% if job.status == 'sending limits exceeded'%} diff --git a/tests/app/main/views/test_activity.py b/tests/app/main/views/test_activity.py index 96c50a308..e224c2e7d 100644 --- a/tests/app/main/views/test_activity.py +++ b/tests/app/main/views/test_activity.py @@ -160,8 +160,8 @@ def test_can_show_notifications( assert normalize_spaces( first_row.select_one(".table-field-right-aligned .align-with-message-body").text ) in [ - "Delivered 1 January at 02:00 US/Eastern", - "Delivered 1 January at 01:00 US/Eastern", + "Delivered 01-01-2020 at 01:00 AM", + "Delivered 01-01-2020 at 01:00 AM", ] assert page_title in page.h1.text.strip() @@ -656,36 +656,36 @@ def test_redacts_templates_that_should_be_redacted( @pytest.mark.parametrize( ("message_type", "status", "expected_hint_status", "single_line"), [ - ("email", "created", "Sending since 27 September at 08:30 US/Eastern", True), - ("email", "sending", "Sending since 27 September at 08:30 US/Eastern", True), + ("email", "created", "Sending since 09-27-2017 at 08:30 AM", True), + ("email", "sending", "Sending since 09-27-2017 at 08:30 AM", True), ( "email", "temporary-failure", - "Inbox not accepting messages right now 27 September at 08:30 US/Eastern", + "Inbox not accepting messages right now 09-27-2017 at 08:30 AM", False, ), ( "email", "permanent-failure", - "Email address does not exist 27 September at 08:30 US/Eastern", + "Email address does not exist 09-27-2017 at 08:30 AM", False, ), - ("email", "delivered", "Delivered 27 September at 08:30 US/Eastern", True), - ("sms", "created", "Sending since 27 September at 08:30 US/Eastern", True), - ("sms", "sending", "Sending since 27 September at 08:30 US/Eastern", True), + ("email", "delivered", "Delivered 09-27-2017 at 08:30 AM", True), + ("sms", "created", "Sending since 09-27-2017 at 08:30 AM", True), + ("sms", "sending", "Sending since 09-27-2017 at 08:30 AM", True), ( "sms", "temporary-failure", - "Phone not accepting messages right now 27 September at 08:30 US/Eastern", + "Phone not accepting messages right now 09-27-2017 at 08:30 AM", False, ), ( "sms", "permanent-failure", - "Not delivered 27 September at 08:30 US/Eastern", + "Not delivered 09-27-2017 at 08:30 AM", False, ), - ("sms", "delivered", "Delivered 27 September at 08:30 US/Eastern", True), + ("sms", "delivered", "Delivered 09-27-2017 at 08:30 AM", True), ], ) def test_sending_status_hint_displays_correctly_on_notifications_page( diff --git a/tests/app/main/views/test_jobs.py b/tests/app/main/views/test_jobs.py index 323a1fe00..3076fe88f 100644 --- a/tests/app/main/views/test_jobs.py +++ b/tests/app/main/views/test_jobs.py @@ -90,7 +90,7 @@ def test_should_show_page_for_one_job( assert page.h1.text.strip() == "thisisatest.csv" assert " ".join(page.find("tbody").find("tr").text.split()) == ( - "2021234567 template content Delivered 1 January at 06:09 US/Eastern" + "2021234567 template content Delivered 01-01-2016 at 06:09 AM" ) assert page.find("div", {"data-key": "notifications"})["data-resource"] == url_for( "main.view_job_updates", @@ -109,7 +109,7 @@ def test_should_show_page_for_one_job( assert page.find("span", {"id": "time-left"}).text == "Data available for 7 days" assert normalize_spaces(page.select_one("tbody tr").text) == normalize_spaces( - "2021234567 " "template content " "Delivered 1 January at 06:09 US/Eastern" + "2021234567 " "template content " "Delivered 01-01-2016 at 06:09 AM" ) assert page.select_one("tbody tr a")["href"] == url_for( "main.view_notification", @@ -424,8 +424,8 @@ def test_should_show_updates_for_one_job_as_json( assert "2021234567" in content["notifications"] assert "Status" in content["notifications"] assert "Delivered" in content["notifications"] - assert "00:00" in content["notifications"] - assert "Sent by Test User on 1 January at 00:00" in content["status"] + assert "Sent by Test User on 01-01-2016 at 12:00 AM" in content["status"] + assert "12:00" in content["notifications"] @freeze_time("2016-01-01 05:00:00.000001") @@ -466,8 +466,8 @@ def test_should_show_updates_for_scheduled_job_as_json( assert "2021234567" in content["notifications"] assert "Status" in content["notifications"] assert "Delivered" in content["notifications"] - assert "00:00" in content["notifications"] - assert "Sent by Test User on 1 June at 16:00" in content["status"] + assert "Sent by Test User on 06-01-2016 at 04:00 PM" in content["status"] + assert "12:00" in content["notifications"] @pytest.mark.parametrize( From bdf22a1bc98baa47321a10b1de54c8197b90aff3 Mon Sep 17 00:00:00 2001 From: Jonathan Bobel Date: Thu, 29 Feb 2024 12:24:31 -0500 Subject: [PATCH 64/64] 1221 - Delivery status page updates --- app/main/forms.py | 16 ++++++++------ app/main/views/api_keys.py | 22 +++++++++++-------- app/main/views/manage_users.py | 22 ++++++++++--------- app/main/views/performance.py | 6 +++--- app/main/views/send.py | 28 ++++++++++++++----------- app/main/views/service_settings.py | 24 +++++++++++++-------- app/templates/views/message-status.html | 14 ++++++------- 7 files changed, 76 insertions(+), 56 deletions(-) diff --git a/app/main/forms.py b/app/main/forms.py index c01ce8fcc..2e6655cc5 100644 --- a/app/main/forms.py +++ b/app/main/forms.py @@ -1781,12 +1781,16 @@ class TemplateAndFoldersSelectionForm(Form): None, [ # ('email', 'Email') if 'email' in available_template_types else None, - ("sms", "Start with a blank template") - if "sms" in available_template_types - else None, - ("copy-existing", "Copy an existing template") - if allow_adding_copy_of_template - else None, + ( + ("sms", "Start with a blank template") + if "sms" in available_template_types + else None + ), + ( + ("copy-existing", "Copy an existing template") + if allow_adding_copy_of_template + else None + ), ], ) ) diff --git a/app/main/views/api_keys.py b/app/main/views/api_keys.py index 4f8c3b29e..8cb28ba59 100644 --- a/app/main/views/api_keys.py +++ b/app/main/views/api_keys.py @@ -168,12 +168,14 @@ def api_callbacks(service_id): return render_template( "views/api/callbacks.html", - received_text_messages_callback=received_text_messages_callback["url"] - if received_text_messages_callback - else None, - delivery_status_callback=delivery_status_callback["url"] - if delivery_status_callback - else None, + received_text_messages_callback=( + received_text_messages_callback["url"] + if received_text_messages_callback + else None + ), + delivery_status_callback=( + delivery_status_callback["url"] if delivery_status_callback else None + ), ) @@ -262,9 +264,11 @@ def received_text_messages_callback(service_id): received_text_messages_callback = get_received_text_messages_callback() form = CallbackForm( - url=received_text_messages_callback.get("url") - if received_text_messages_callback - else "", + url=( + received_text_messages_callback.get("url") + if received_text_messages_callback + else "" + ), bearer_token=dummy_bearer_token if received_text_messages_callback else "", ) diff --git a/app/main/views/manage_users.py b/app/main/views/manage_users.py index 4ab20f363..1b80c659e 100644 --- a/app/main/views/manage_users.py +++ b/app/main/views/manage_users.py @@ -122,16 +122,18 @@ def edit_user_permissions(service_id, user_id): form = form_class.from_user( user, service_id, - folder_permissions=None - if user.platform_admin - else [ - f["id"] - for f in current_service.all_template_folders - if user.has_template_folder_permission(f) - ], - all_template_folders=None - if user.platform_admin - else current_service.all_template_folders, + folder_permissions=( + None + if user.platform_admin + else [ + f["id"] + for f in current_service.all_template_folders + if user.has_template_folder_permission(f) + ] + ), + all_template_folders=( + None if user.platform_admin else current_service.all_template_folders + ), ) if form.validate_on_submit(): diff --git a/app/main/views/performance.py b/app/main/views/performance.py index 13445967b..1d2a4d1bc 100644 --- a/app/main/views/performance.py +++ b/app/main/views/performance.py @@ -34,8 +34,8 @@ def performance(): stats["average_percentage_under_10_seconds"] = mean( [row["percentage_under_10_seconds"] for row in stats["processing_time"]] or [0] ) - stats[ - "count_of_live_services_and_organizations" - ] = status_api_client.get_count_of_live_services_and_organizations() + stats["count_of_live_services_and_organizations"] = ( + status_api_client.get_count_of_live_services_and_organizations() + ) return render_template("views/performance.html", **stats) diff --git a/app/main/views/send.py b/app/main/views/send.py index 4332c7ddb..6c786e3ac 100644 --- a/app/main/views/send.py +++ b/app/main/views/send.py @@ -52,12 +52,14 @@ def get_example_csv_fields(column_headers, use_example_as_example, submitted_fie def get_example_csv_rows(template, use_example_as_example=True, submitted_fields=False): return { - "email": ["test@example.com"] - if use_example_as_example - else [current_user.email_address], - "sms": ["12223334444"] - if use_example_as_example - else [current_user.mobile_number], + "email": ( + ["test@example.com"] + if use_example_as_example + else [current_user.email_address] + ), + "sms": ( + ["12223334444"] if use_example_as_example else [current_user.mobile_number] + ), }[template.template_type] + get_example_csv_fields( ( placeholder @@ -511,12 +513,14 @@ def _check_messages(service_id, template_id, upload_id, preview_row): template=template, max_initial_rows_shown=50, max_errors_shown=50, - guestlist=itertools.chain.from_iterable( - [user.name, user.mobile_number, user.email_address] - for user in Users(service_id) - ) - if current_service.trial_mode - else None, + guestlist=( + itertools.chain.from_iterable( + [user.name, user.mobile_number, user.email_address] + for user in Users(service_id) + ) + if current_service.trial_mode + else None + ), remaining_messages=remaining_messages, allow_international_sms=current_service.has_permission("international_sms"), ) diff --git a/app/main/views/service_settings.py b/app/main/views/service_settings.py index 1cac1410c..628ac59e5 100644 --- a/app/main/views/service_settings.py +++ b/app/main/views/service_settings.py @@ -477,9 +477,11 @@ def service_edit_email_reply_to(service_id, reply_to_email_id): current_service.id, reply_to_email_id=reply_to_email_id, email_address=form.email_address.data, - is_default=True - if reply_to_email_address["is_default"] - else form.is_default.data, + is_default=( + True + if reply_to_email_address["is_default"] + else form.is_default.data + ), ) return redirect(url_for(".service_email_reply_to", service_id=service_id)) try: @@ -499,9 +501,11 @@ def service_edit_email_reply_to(service_id, reply_to_email_id): ".service_verify_reply_to_address", service_id=service_id, notification_id=notification_id, - is_default=True - if reply_to_email_address["is_default"] - else form.is_default.data, + is_default=( + True + if reply_to_email_address["is_default"] + else form.is_default.data + ), replace=reply_to_email_id, ) ) @@ -702,9 +706,11 @@ def service_edit_sms_sender(service_id, sms_sender_id): service_api_client.update_sms_sender( current_service.id, sms_sender_id=sms_sender_id, - sms_sender=sms_sender["sms_sender"] - if is_inbound_number - else form.sms_sender.data.replace("\r", ""), + sms_sender=( + sms_sender["sms_sender"] + if is_inbound_number + else form.sms_sender.data.replace("\r", "") + ), is_default=True if sms_sender["is_default"] else form.is_default.data, ) return redirect(url_for(".service_sms_senders", service_id=service_id)) diff --git a/app/templates/views/message-status.html b/app/templates/views/message-status.html index 9f30f1170..79ea960fe 100644 --- a/app/templates/views/message-status.html +++ b/app/templates/views/message-status.html @@ -10,8 +10,8 @@

    Delivery status

    Notify’s real-time dashboard lets you check the status of any message.

    -

    For security, this information is only available for seven days after a message has been sent. You can download a report, including a list of sent messages, for your own records.

    -

    This page describes the statuses you’ll see when you’re signed in to Notify.

    +

    For security, this information is only available for seven days after a message has been sent. You can download a report, including a list of sent messages, for your own records.

    +

    This page describes the statuses you'll see when you're signed in to Notify.