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

Add tests #116

Merged
merged 27 commits into from
Dec 19, 2023
Merged

Add tests #116

merged 27 commits into from
Dec 19, 2023

Conversation

daun
Copy link
Member

@daun daun commented Dec 15, 2023

Description

  • Create unit tests for our custom queue implementation
  • Create functional tests for the plugin and all options
  • Add workflows to run both in CI

Checks

  • The PR is submitted to the master branch
  • The code was linted before pushing (npm run lint)
  • All tests are passing (npm run test)
  • New or updated tests are included
  • The documentation was updated as required

Required changes

  • Update to and require swup 4.5 to get touchstart to work properly 🤔
  • Use new argument order for hook calls
  • Wrap preload function in page:preload hook

Copy link

github-actions bot commented Dec 15, 2023

Playwright test results

passed  68 passed
skipped  4 skipped

Details

stats  72 tests across 7 suites
duration  1 minute, 11 seconds
commit  4c3e0b5

Skipped tests

chromium → preload-plugin.spec.ts → active links → preloads links on touchstart
firefox → preload-plugin.spec.ts → active links → preloads links on touchstart
webkit → preload-plugin.spec.ts → active links → preloads links on touchstart
ios → preload-plugin.spec.ts → active links → preloads links on hover

@daun daun requested a review from a team December 18, 2023 12:27
@hirasso
Copy link
Member

hirasso commented Dec 18, 2023

Besutiful! Is the changed argument order a breaking change?

@daun
Copy link
Member Author

daun commented Dec 18, 2023

@hirasso No, swup currently accepts both old and new hook argument order. This change just updates to the current canonical order.

@daun
Copy link
Member Author

daun commented Dec 18, 2023

@hirasso Ah, I misread your question. The updated arguments are for the call to swup.hooks.call(). The arguments of the page:preload hook itself haven't changed.

@hirasso
Copy link
Member

hirasso commented Dec 18, 2023

Ah ok 👌

{
"public": "tests/fixtures",
"cleanUrls": false,
"redirects": [
Copy link
Member

Choose a reason for hiding this comment

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

do we need the redirects directive here?

Copy link
Member Author

Choose a reason for hiding this comment

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

We currently don't test the expected behavior for redirected requests, but I think we should. For example, 302 redirects probably shouldn't preload, but we don't know the exact status code, so we should discard all redirected responses anyway.

'tests/unit/**/*.test.ts'
],
setupFiles: [
'tests/config/vitest.setup.ts'
Copy link
Member

Choose a reason for hiding this comment

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

Leaving this here so we can quickly use it should we need it sometime later?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think so — let's merge this for now, and then do a more thorough review when comparing all plugins with e2e tests.

@@ -0,0 +1,13 @@
import { vi } from 'vitest';
Copy link
Member

Choose a reason for hiding this comment

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

Unused right now – leaving it here for future usage?

@hirasso
Copy link
Member

hirasso commented Dec 19, 2023

I guess all my comments about unused stuff also apply to fragment plugin :) ...no big deal, we can totally leave it in.

@daun daun merged commit 819d922 into master Dec 19, 2023
2 checks passed
@daun daun deleted the functional-tests branch December 19, 2023 08:55
@daun daun restored the functional-tests branch January 26, 2024 14:14
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