Skip to content

Commit 29da30a

Browse files
authored
Migrate the E2E tests to the new URLs and use TB Accounts for sign-in (#1314)
* Migrate the E2E tests to the new URLs and use TB Accounts for sign-in * Remove unused const and import
1 parent 1487512 commit 29da30a

29 files changed

+285
-293
lines changed

.github/workflows/deploy-production.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ jobs:
128128
runs-on: ubuntu-latest
129129
environment: production
130130
env:
131-
APPT_LOGIN_EMAIL: ${{ secrets.E2E_APPT_PROD_LOGIN_EMAIL }}
132-
APPT_LOGIN_PWORD: ${{ secrets.E2E_APPT_PROD_LOGIN_PASSWORD }}
131+
TB_ACCTS_EMAIL: ${{ secrets.E2E_APPT_PROD_TB_ACCTS_EMAIL }}
132+
TB_ACCTS_PWORD: ${{ secrets.E2E_APPT_PROD_TB_ACCTS_PWORD }}
133133
APPT_DISPLAY_NAME: ${{ secrets.E2E_APPT_PROD_DISPLAY_NAME }}
134134
APPT_MY_SHARE_LINK: ${{ secrets.E2E_APPT_PROD_MY_SHARE_LINK }}
135135
APPT_BOOKEE_EMAIL: ${{ secrets.E2E_APPT_PROD_BOOKEE_EMAIL }}

.github/workflows/deploy-staging.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,8 @@ jobs:
235235
runs-on: ubuntu-latest
236236
environment: staging
237237
env:
238-
APPT_LOGIN_EMAIL: ${{ secrets.E2E_APPT_STAGE_LOGIN_EMAIL }}
239-
APPT_LOGIN_PWORD: ${{ secrets.E2E_APPT_STAGE_LOGIN_PASSWORD }}
238+
TB_ACCTS_EMAIL: ${{ secrets.E2E_APPT_STAGE_TB_ACCTS_EMAIL }}
239+
TB_ACCTS_PWORD: ${{ secrets.E2E_APPT_STAGE_TB_ACCTS_PWORD }}
240240
APPT_DISPLAY_NAME: ${{ secrets.E2E_APPT_STAGE_DISPLAY_NAME }}
241241
APPT_MY_SHARE_LINK: ${{ secrets.E2E_APPT_STAGE_MY_SHARE_LINK }}
242242
APPT_BOOKEE_EMAIL: ${{ secrets.E2E_APPT_STAGE_BOOKEE_EMAIL }}

.github/workflows/nightly-tests-desktop.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ jobs:
2020
runs-on: ubuntu-latest
2121
environment: production
2222
env:
23-
APPT_LOGIN_EMAIL: ${{ secrets.E2E_APPT_PROD_LOGIN_EMAIL }}
24-
APPT_LOGIN_PWORD: ${{ secrets.E2E_APPT_PROD_LOGIN_PASSWORD }}
23+
TB_ACCTS_EMAIL: ${{ secrets.E2E_APPT_PROD_TB_ACCTS_EMAIL }}
24+
TB_ACCTS_PWORD: ${{ secrets.E2E_APPT_PROD_TB_ACCTS_PWORD }}
2525
APPT_DISPLAY_NAME: ${{ secrets.E2E_APPT_PROD_DISPLAY_NAME }}
2626
APPT_MY_SHARE_LINK: ${{ secrets.E2E_APPT_PROD_MY_SHARE_LINK }}
2727
APPT_BOOKEE_EMAIL: ${{ secrets.E2E_APPT_PROD_BOOKEE_EMAIL }}

.github/workflows/nightly-tests-mobile.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ jobs:
2020
runs-on: ubuntu-latest
2121
environment: production
2222
env:
23-
APPT_LOGIN_EMAIL: ${{ secrets.E2E_APPT_PROD_LOGIN_EMAIL }}
24-
APPT_LOGIN_PWORD: ${{ secrets.E2E_APPT_PROD_LOGIN_PASSWORD }}
23+
TB_ACCTS_EMAIL: ${{ secrets.E2E_APPT_PROD_TB_ACCTS_EMAIL }}
24+
TB_ACCTS_PWORD: ${{ secrets.E2E_APPT_PROD_TB_ACCTS_PWORD }}
2525
APPT_DISPLAY_NAME: ${{ secrets.E2E_APPT_PROD_DISPLAY_NAME }}
2626
APPT_MY_SHARE_LINK: ${{ secrets.E2E_APPT_PROD_MY_SHARE_LINK }}
2727
APPT_BOOKEE_EMAIL: ${{ secrets.E2E_APPT_PROD_BOOKEE_EMAIL }}

backend/src/appointment/database/repo/external_connection.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,8 @@ def get_subscriber_without_oidc_by_email(db: Session, email: str):
145145
.filter(models.ExternalConnections.type == models.ExternalConnectionType.oidc)
146146
.exists()
147147
)
148-
148+
149149
# Find subscribers without an OIDC connection that match the email
150-
query = (
151-
db.query(models.Subscriber)
152-
.filter(~oidc_exists)
153-
.filter(models.Subscriber.email == email)
154-
)
150+
query = db.query(models.Subscriber).filter(~oidc_exists).filter(models.Subscriber.email == email)
155151

