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

chore(workspace): Bump react-related libraries #3681

Merged
merged 3 commits into from
Sep 23, 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
7 changes: 0 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,11 @@
"react-native"
],
"allowedVersions": {
"react": "17",
"react-dom": "17",
"react-is": "17",
"styled-components": "5"
}
},
"overrides": {
"@types/react": "^17.0.39",
"graphql": "^16.6.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-is": "^17.0.2",
"styled-components": "^5.2.3",
"wonka": "^6.3.2"
}
Expand Down
4 changes: 2 additions & 2 deletions packages/next-urql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
"devDependencies": {
"@urql/core": "workspace:*",
"urql": "workspace:*",
"@types/react": "^18.2.6",
"@types/react-dom": "^18.2.4",
"@types/react": "^18.3.8",
"@types/react-dom": "^18.3.0",
"graphql": "^16.0.0",
"next": "^13.0.0",
"react": "^18.0.0",
Expand Down
4 changes: 3 additions & 1 deletion packages/next-urql/src/DataHydrationContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ export const DataHydrationContextProvider = ({

export function useDataHydrationContext(): DataHydrationValue | undefined {
const dataHydrationContext = React.useContext(DataHydrationContext);
const insertHtml = React.useContext(ServerInsertedHTMLContext);
const insertHtml = React.useContext(ServerInsertedHTMLContext as any) as (
cb: () => any
) => any;

if (typeof window !== 'undefined') return;

Expand Down
17 changes: 8 additions & 9 deletions packages/react-urql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,18 @@
},
"devDependencies": {
"@cypress/react": "^8.0.2",
"@cypress/vite-dev-server": "^5.0.4",
"@testing-library/react": "^11.1.1",
"@testing-library/react-hooks": "^5.1.2",
"@types/react": "^17.0.4",
"@cypress/vite-dev-server": "^5.2.0",
"@testing-library/react": "^16.0.1",
"@types/react": "^18.3.8",
"@types/react-test-renderer": "^17.0.1",
"@urql/core": "workspace:*",
"cypress": "^13.14.0",
"graphql": "^16.6.0",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-is": "^17.0.1",
"react-ssr-prepass": "^1.1.2",
"react-test-renderer": "^17.0.1"
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-is": "^18.3.1",
"react-ssr-prepass": "^1.5.0",
"react-test-renderer": "^18.3.1"
},
"peerDependencies": {
"@urql/core": "^5.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-urql/src/components/Query.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ vi.mock('../context', async () => {
const mock = {
executeQuery: vi.fn(() =>
pipe(
interval(200),
interval(150),
map((i: number) => ({ data: i, error: i + 1 }))
)
),
Expand Down
2 changes: 2 additions & 0 deletions packages/react-urql/src/hooks/useMutation.test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @vitest-environment jsdom

import { vi, expect, it, beforeEach, describe, Mock } from 'vitest';

// Note: Testing for hooks is not yet supported in Enzyme - https://github.com/airbnb/enzyme/issues/2011
Expand Down
64 changes: 29 additions & 35 deletions packages/react-urql/src/hooks/useQuery.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { renderHook, act } from '@testing-library/react-hooks';
// @vitest-environment jsdom

import { renderHook, act } from '@testing-library/react';
import { interval, map, pipe } from 'wonka';
import { RequestPolicy } from '@urql/core';
import { vi, expect, it, beforeEach, describe, beforeAll, Mock } from 'vitest';
Expand Down Expand Up @@ -87,22 +89,18 @@ describe('useQuery', () => {
});

it('should execute the subscription', async () => {
const { waitForNextUpdate } = renderHook(
({ query, variables }) => useQuery({ query, variables }),
{ initialProps: { query: mockQuery, variables: mockVariables } }
);
renderHook(({ query, variables }) => useQuery({ query, variables }), {
initialProps: { query: mockQuery, variables: mockVariables },
});

await waitForNextUpdate();
expect(client.executeQuery).toBeCalledTimes(1);
});

it('should pass query and variables to executeQuery', async () => {
const { waitForNextUpdate } = renderHook(
({ query, variables }) => useQuery({ query, variables }),
{ initialProps: { query: mockQuery, variables: mockVariables } }
);
renderHook(({ query, variables }) => useQuery({ query, variables }), {
initialProps: { query: mockQuery, variables: mockVariables },
});

await waitForNextUpdate();
expect(client.executeQuery).toBeCalledTimes(1);
expect(client.executeQuery).toBeCalledWith(
{
Expand All @@ -117,12 +115,12 @@ describe('useQuery', () => {
});

it('should return data from executeQuery', async () => {
const { result, waitForNextUpdate } = renderHook(
const { result } = renderHook(
({ query, variables }) => useQuery({ query, variables }),
{ initialProps: { query: mockQuery, variables: mockVariables } }
);

await waitForNextUpdate();
await new Promise(res => setTimeout(res, 30));
const [state] = result.current;
expect(state).toEqual({
fetching: false,
Expand All @@ -134,14 +132,13 @@ describe('useQuery', () => {
});

it('should update if a new query is received', async () => {
const { rerender, waitForNextUpdate } = renderHook<
{ query: string; variables?: object },
{}
const { rerender } = renderHook<
any,
{ query: string; variables: { id?: number } }
>(({ query, variables }) => useQuery({ query, variables }), {
initialProps: { query: mockQuery, variables: mockVariables },
});

await waitForNextUpdate();
expect(client.executeQuery).toBeCalledTimes(1);

const newQuery = `
Expand All @@ -151,7 +148,7 @@ describe('useQuery', () => {
}
`;

rerender({ query: newQuery });
rerender({ query: newQuery, variables: {} });
expect(client.executeQuery).toBeCalledTimes(2);
expect(client.executeQuery).toHaveBeenNthCalledWith(
2,
Expand All @@ -167,14 +164,13 @@ describe('useQuery', () => {
});

it('should update if new variables are received', async () => {
const { rerender, waitForNextUpdate } = renderHook<
{ query: string; variables: object },
{}
>(({ query, variables }) => useQuery({ query, variables }), {
initialProps: { query: mockQuery, variables: mockVariables },
});
const { rerender } = renderHook(
({ query, variables }) => useQuery({ query, variables }),
{
initialProps: { query: mockQuery, variables: mockVariables },
}
);

await waitForNextUpdate();
expect(client.executeQuery).toBeCalledTimes(1);

const newVariables = {
Expand All @@ -197,22 +193,21 @@ describe('useQuery', () => {
});

it('should not update if query and variables are unchanged', async () => {
const { rerender, waitForNextUpdate } = renderHook(
const { rerender } = renderHook(
({ query, variables }) => useQuery({ query, variables }),
{
initialProps: { query: mockQuery, variables: mockVariables },
}
);

await waitForNextUpdate();
expect(client.executeQuery).toBeCalledTimes(1);

rerender({ query: mockQuery, variables: mockVariables });
expect(client.executeQuery).toBeCalledTimes(1);
});

it('should update if a new requestPolicy is provided', async () => {
const { rerender, waitForNextUpdate } = renderHook(
const { rerender } = renderHook(
({ query, variables, requestPolicy }) =>
useQuery({ query, variables, requestPolicy }),
{
Expand All @@ -224,7 +219,6 @@ describe('useQuery', () => {
}
);

await waitForNextUpdate();
expect(client.executeQuery).toBeCalledTimes(1);
expect(client.executeQuery).toHaveBeenNthCalledWith(
1,
Expand Down Expand Up @@ -258,17 +252,15 @@ describe('useQuery', () => {
});

it('should provide an executeQuery function to be imperatively executed', async () => {
const { result, waitForNextUpdate } = renderHook(
const { result } = renderHook(
({ query, variables }) => useQuery({ query, variables }),
{ initialProps: { query: mockQuery, variables: mockVariables } }
);

await waitForNextUpdate();
expect(client.executeQuery).toBeCalledTimes(1);

const [, executeQuery] = result.current;
act(() => executeQuery());
await waitForNextUpdate();
expect(client.executeQuery).toBeCalledTimes(2);
});

Expand All @@ -288,8 +280,11 @@ describe('useQuery', () => {
});

it('should pause executing the query if pause updates to true', async () => {
const { rerender, waitForNextUpdate } = renderHook(
({ query, variables, pause }) => useQuery({ query, variables, pause }),
const { rerender } = renderHook(
props => {
const { query, variables, pause } = props;
return useQuery({ query, variables, pause });
},
{
initialProps: {
query: mockQuery,
Expand All @@ -299,7 +294,6 @@ describe('useQuery', () => {
}
);

await waitForNextUpdate();
expect(client.executeQuery).toBeCalledTimes(1);

rerender({ query: mockQuery, variables: mockVariables, pause: true });
Expand Down
1 change: 1 addition & 0 deletions packages/react-urql/src/hooks/useQuery.test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @vitest-environment jsdom
import { vi, expect, it, beforeEach, describe, Mock } from 'vitest';

// Note: Testing for hooks is not yet supported in Enzyme - https://github.com/airbnb/enzyme/issues/2011
Expand Down
3 changes: 2 additions & 1 deletion packages/react-urql/src/hooks/useRequest.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @vitest-environment jsdom
import { gql } from '@urql/core';
import { renderHook } from '@testing-library/react-hooks';
import { renderHook } from '@testing-library/react';
import { it, expect } from 'vitest';
import { useRequest } from './useRequest';

Expand Down
1 change: 1 addition & 0 deletions packages/react-urql/src/hooks/useSubscription.test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @vitest-environment jsdom
import { vi, expect, it, beforeEach, describe, Mock } from 'vitest';

// Note: Testing for hooks is not yet supported in Enzyme - https://github.com/airbnb/enzyme/issues/2011
Expand Down
6 changes: 5 additions & 1 deletion packages/react-urql/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { mergeConfig } from 'vitest/config';
import baseConfig from '../../vitest.config';

export default mergeConfig(baseConfig, {});
export default mergeConfig(baseConfig, {
test: {
environment: 'jsdom',
},
});
Loading