Skip to content

Commit

Permalink
Highlight the error title
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzaloriestra committed Jun 21, 2024
1 parent 54c297f commit a012c8a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
20 changes: 14 additions & 6 deletions packages/app/src/cli/models/app/loader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
import {inTemporaryDirectory, moveFile, mkdir, mkTmpDir, rmdir, writeFile} from '@shopify/cli-kit/node/fs'
import {joinPath, dirname, cwd, normalizePath} from '@shopify/cli-kit/node/path'
import {platformAndArch} from '@shopify/cli-kit/node/os'
import {outputContent} from '@shopify/cli-kit/node/output'
import {outputContent, outputToken} from '@shopify/cli-kit/node/output'
import {zod} from '@shopify/cli-kit/node/schema'
import {mockAndCaptureOutput} from '@shopify/cli-kit/node/testing/output'
import {currentProcessIsGlobal} from '@shopify/cli-kit/node/is-global'
Expand Down Expand Up @@ -418,7 +418,7 @@ wrong = "property"
})

// When
await expect(loadTestingApp()).rejects.toThrow(/Validation errors in/)
await expect(loadTestingApp()).rejects.toThrow(/Validation errors/)
})

test('throws an error if the extension type is invalid', async () => {
Expand Down Expand Up @@ -2484,7 +2484,9 @@ describe('parseConfigurationObject', () => {
message: 'Boolean is required',
},
]
const expectedFormatted = outputContent`\nValidation errors in tmp:\n\n${parseHumanReadableError(errorObject)}`
const expectedFormatted = outputContent`\n${outputToken.errorText(
'Validation errors',
)} in tmp:\n\n${parseHumanReadableError(errorObject)}`

const abortOrReport = vi.fn()

Expand All @@ -2509,7 +2511,9 @@ describe('parseConfigurationObject', () => {
message: 'Expected string, received array',
},
]
const expectedFormatted = outputContent`\nValidation errors in tmp:\n\n${parseHumanReadableError(errorObject)}`
const expectedFormatted = outputContent`\n${outputToken.errorText(
'Validation errors',
)} in tmp:\n\n${parseHumanReadableError(errorObject)}`
const abortOrReport = vi.fn()
await parseConfigurationObject(LegacyAppSchema, 'tmp', configurationObject, abortOrReport)

Expand Down Expand Up @@ -2556,7 +2560,9 @@ describe('parseConfigurationObject', () => {
message: 'Invalid input',
},
]
const expectedFormatted = outputContent`\nValidation errors in tmp:\n\n${parseHumanReadableError(errorObject)}`
const expectedFormatted = outputContent`\n${outputToken.errorText(
'Validation errors',
)} in tmp:\n\n${parseHumanReadableError(errorObject)}`
const abortOrReport = vi.fn()
await parseConfigurationObject(WebConfigurationSchema, 'tmp', configurationObject, abortOrReport)

Expand Down Expand Up @@ -3031,7 +3037,9 @@ describe('WebhooksSchema', () => {

async function setupParsing(errorObj: zod.ZodIssue | {}, webhookConfigOverrides: WebhooksConfig) {
const err = Array.isArray(errorObj) ? errorObj : [errorObj]
const expectedFormatted = outputContent`\nValidation errors in tmp:\n\n${parseHumanReadableError(err)}`
const expectedFormatted = outputContent`\n${outputToken.errorText(
'Validation errors',
)} in tmp:\n\n${parseHumanReadableError(err)}`
const abortOrReport = vi.fn()

const {path, ...toParse} = getWebhookConfig(webhookConfigOverrides)
Expand Down
6 changes: 3 additions & 3 deletions packages/app/src/cli/models/app/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ export function parseConfigurationObject<TSchema extends zod.ZodType>(
const parseResult = schema.safeParse(configurationObject)
if (!parseResult.success) {
return abortOrReport(
outputContent`\nValidation errors in ${outputToken.path(filepath)}:\n\n${parseHumanReadableError(
parseResult.error.issues,
)}`,
outputContent`\n${outputToken.errorText('Validation errors')} in ${outputToken.path(
filepath,
)}:\n\n${parseHumanReadableError(parseResult.error.issues)}`,
fallbackOutput,
filepath,
)
Expand Down

0 comments on commit a012c8a

Please sign in to comment.