forked from redwoodjs/redwood
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:redwoodjs/redwood into feat/api-ski…
…p-prebuild-try-2 * 'main' of github.com:redwoodjs/redwood: Fastify config: Use exact file extension in log message (redwoodjs#9828) Remove unused Fastify plugin (redwoodjs#9827) Add trusted-documents to fragments CI smoke-test (redwoodjs#9826) prerender: Enable Trusted Documents support (redwoodjs#9825) trustedDocuments.test.ts: Format source cli: add missing dep jscodeshift (redwoodjs#9823) graphql setup fragments: Move telemetry to main handler (redwoodjs#9819) feat: Adds Setup CLI Command to Configure GraphQL Trusted Documents (redwoodjs#9800) Update cli tsconfig to reference used packages (redwoodjs#9822) fragments setup: newline fix + refactor->rename (redwoodjs#9821) yarn rw setup graphql fragments (redwoodjs#9811)
- Loading branch information
Showing
71 changed files
with
3,341 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import type { Config } from 'jest' | ||
|
||
const config: Config = { | ||
projects: [ | ||
{ | ||
displayName: 'root', | ||
testMatch: ['**/__tests__/**/*.[jt]s?(x)', '**/*.test.[jt]s?(x)'], | ||
testPathIgnorePatterns: [ | ||
'__fixtures__', | ||
'__testfixtures__', | ||
'__codemod_tests__', | ||
'__tests__/utils/*', | ||
'__tests__/fixtures/*', | ||
'.d.ts', | ||
'dist', | ||
], | ||
moduleNameMapper: { | ||
'^src/(.*)': '<rootDir>/src/$1', | ||
}, | ||
setupFilesAfterEnv: ['./jest.setup.js'], | ||
}, | ||
{ | ||
displayName: 'setup codemods', | ||
testMatch: ['**/commands/setup/**/__codemod_tests__/*.ts'], | ||
testPathIgnorePatterns: [ | ||
'__fixtures__', | ||
'__testfixtures__', | ||
'__tests__/utils/*', | ||
'__tests__/fixtures/*', | ||
'.d.ts', | ||
'dist', | ||
], | ||
setupFilesAfterEnv: ['./src/jest.codemods.setup.ts'], | ||
}, | ||
], | ||
testTimeout: 20_000, | ||
} | ||
|
||
export default config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
...commands/setup/graphql/features/fragments/__codemod_tests__/appGqlConfigTransform.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import fs from 'node:fs' | ||
import path from 'node:path' | ||
|
||
import { findUp } from '@redwoodjs/project-config' | ||
|
||
describe('fragments graphQLClientConfig', () => { | ||
test('App.tsx with no graphQLClientConfig', async () => { | ||
await matchFolderTransform('appGqlConfigTransform', 'config-simple', { | ||
useJsCodeshift: true, | ||
}) | ||
}) | ||
|
||
test('App.tsx with existing inline graphQLClientConfig', async () => { | ||
await matchFolderTransform('appGqlConfigTransform', 'existingPropInline', { | ||
useJsCodeshift: true, | ||
}) | ||
}) | ||
|
||
test('App.tsx with existing graphQLClientConfig in separate variable', async () => { | ||
await matchFolderTransform( | ||
'appGqlConfigTransform', | ||
'existingPropVariable', | ||
{ | ||
useJsCodeshift: true, | ||
} | ||
) | ||
}) | ||
|
||
test('App.tsx with existing graphQLClientConfig in separate variable, without cacheConfig property', async () => { | ||
await matchFolderTransform( | ||
'appGqlConfigTransform', | ||
'existingPropVariableNoCacheConfig', | ||
{ | ||
useJsCodeshift: true, | ||
} | ||
) | ||
}) | ||
|
||
test('App.tsx with existing graphQLClientConfig in separate variable with non-standard name', async () => { | ||
await matchFolderTransform( | ||
'appGqlConfigTransform', | ||
'existingPropVariableCustomName', | ||
{ | ||
useJsCodeshift: true, | ||
} | ||
) | ||
}) | ||
|
||
test('test-project App.tsx', async () => { | ||
const rootFwPath = path.dirname(findUp('lerna.json') || '') | ||
const testProjectAppTsx = fs.readFileSync( | ||
path.join( | ||
rootFwPath, | ||
'__fixtures__', | ||
'test-project', | ||
'web', | ||
'src', | ||
'App.tsx' | ||
), | ||
'utf-8' | ||
) | ||
await matchInlineTransformSnapshot( | ||
'appGqlConfigTransform', | ||
testProjectAppTsx, | ||
`import { FatalErrorBoundary, RedwoodProvider } from \"@redwoodjs/web\"; | ||
import { RedwoodApolloProvider } from \"@redwoodjs/web/apollo\"; | ||
import FatalErrorPage from \"src/pages/FatalErrorPage\"; | ||
import Routes from \"src/Routes\"; | ||
import { AuthProvider, useAuth } from \"./auth\"; | ||
import \"./scaffold.css\"; | ||
import \"./index.css\"; | ||
const graphQLClientConfig = { | ||
cacheConfig: { | ||
possibleTypes: possibleTypes.possibleTypes, | ||
}, | ||
}; | ||
const App = () => ( | ||
<FatalErrorBoundary page={FatalErrorPage}> | ||
<RedwoodProvider titleTemplate=\"%PageTitle | %AppTitle\"> | ||
<AuthProvider> | ||
<RedwoodApolloProvider | ||
useAuth={useAuth} | ||
graphQLClientConfig={graphQLClientConfig} | ||
> | ||
<Routes /> | ||
</RedwoodApolloProvider> | ||
</AuthProvider> | ||
</RedwoodProvider> | ||
</FatalErrorBoundary> | ||
); | ||
export default App; | ||
` | ||
) | ||
}) | ||
}) |
13 changes: 13 additions & 0 deletions
13
...rc/commands/setup/graphql/features/fragments/__codemod_tests__/appImportTransform.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
describe('fragments possibleTypes import', () => { | ||
test('Default App.tsx', async () => { | ||
await matchFolderTransform('appImportTransform', 'import-simple', { | ||
useJsCodeshift: true, | ||
}) | ||
}) | ||
|
||
test('App.tsx with existing import', async () => { | ||
await matchFolderTransform('appImportTransform', 'existingImport', { | ||
useJsCodeshift: true, | ||
}) | ||
}) | ||
}) |
22 changes: 22 additions & 0 deletions
22
...rc/commands/setup/graphql/features/fragments/__testfixtures__/config-simple/input/App.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { FatalErrorBoundary, RedwoodProvider } from '@redwoodjs/web' | ||
import { RedwoodApolloProvider } from '@redwoodjs/web/apollo' | ||
|
||
import possibleTypes from 'src/graphql/possibleTypes' | ||
|
||
import FatalErrorPage from 'src/pages/FatalErrorPage' | ||
import Routes from 'src/Routes' | ||
|
||
import './scaffold.css' | ||
import './index.css' | ||
|
||
const App = () => ( | ||
<FatalErrorBoundary page={FatalErrorPage}> | ||
<RedwoodProvider titleTemplate="%PageTitle | %AppTitle"> | ||
<RedwoodApolloProvider> | ||
<Routes /> | ||
</RedwoodApolloProvider> | ||
</RedwoodProvider> | ||
</FatalErrorBoundary> | ||
) | ||
|
||
export default App |
Oops, something went wrong.