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

Rewrite tests that use subscribeAndCount with ObservableStream #12163

Merged
merged 57 commits into from
Dec 5, 2024

Conversation

jerelmiller
Copy link
Member

This PR updates all tests that use the subscribeAndCount test utility in favor of the much more useable ObservableStream helper. Tests are much more serial as a result and easier to follow since its easy to understand which order the assertions run relative to the checked behavior.

As a part of this PR, I've added several new matchers that allow us to check the emitted value directly, rather than using the block { } trick to reuse the same variable name.

Since we plan to migrate to RxJS in 4.0, this change should make it much easier to determine what breaks and what doesn't.

NOTE: I'm opening in draft as this will be one of the first PRs that I'd like to merge in to main after 3.12 is released. We should deprecate and remove this function for 4.0 so that we no longer have to maintain it.

Copy link

changeset-bot bot commented Nov 27, 2024

⚠️ No Changeset found

Latest commit: 349dda8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@svc-apollo-docs
Copy link

svc-apollo-docs commented Nov 27, 2024

✅ Docs Preview Ready

No new or changed pages found.

Copy link

pkg-pr-new bot commented Nov 27, 2024

npm i https://pkg.pr.new/@apollo/client@12163

commit: 349dda8

Copy link
Contributor

github-actions bot commented Nov 27, 2024

size-limit report 📦

Path Size
dist/apollo-client.min.cjs 40.64 KB (0%)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/main.cjs" 50.02 KB (0%)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/main.cjs" (production) 47.14 KB (0%)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/index.js" 36.13 KB (0%)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/index.js" (production) 33.54 KB (0%)
import { ApolloProvider } from "dist/react/index.js" 1.26 KB (0%)
import { ApolloProvider } from "dist/react/index.js" (production) 1.24 KB (0%)
import { useQuery } from "dist/react/index.js" 5.21 KB (0%)
import { useQuery } from "dist/react/index.js" (production) 4.29 KB (0%)
import { useLazyQuery } from "dist/react/index.js" 5.7 KB (0%)
import { useLazyQuery } from "dist/react/index.js" (production) 4.78 KB (0%)
import { useMutation } from "dist/react/index.js" 3.62 KB (0%)
import { useMutation } from "dist/react/index.js" (production) 2.84 KB (0%)
import { useSubscription } from "dist/react/index.js" 4.42 KB (0%)
import { useSubscription } from "dist/react/index.js" (production) 3.48 KB (0%)
import { useSuspenseQuery } from "dist/react/index.js" 5.51 KB (0%)
import { useSuspenseQuery } from "dist/react/index.js" (production) 4.17 KB (0%)
import { useBackgroundQuery } from "dist/react/index.js" 5.01 KB (0%)
import { useBackgroundQuery } from "dist/react/index.js" (production) 3.66 KB (0%)
import { useLoadableQuery } from "dist/react/index.js" 5.09 KB (0%)
import { useLoadableQuery } from "dist/react/index.js" (production) 3.73 KB (0%)
import { useReadQuery } from "dist/react/index.js" 3.41 KB (0%)
import { useReadQuery } from "dist/react/index.js" (production) 3.35 KB (0%)
import { useFragment } from "dist/react/index.js" 2.36 KB (0%)
import { useFragment } from "dist/react/index.js" (production) 2.31 KB (0%)

@jerelmiller jerelmiller force-pushed the jerel/rewrite-to-observable-stream branch from 5d319bd to a0c0ba5 Compare December 4, 2024 21:21
@jerelmiller jerelmiller force-pushed the jerel/rewrite-to-observable-stream branch from a0c0ba5 to 83a35d8 Compare December 4, 2024 21:22
@jerelmiller jerelmiller changed the base branch from release-3.12 to main December 4, 2024 21:22
@jerelmiller jerelmiller requested a review from phryneas December 4, 2024 21:22
@jerelmiller jerelmiller marked this pull request as ready for review December 4, 2024 21:22
Copy link

netlify bot commented Dec 4, 2024

Deploy Preview for apollo-client-docs ready!

Name Link
🔨 Latest commit a0c0ba5
🔍 Latest deploy log https://app.netlify.com/sites/apollo-client-docs/deploys/6750c7ee3bb0250008271ada
😎 Deploy Preview https://deploy-preview-12163--apollo-client-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Dec 4, 2024

Deploy Preview for apollo-client-docs ready!

Name Link
🔨 Latest commit 349dda8
🔍 Latest deploy log https://app.netlify.com/sites/apollo-client-docs/deploys/6751cfe2baa86c00087a47d9
😎 Deploy Preview https://deploy-preview-12163--apollo-client-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Member

@phryneas phryneas left a comment

Choose a reason for hiding this comment

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

This looks good to me!

While I was reviewing this, I did refactor a few more tests and did some tweaks here and there, so please give 67a6a42 a quick review before merging this :)

Comment on lines +191 to +193
for (const result of results) {
await expect(observableStream).toEmitValue(result);
}
Copy link
Member

Choose a reason for hiding this comment

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

Love it!

@github-actions github-actions bot added the auto-cleanup 🤖 label Dec 5, 2024
@jerelmiller jerelmiller merged commit 17b449f into main Dec 5, 2024
46 checks passed
@jerelmiller jerelmiller deleted the jerel/rewrite-to-observable-stream branch December 5, 2024 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants