Skip to content

Commit

Permalink
WIP5
Browse files Browse the repository at this point in the history
  • Loading branch information
codykaup committed Dec 9, 2024
1 parent ef19f24 commit 64ad25b
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 4 deletions.
85 changes: 84 additions & 1 deletion node-src/tasks/verify.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, expect, it, vi } from 'vitest';
import { describe, expect, it, test, vi } from 'vitest';

import { exitCodes } from '../lib/setExitCode';
import { publishBuild, verifyBuild } from './verify';
Expand Down Expand Up @@ -229,6 +229,89 @@ describe('verifyBuild', () => {
expect(ctx.exitCode).toBe(12);
});

describe('sets exitCode to 0 and skips snapshotting', () => {
const publishOnlyClient = { runQuery: vi.fn() };
publishOnlyClient.runQuery.mockReturnValue({
app: {
build: {
number: 1,
status: 'IN_PROGRESS',
storybookUrl: 'https://5d67dc0374b2e300209c41e7-pfkaemtlit.chromatic.com/',
features: { uiTests: false, uiReview: false },
app: { account: { paymentRequired: true } },
wasLimited: true,
startedAt: Date.now(),
},
},
});

const client = { runQuery: vi.fn() };
client.runQuery.mockReturnValue({
app: {
build: {
number: 1,
status: 'IN_PROGRESS',
storybookUrl: 'https://5d67dc0374b2e300209c41e7-pfkaemtlit.chromatic.com/',
features: { uiTests: true, uiReview: false },
app: { account: { paymentRequired: false } },
startedAt: Date.now(),
},
},
});

test('publish-only builds', async () => {
const ctx = { client: publishOnlyClient, ...defaultContext } as any;
await verifyBuild(ctx, {} as any);
expect(ctx.exitCode).toBe(0);
expect(ctx.skipSnapshots).toBe(true);
});

test('exitOnceUploaded from flags', async () => {
const ctx = {
client,
...defaultContext,
flags: { exitOnceUploaded: true },
git: {
matchesBranch: (glob: string | boolean) =>
typeof glob === 'string' ? glob === 'true' : !!glob,
},
} as any;
await verifyBuild(ctx, {} as any);
expect(ctx.exitCode).toBe(0);
expect(ctx.skipSnapshots).toBe(true);
});

test('exitOnceUploaded from configuration', async () => {
const ctx = {
client,
...defaultContext,
configuration: { exitOnceUploaded: true },
git: {
matchesBranch: (glob: string | boolean) =>
typeof glob === 'string' ? glob === 'true' : !!glob,
},
} as any;
await verifyBuild(ctx, {} as any);
expect(ctx.exitCode).toBe(0);
expect(ctx.skipSnapshots).toBe(true);
});

test('exitOnceUploaded from options', async () => {
const ctx = {
client,
...defaultContext,
options: { exitOnceUploaded: true },
git: {
matchesBranch: (glob: string | boolean) =>
typeof glob === 'string' ? glob === 'true' : !!glob,
},
} as any;
await verifyBuild(ctx, {} as any);
expect(ctx.exitCode).toBe(0);
expect(ctx.skipSnapshots).toBe(true);
});
});

it('sets exitCode to 0 and skips snapshotting for publish-only builds', async () => {
const client = { runQuery: vi.fn() };
client.runQuery.mockReturnValue({
Expand Down
6 changes: 3 additions & 3 deletions node-src/tasks/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,9 @@ export const verifyBuild = async (ctx: Context, task: Task) => {
list ||
ctx.isPublishOnly ||
matchesBranch?.(
ctx.options.exitOnceUploaded ||
ctx.configuration.exitOnceUploaded ||
ctx.options.exitOnceUploaded
ctx.flags?.exitOnceUploaded ||
ctx.configuration?.exitOnceUploaded ||
ctx.options?.exitOnceUploaded
)
) {
ctx.log.info('Exit once uploaded triggered, skipping!!!');
Expand Down

0 comments on commit 64ad25b

Please sign in to comment.