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

try to stabilize flimsy tests #266

Merged
merged 3 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20.x"
node-version: "20.11.0"
cache: "yarn"
- run: yarn install --immutable
- run: yarn workspaces foreach --all --include "@apollo/*" add -D -P @apollo/client@${{ matrix.version }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@ import { test, mock } from "node:test";
import assert from "node:assert";
import { fromPartial } from "@total-typescript/shoehorn";
import type { SubscriptionObserver } from "zen-observable-ts";
import { runInConditions } from "./util/runInConditions.js";

runInConditions("node", "browser");

const { DebounceMultipartResponsesLink: AccumulateMultipartResponsesLink } =
await import("#bundled");

test("normal queries can resolve synchronously", () => {
await test("normal queries can resolve synchronously", () => {
const query = gql`
query {
fastField
Expand Down Expand Up @@ -49,7 +46,7 @@ test("normal queries can resolve synchronously", () => {
});
});

test("deferred query will complete synchonously if maxDelay is 0", () => {
await test("deferred query will complete synchonously if maxDelay is 0", () => {
const query = gql`
query {
fastField
Expand Down Expand Up @@ -84,7 +81,7 @@ test("deferred query will complete synchonously if maxDelay is 0", () => {
});
});

test("`next` call will be debounced and results will be merged together", () => {
await test("`next` call will be debounced and results will be merged together", () => {
mock.timers.enable();

const query = gql`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ import { gql, Observable } from "@apollo/client/core/index.js";
import { print } from "graphql";
import { it } from "node:test";
import assert from "node:assert";
import { runInConditions } from "./util/runInConditions.js";

runInConditions("node", "browser");

const { RemoveMultipartDirectivesLink } = await import("#bundled");

Expand Down Expand Up @@ -51,7 +48,7 @@ const queryWithDeferAndStripAnnotation = gql`
}
`;

it("removes fields with a @defer directive", () => {
await it("removes fields with a @defer directive", () => {
const link = new RemoveMultipartDirectivesLink({
stripDefer: true,
});
Expand All @@ -69,7 +66,7 @@ query myQuery {
);
});

it("`stripDefer` defaults to `true`", () => {
await it("`stripDefer` defaults to `true`", () => {
const link = new RemoveMultipartDirectivesLink({
stripDefer: true,
});
Expand All @@ -87,7 +84,7 @@ query myQuery {
);
});

it("preserves @defer fields with a `SsrDontStrip` label", () => {
await it("preserves @defer fields with a `SsrDontStrip` label", () => {
const link = new RemoveMultipartDirectivesLink({
stripDefer: true,
});
Expand All @@ -114,7 +111,7 @@ query myQuery {
);
});

it("can be configured to not remove @defer fields", () => {
await it("can be configured to not remove @defer fields", () => {
const link = new RemoveMultipartDirectivesLink({
stripDefer: false,
});
Expand All @@ -138,7 +135,7 @@ query myQuery {
);
});

it("even with `stripDefer: false`, certain fields can be marked for stripping", () => {
await it("even with `stripDefer: false`, certain fields can be marked for stripping", () => {
const link = new RemoveMultipartDirectivesLink({
stripDefer: false,
});
Expand Down
Loading