Skip to content

[Tech Debt] Update tests to be able to run against live staging/production environments#146

Merged
levinmr merged 3 commits intomasterfrom
feature/add_staging_tests
Feb 4, 2025
Merged

[Tech Debt] Update tests to be able to run against live staging/production environments#146
levinmr merged 3 commits intomasterfrom
feature/add_staging_tests

Conversation

@levinmr
Copy link
Copy Markdown
Contributor

@levinmr levinmr commented Nov 12, 2024

No description provided.

@levinmr levinmr requested a review from sanason November 12, 2024 14:09
@levinmr levinmr force-pushed the feature/add_staging_tests branch 2 times, most recently from b104083 to e12ebbd Compare November 12, 2024 14:43
Copy link
Copy Markdown
Member

@sanason sanason left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m torn between this approach (where the running test site supports all different environments and the user of the test site chooses which one to use on a page-by-page basis at runtime with query params) vs an approach where the test site environment is set at execution-time (via something like npm run test-site-dev vs npm run test-site-staging).

I would guess that one is usually not switching environments during a single testing session (so the flexibility of approach 1 is less useful) and it’s probably simpler to execute a test if you don’t have to deal with setting the environment each time you load a page (so approach 2 would make it easier both to write automated tests and to perform manual tests against the test site).

Comment thread test_site/index.html Outdated
let dapCodeLocation;
dapScriptTag.id = "_fed_an_ua_tag";
dapScriptTag.async = true;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There aren't any automated tests hitting it yet but I guess this would need to be replicated on the youtube.html page too.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can something like Server Side Includes be used to insert this script in the <head> of every page in the test site? I should have thought about that when I first committed this file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the changeset here to use NGINX server side includes to populate the script tag for each page.

@levinmr
Copy link
Copy Markdown
Contributor Author

levinmr commented Nov 13, 2024

I’m torn between this approach (where the running test site supports all different environments and the user of the test site chooses which one to use on a page-by-page basis at runtime with query params) vs an approach where the test site environment is set at execution-time (via something like npm run test-site-dev vs npm run test-site-staging).

I would guess that one is usually not switching environments during a single testing session (so the flexibility of approach 1 is less useful) and it’s probably simpler to execute a test if you don’t have to deal with setting the environment each time you load a page (so approach 2 would make it easier both to write automated tests and to perform manual tests against the test site).

I agree that it would really odd to switch environments in the middle of a testing session, so we probably don't have to account for that case. The only advantage I can think of for keeping the env setting in the test runner is to be able to customize test expectations by environment. But this also seems to only be useful for a small set of tests currently that check for unexpected request hostnames and there are workarounds for it.

@sanason
Copy link
Copy Markdown
Member

sanason commented Nov 15, 2024

I agree that it would really odd to switch environments in the middle of a testing session, so we probably don't have to account for that case. The only advantage I can think of for keeping the env setting in the test runner is to be able to customize test expectations by environment. But this also seems to only be useful for a small set of tests currently that check for unexpected request hostnames and there are workarounds for it.

I agree with your assessment. I think I prefer approach 2 (for ease of executing tests) however I don't feel strongly and I'm happy to approve this approach too.

@levinmr levinmr force-pushed the feature/add_staging_tests branch from e12ebbd to 3f015ba Compare January 30, 2025 21:26
@levinmr levinmr force-pushed the feature/add_staging_tests branch from 3f015ba to 4ce308e Compare January 30, 2025 21:32
@levinmr
Copy link
Copy Markdown
Contributor Author

levinmr commented Jan 30, 2025

I’m torn between this approach (where the running test site supports all different environments and the user of the test site chooses which one to use on a page-by-page basis at runtime with query params) vs an approach where the test site environment is set at execution-time (via something like npm run test-site-dev vs npm run test-site-staging).

I would guess that one is usually not switching environments during a single testing session (so the flexibility of approach 1 is less useful) and it’s probably simpler to execute a test if you don’t have to deal with setting the environment each time you load a page (so approach 2 would make it easier both to write automated tests and to perform manual tests against the test site).

Updated to use the suggestion above. Now in order to run the tests against different environments, you specify the environment when starting up the test-site container. Example:

# Uses the staging environment version of the DAP code
npm run test-site-stg

npm run cucumber

@sanason sanason self-requested a review January 31, 2025 17:27
Copy link
Copy Markdown
Member

@sanason sanason left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome.

@levinmr levinmr merged commit 081531f into master Feb 4, 2025
@levinmr levinmr deleted the feature/add_staging_tests branch February 4, 2025 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants