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

fix: no-sw error shows for subdomain requests #491

Merged

Conversation

SgtPooki
Copy link
Member

Title

fix: no-sw error shows for subdomain requests

Description

Fixes #272 again

Adds tests to prevent regression

Notes & open questions

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if necessary (this includes comments as well)
  • I have added tests that prove my fix is effective or that my feature works

@SgtPooki SgtPooki linked an issue Nov 22, 2024 that may be closed by this pull request
Copy link
Member Author

@SgtPooki SgtPooki left a comment

Choose a reason for hiding this comment

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

self review. FYI i'm attempting to update these changes so we don't need an entirely different project.. we should be able to set launchOptions and other things in the testNoServiceWorker test fixture but I was running into issues and wanted to get something working first.

name: 'no-service-worker',
testMatch: /test-e2e\/no-service-worker\.test\.ts/,
use: {
...devices['Desktop Firefox'],
Copy link
Member Author

Choose a reason for hiding this comment

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

Note that this doesn't test no service worker functionality in chrome, but we shouldn't need to...?

Comment on lines 24 to 26
{ default: true, component: ErrorPage ?? LazyHelperUi },
{ shouldRender: async () => renderChecks.shouldRenderNoServiceWorkerError(), component: LazyServiceWorkerErrorPage },
{ shouldRender: async () => renderChecks.shouldRenderRedirectsInterstitial(), component: LazyInterstitial },
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the actual bug fix..

})

/**
* You should use this fixture instead of the `test` fixture from `@playwright/test` when testing path routing via the service worker.
*/
export const testPathRouting = base.extend<{ rootDomain: string, baseURL: string, protocol: string }>({
export const testPathRouting = test.extend<{ rootDomain: string, baseURL: string, protocol: string }>({
Copy link
Member Author

Choose a reason for hiding this comment

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

idk why this wasn't being done before, but all of our custom test fixtures now extend from our test fixture above, so we get the isNoServiceWorkerProject check for free without modifying all the others.

*
* @see https://github.com/ipfs/service-worker-gateway/issues/272
*/
export const testNoServiceWorker = base.extend<{ rootDomain: string, baseURL: string, protocol: string }>({
Copy link
Member Author

Choose a reason for hiding this comment

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

not extending our test fixture above because that is trying to skip everything that skips tests on the isNoServiceWorkerProject(test) check. we need the opposite here.

@SgtPooki
Copy link
Member Author

FYI: I can't seem to get the launch options and firefoxUserPrefs to trigger from a test fixture.. i'm guessing because firefox is already launched at the project level.. so I will leave as is for now

@SgtPooki SgtPooki merged commit c16688e into main Nov 22, 2024
16 checks passed
@SgtPooki SgtPooki deleted the 272-user-friendly-error-when-navigatorserviceworker-is-undefined branch November 22, 2024 19:20
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.

User-friendly error when navigator.serviceWorker is undefined
1 participant