From 359f4bc209b5f0e1d3bccb474134aed0e0d5614d Mon Sep 17 00:00:00 2001 From: Tobbe Lundberg Date: Sun, 15 Oct 2023 12:17:34 +0200 Subject: [PATCH] Cell generator: Fix formatting in template (#9301) --- .../generate/cell/__tests__/__snapshots__/cell.test.js.snap | 2 ++ .../src/commands/generate/cell/templates/cell.tsx.template | 1 + .../commands/generate/cell/templates/cellList.tsx.template | 1 + packages/internal/src/__tests__/ast.test.ts | 6 +++--- .../src/__tests__/fixtures/web/src/{cell.ts => cell.tsx} | 1 + 5 files changed, 8 insertions(+), 3 deletions(-) rename packages/internal/src/__tests__/fixtures/web/src/{cell.ts => cell.tsx} (99%) diff --git a/packages/cli/src/commands/generate/cell/__tests__/__snapshots__/cell.test.js.snap b/packages/cli/src/commands/generate/cell/__tests__/__snapshots__/cell.test.js.snap index 38d5d276f603..0a0702dce540 100644 --- a/packages/cli/src/commands/generate/cell/__tests__/__snapshots__/cell.test.js.snap +++ b/packages/cli/src/commands/generate/cell/__tests__/__snapshots__/cell.test.js.snap @@ -510,6 +510,7 @@ describe('UserProfileCell', () => { exports[`TypeScript: generates list cells if list flag passed in 1`] = ` "import type { FindBazingaQuery, FindBazingaQueryVariables } from 'types/graphql' + import type { CellSuccessProps, CellFailureProps } from '@redwoodjs/web' export const QUERY = gql\` @@ -633,6 +634,7 @@ export const standard = (/* vars, { ctx, req } */) => ({ exports[`TypeScript: generates list cells if name is plural 1`] = ` "import type { MembersQuery } from 'types/graphql' + import type { CellSuccessProps, CellFailureProps } from '@redwoodjs/web' export const QUERY = gql\` diff --git a/packages/cli/src/commands/generate/cell/templates/cell.tsx.template b/packages/cli/src/commands/generate/cell/templates/cell.tsx.template index 626a1372167b..264ef6031ec9 100644 --- a/packages/cli/src/commands/generate/cell/templates/cell.tsx.template +++ b/packages/cli/src/commands/generate/cell/templates/cell.tsx.template @@ -1,4 +1,5 @@ import type { ${operationName}, ${operationName}Variables } from 'types/graphql' + import type { CellSuccessProps, CellFailureProps } from '@redwoodjs/web' export const QUERY = gql` diff --git a/packages/cli/src/commands/generate/cell/templates/cellList.tsx.template b/packages/cli/src/commands/generate/cell/templates/cellList.tsx.template index 6b7b71094c35..c4d434893132 100644 --- a/packages/cli/src/commands/generate/cell/templates/cellList.tsx.template +++ b/packages/cli/src/commands/generate/cell/templates/cellList.tsx.template @@ -1,4 +1,5 @@ import type { ${operationName} } from 'types/graphql' + import type { CellSuccessProps, CellFailureProps } from '@redwoodjs/web' diff --git a/packages/internal/src/__tests__/ast.test.ts b/packages/internal/src/__tests__/ast.test.ts index e041f8f9c8d6..29ad90fabf13 100644 --- a/packages/internal/src/__tests__/ast.test.ts +++ b/packages/internal/src/__tests__/ast.test.ts @@ -79,7 +79,7 @@ test('tests default exports', () => { }) test('Returns the exported query from a cell (ignoring others)', () => { - const cellFileAst = fileToAst(getFixturePath('web/src/cell.ts')) + const cellFileAst = fileToAst(getFixturePath('web/src/cell.tsx')) const cellQuery = getCellGqlQuery(cellFileAst) expect(cellQuery).toMatchInlineSnapshot(` @@ -93,8 +93,8 @@ test('Returns the exported query from a cell (ignoring others)', () => { `) }) -test('Returns the all quries from a file using getGqlQueries', () => { - const cellFileAst = fileToAst(getFixturePath('web/src/cell.ts')) +test('Returns the all queries from a file using getGqlQueries', () => { + const cellFileAst = fileToAst(getFixturePath('web/src/cell.tsx')) const cellQuery = getGqlQueries(cellFileAst) expect(cellQuery).toMatchInlineSnapshot(` diff --git a/packages/internal/src/__tests__/fixtures/web/src/cell.ts b/packages/internal/src/__tests__/fixtures/web/src/cell.tsx similarity index 99% rename from packages/internal/src/__tests__/fixtures/web/src/cell.ts rename to packages/internal/src/__tests__/fixtures/web/src/cell.tsx index 3ab4552513c8..b39160cbad3b 100644 --- a/packages/internal/src/__tests__/fixtures/web/src/cell.ts +++ b/packages/internal/src/__tests__/fixtures/web/src/cell.tsx @@ -2,6 +2,7 @@ /* eslint-disable */ import type { BazingaQuery } from 'types/graphql' + import type { CellSuccessProps, CellFailureProps } from '@redwoodjs/web' export const QUERY = gql`