Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve(wrangler): fix subdomain tests #7210

Merged
merged 1 commit into from
Nov 13, 2024

Conversation

taylorlee
Copy link
Contributor

@taylorlee taylorlee commented Nov 9, 2024

Many tests had mocks that weren't called, or had false assertions about not updating subdomain routes when they actually were being updated.

Additionally, available_on_subdomain is now unecessary during script-upload, as it is not read there, due to being handled entirely within triggers-deploy. This also saves a double call to get /subdomain in the new-api path.

The get/update subdomain helpers are refactored from deploy/version tests, and unified to standardize default workername and legacyEnv.

I wanted to remove the getSubdomain mock from mockUpload entirely, but there were a bit too many callsites... At least every test now that makes assertions about workers.dev deployments does explicitly reset the mock return value.

Fixes N/A

  • Tests
    • Tests included
  • E2E Tests CI Job required? (Use "e2e" label or ask maintainer to run separately)
    • Not required because: this pr fixes unit-tests & mocks
  • Public documentation
    • Documentation not necessary because: no functional changes

Many tests had mocks that weren't called,
or had false assertions about not updating subdomain routes when they
actually were being updated.

Additionally, available_on_subdomain is now unecessary during
script-upload, as it is not read there, due to being handled entirely
within triggers-deploy. This also saves a double call to get /subdomain
in the new-api path.

The get/update subdomain helpers are refactored from deploy/version
tests, and unified to standardize default workername and legacyEnv.

I wanted to remove the getSubdomain mock from mockUpload entirely, but
there were a bit too many callsites... At least every test now that
makes assertions about workers.dev deployments does explicitly reset the
mock return value.
@taylorlee taylorlee requested a review from a team as a code owner November 9, 2024 20:22
Copy link

changeset-bot bot commented Nov 9, 2024

🦋 Changeset detected

Latest commit: 9ae9c6c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
wrangler Patch
@cloudflare/vitest-pool-workers Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Nov 9, 2024

A wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11759185956/npm-package-wrangler-7210

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/7210/npm-package-wrangler-7210

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11759185956/npm-package-wrangler-7210 dev path/to/script.js
Additional artifacts:
npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11759185956/npm-package-create-cloudflare-7210 --no-auto-update
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11759185956/npm-package-cloudflare-kv-asset-handler-7210
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11759185956/npm-package-miniflare-7210
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11759185956/npm-package-cloudflare-pages-shared-7210
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11759185956/npm-package-cloudflare-vitest-pool-workers-7210
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11759185956/npm-package-cloudflare-workers-editor-shared-7210
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11759185956/npm-package-cloudflare-workers-shared-7210
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11759185956/npm-package-cloudflare-workflows-shared-7210

Note that these links will no longer work once the GitHub Actions artifact expires.


wrangler@3.86.0 includes the following runtime dependencies:

Package Constraint Resolved
miniflare workspace:* 3.20241106.0
workerd 1.20241106.1 1.20241106.1
workerd --version 1.20241106.1 2024-11-06

Please ensure constraints are pinned, and miniflare/workerd minor versions match.

}
)
);
// TODO make explicit by callers?
Copy link
Contributor

Choose a reason for hiding this comment

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

TODO in this PR? Otherwise should we track this somewhere?

Copy link
Member

Choose a reason for hiding this comment

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

Future thing, I'm not sure where is best to track

@@ -885,7 +877,6 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
headers: await getMetricsUsageHeaders(config.send_metrics),
},
new URLSearchParams({
include_subdomain_availability: "true",
Copy link
Contributor

Choose a reason for hiding this comment

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

should we remove

available_on_subdomain: boolean;
as well?

Copy link
Member

Choose a reason for hiding this comment

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

I'll not remove for now just to keep the scope a bit smaller but yeah, it isn't needed here either

@@ -870,7 +863,6 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
} else {
result = await retryOnError(async () =>
fetchResult<{
available_on_subdomain: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

sanity check...is this the only place available_on_subdomain needs to be removed from the fetch result shape? Seeing it in other places too, such as versions upload, and triggers...tho my understanding is that triggers has it right and it should be kept there

Copy link
Member

Choose a reason for hiding this comment

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

Yeah for scoping I think good to only remove in this path right now. Deploy is what was using it when it wasn't needed and what was cleaned up. Will make a note to cleanup the rest though

Copy link
Contributor

@CarmenPopoviciu CarmenPopoviciu left a comment

Choose a reason for hiding this comment

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

LGTM, pending the few questions above

@WalshyDev WalshyDev merged commit c12c0fe into main Nov 13, 2024
20 of 23 checks passed
@WalshyDev WalshyDev deleted the tlee/preview-url-separate-subdomain-toggle branch November 13, 2024 16:45
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.

3 participants