Skip to content

Commit

Permalink
Move to multiline format for changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmhobbs committed Jan 24, 2025
1 parent 28eaae5 commit 3314025
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
12 changes: 9 additions & 3 deletions node-src/ui/messages/errors/buildHasChanges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,20 @@ export default ({ build, exitCode, isOnboarding }) => {

const changes: any[] = [];
if (build.changeCount > 0) {
changes.push(pluralize('visual changes', build.changeCount, true));
changes.push(
chalk`${error} {bold Found ${pluralize('visual changes', build.changeCount, true)}}`
);
}
if (build.accessibilityChangeCount > 0) {
changes.push(pluralize('accessibility changes', build.accessibilityChangeCount, true));
changes.push(
chalk`${error} {bold Found ${pluralize('accessibility changes', build.accessibilityChangeCount, true)}}`
);
}

Check warning on line 21 in node-src/ui/messages/errors/buildHasChanges.ts

View check run for this annotation

Codecov / codecov/patch

node-src/ui/messages/errors/buildHasChanges.ts#L18-L21

Added lines #L18 - L21 were not covered by tests

return dedent(chalk`
${error} {bold Found ${changes.join(' and ')}}: Review the changes at ${link(url)}
${changes.join('\n')}
Review the changes at ${link(url)}
${info} For CI/CD use cases, this command failed with exit code ${exitCode}
Pass {bold --exit-zero-on-changes} to succeed this command regardless of changes.
Expand Down
21 changes: 21 additions & 0 deletions node-src/ui/messages/info/buildPassed.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,27 @@ export const BuildPassedWithChanges = () =>
number: 42,
webUrl: 'https://www.chromatic.com/build?appId=59c59bd0183bd100364e1d57&number=42',
changeCount: 2,
accessibilityChangeCount: 1,
},
} as any);

export const BuildPassedWithVisualChanges = () =>
buildPassed({
...ctx,
build: {
number: 42,
webUrl: 'https://www.chromatic.com/build?appId=59c59bd0183bd100364e1d57&number=42',
changeCount: 2,
},
} as any);

export const BuildPassedWithAccessibilityChanges = () =>
buildPassed({
...ctx,
build: {
number: 42,
webUrl: 'https://www.chromatic.com/build?appId=59c59bd0183bd100364e1d57&number=42',
accessibilityChangeCount: 1,
},
} as any);

Expand Down
4 changes: 2 additions & 2 deletions node-src/ui/messages/info/buildPassed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { stats } from '../../tasks/snapshot';
export default (ctx: Context) => {
const { snapshots, components, stories, e2eTests } = stats({ build: ctx.build });

const totalChanges = ctx.build.changeCount + ctx.build.accessibilityChangeCount;
const totalChanges = (ctx.build.changeCount || 0) + (ctx.build.accessibilityChangeCount || 0);

if (ctx.isOnboarding) {
const foundString = isE2EBuild(ctx.options)
Expand All @@ -36,7 +36,7 @@ export default (ctx: Context) => {
return ctx.build.autoAcceptChanges && totalChanges > 0
? dedent(chalk`
${success} {bold Build ${ctx.build.number} passed!}
Auto-accepted ${pluralize('changes', ctx.build.changeCount + ctx.build.accessibilityChangeCount, true)}.
Auto-accepted ${pluralize('changes', totalChanges, true)}.

Check warning on line 39 in node-src/ui/messages/info/buildPassed.ts

View check run for this annotation

Codecov / codecov/patch

node-src/ui/messages/info/buildPassed.ts#L39

Added line #L39 was not covered by tests
${info} View build details at ${link(ctx.build.webUrl)}
`)
: dedent(chalk`
Expand Down

0 comments on commit 3314025

Please sign in to comment.