156152
return query.first()

backend/test/integration/test_auth.py

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -854,10 +854,7 @@ def test_oidc_token_not_enabled(self, with_client):
854854
"""Test that endpoint returns 405 when AUTH_SCHEME is not OIDC"""
855855
os.environ['AUTH_SCHEME'] = 'password'
856856

857-
response = with_client.post(
858-
'/oidc/token',
859-
json={'access_token': 'test_token', 'timezone': 'America/Vancouver'}
860-
)
857+
response = with_client.post('/oidc/token', json={'access_token': 'test_token', 'timezone': 'America/Vancouver'})
861858

862859
assert response.status_code == 405, response.text
863860

@@ -870,8 +867,7 @@ def test_oidc_token_invalid_token(self, with_client):
870867
mock_introspect.return_value = None
871868

872869
response = with_client.post(
873-
'/oidc/token',
874-
json={'access_token': 'invalid_token', 'timezone': 'America/Vancouver'}
870+
'/oidc/token', json={'access_token': 'invalid_token', 'timezone': 'America/Vancouver'}
875871
)
876872

877873
assert response.status_code == 403, response.text
@@ -887,10 +883,7 @@ def test_oidc_token_existing_subscriber(self, with_client, make_pro_subscriber,
887883

888884
# Create existing OIDC external connection
889885
make_external_connections(
890-
subscriber_id=subscriber.id,
891-
type=models.ExternalConnectionType.oidc,
892-
type_id=oidc_id,
893-
name=subscriber.email
886+
subscriber_id=subscriber.id, type=models.ExternalConnectionType.oidc, type_id=oidc_id, name=subscriber.email
894887
)
895888

896889
# Mock OIDCClient to return valid token data
@@ -903,8 +896,7 @@ def test_oidc_token_existing_subscriber(self, with_client, make_pro_subscriber,
903896
}
904897

905898
response = with_client.post(
906-
'/oidc/token',
907-
json={'access_token': 'valid_token', 'timezone': 'America/Vancouver'}
899+
'/oidc/token', json={'access_token': 'valid_token', 'timezone': 'America/Vancouver'}
908900
)
909901

910902
assert response.status_code == 200, response.text
@@ -923,13 +915,12 @@ def test_oidc_token_fallback_match_by_email(self, with_db, with_client, make_pro
923915
mock_introspect.return_value = {
924916
'sub': oidc_id,
925917
'email': subscriber.email,
926-
'preferred_username': subscriber.email, # preferred_username is the thundermail address
918+
'preferred_username': subscriber.email, # preferred_username is the thundermail address
927919
'name': subscriber.name,
928920
}
929921

930922
response = with_client.post(
931-
'/oidc/token',
932-
json={'access_token': 'valid_token', 'timezone': 'America/Vancouver'}
923+
'/oidc/token', json={'access_token': 'valid_token', 'timezone': 'America/Vancouver'}
933924
)
934925

935926
assert response.status_code == 200, response.text

test/e2e/.env.dev.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ APPT_TARGET_ENV=dev
55
APPT_URL=http://localhost:8080/
66

77
# Local sign-in credentials
8-
APPT_LOGIN_EMAIL=
9-
APPT_LOGIN_PWORD=
8+
TB_ACCTS_EMAIL=
9+
TB_ACCTS_PWORD=
1010

1111
# Local Appointment user display name (settings => account => display name) for above user
1212
APPT_DISPLAY_NAME=

test/e2e/.env.prod.example

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
APPT_TARGET_ENV=prod
33

44
# URLs
5-
APPT_URL=https://appointment.day/
6-
APPT_SHORT_SHARE_LINK_PREFIX=https://apmt.day/
7-
APPT_LONG_SHARE_LINK_PREFIX=https://appointment.day/user/
5+
APPT_URL=https://appointment.tb.pro/
6+
APPT_SHORT_SHARE_LINK_PREFIX=https://apt.mt/
7+
APPT_LONG_SHARE_LINK_PREFIX=https://appointment.tb.pro/user/
88

9-
# Sign-in (FxA) credentials
10-
APPT_LOGIN_EMAIL=
11-
APPT_LOGIN_PWORD=
9+
# Sign-in credentials
10+
TB_ACCTS_EMAIL=
11+
TB_ACCTS_PWORD=
1212

1313
# Appointment user display name (settings => account => display name) for above user
1414
APPT_DISPLAY_NAME=
@@ -18,5 +18,5 @@ APPT_MY_SHARE_LINK=
1818

1919
# Booking requester's name and email address (used when a booking slot is requested via the
2020
# share link). Important: real appointment booking emails will be sent to the provided email.
21-
APPT_BOOKEE_NAME='Automated-Test-Bot-Prod'
21+
APPT_BOOKEE_NAME=
2222
APPT_BOOKEE_EMAIL=

test/e2e/.env.stage.example

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
APPT_TARGET_ENV=stage
33

44
# URLs
5-
APPT_URL=https://stage.appointment.day/
6-
APPT_SHORT_SHARE_LINK_PREFIX=https://stage.apmt.day/
7-
APPT_LONG_SHARE_LINK_PREFIX=https://stage.appointment.day/user/
5+
APPT_URL=https://appointment-stage.tb.pro/
6+
APPT_SHORT_SHARE_LINK_PREFIX=https://stage.apt.mt/
7+
APPT_LONG_SHARE_LINK_PREFIX=https://appointment-stage.tb.pro/user/
88

9-
# Sign-in (FxA) credentials
10-
APPT_LOGIN_EMAIL=
11-
APPT_LOGIN_PWORD=
9+
# Sign-in credentials
10+
TB_ACCTS_EMAIL=
11+
TB_ACCTS_PWORD=
1212

1313
# Appointment user display name (settings => account => display name) for above user
1414
APPT_DISPLAY_NAME=
@@ -18,5 +18,5 @@ APPT_MY_SHARE_LINK=
1818

1919
# Booking requester's name and email address (used when a booking slot is requested via the
2020
# share link). Important: real appointment booking emails will be sent to the provided email.
21-
APPT_BOOKEE_NAME='Automated-Test-Bot-Stage'
21+
APPT_BOOKEE_NAME=
2222
APPT_BOOKEE_EMAIL=

test/e2e/README.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ npx playwright install
1818
```
1919

2020
## E2E Test Prerequisites
21-
The E2E tests require an existing Appointment (and corresponding FxA account) and associated data, and reads this from your local .env file. This includes:
22-
- Credentials for an existing Appointment (FxA) account (email address, password)
21+
22+
The E2E tests require an existing TB Pro account and other settings that are read this from your local .env file. This includes:
23+
- Credentials for an existing TB Pro account (TB Pro email and associated password)
2324
- The account user's display name and share link:
2425
- The display name is found in Appointment => Settings => Account => Display name.
2526
- The share link is found in Appointment => Settings => Account => My Link.
@@ -28,7 +29,7 @@ The E2E tests require an existing Appointment (and corresponding FxA account) an
2829
The tests expect the following Appointment application settings:
2930
- The user scheduling availability hasn't been changed from the default settings;
3031
- In the dashboard the default calendar view is the current month view; this is important so that the tests can find an available booking slot, etc.
31-
- In `Booking Settings`, the `Booking Confirmation` option is enabled, so that requested appointments generate HOLD appointments that need to be confirmed
32+
- In `Booking Settings`, the `Automatically confirm bookings if time is available` option is checked / turned on
3233

3334
## Running the E2E tests against your local dev environment
3435

@@ -43,8 +44,8 @@ cp .env.dev.example .env
4344

4445
Then edit your local `.env` file and provide the following values:
4546
```dotenv
46-
APPT_LOGIN_EMAIL=<existing-dev-FxA-user-email>
47-
APPT_LOGIN_PWORD=<exisiting-dev-FxA-user-password>
47+
TB_ACCTS_EMAIL=<existing-local-account-user-email>
48+
TB_ACCTS_PWORD=<exisiting-local-user-password>
4849
APPT_DISPLAY_NAME=<appointment-dev-user-display-name>
4950
APPT_MY_SHARE_LINK=<apointment-dev-user-share-link>
5051
APPT_BOOKEE_EMAIL=<booking-requesters-email>
@@ -99,8 +100,8 @@ cp .env.stage.example .env
99100

100101
Then edit your local `.env` file and provide the following values:
101102
```dotenv
102-
APPT_LOGIN_EMAIL=<existing-stage-FxA-user-email>
103-
APPT_LOGIN_PWORD=<exisiting-stage-FxA-user-password>
103+
TB_ACCTS_EMAIL=<existing-stage-tb-accounts-user-email>
104+
TB_ACCTS_PWORD=<exisiting-stage-tb-accounts-user-password>
104105
APPT_DISPLAY_NAME=<appointment-stage-user-display-name>
105106
APPT_MY_SHARE_LINK=<apointment-stage-user-share-link>
106107
APPT_BOOKEE_EMAIL=<booking-requesters-email>
@@ -129,8 +130,8 @@ cp .env.prod.example .env
129130

130131
Then edit your local `.env` file and provide the following values:
131132
```dotenv
132-
APPT_LOGIN_EMAIL=<existing-prod-FxA-user-email>
133-
APPT_LOGIN_PWORD=<exisiting-prod-FxA-user-password>
133+
TB_ACCTS_EMAIL=<existing-prod-tb-accounts-user-email>
134+
TB_ACCTS_PWORD=<exisiting-prod-tb-accounts-user-password>
134135
APPT_DISPLAY_NAME=<appointment-prod-user-display-name>
135136
APPT_MY_SHARE_LINK=<apointment-prod-user-share-link>
136137
APPT_BOOKEE_EMAIL=<booking-requesters-email>
@@ -152,13 +153,13 @@ npm run prod-sanity-test-headed
152153

153154
You can run the E2E tests from your local machine but against browsers provided in the BrowserStack Automate cloud.
154155

155-
<b>For security reasons when running the tests on BrowserStack I recommend that you use a dedicated test Appointment FxA account / credentials (NOT your own personal Appointment (FxA) credentials).</b>
156+
<b>For security reasons when running the tests on BrowserStack I recommend that you use a dedicated test Appointment account / credentials (NOT your own personal Appointment credentials).</b>
156157

157-
Once you have credentials for an existing Appointemnt test account, edit your local `.env` file and add these details (more information found above):
158+
Once you have credentials for an existing TB Pro test account, edit your local `.env` file and add these details (more information found above):
158159

159160
```dotenv
160-
APPT_LOGIN_EMAIL=<existing-test-FxA-user-email>
161-
APPT_LOGIN_PWORD=<exisiting-test-FxA-user-password>
161+
TB_ACCTS_EMAIL=<existing-tb-accounts-user-email>
162+
TB_ACCTS_PWORD=<exisiting-tb-accounts-user-password>
162163
APPT_DISPLAY_NAME=<appointment-user-display-name>
163164
APPT_MY_SHARE_LINK=<apointment-user-share-link>
164165
APPT_BOOKEE_EMAIL=<booking-requesters-email>

0 commit comments

Comments
 (0)