Skip to content

Commit

Permalink
Allow null values in test files
Browse files Browse the repository at this point in the history
  • Loading branch information
codykaup committed Sep 27, 2024
1 parent c29296c commit 3d61a79
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 22 deletions.
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ export default [
'no-secrets/no-secrets': 'warn',
'max-lines': 'warn',
'jsdoc/require-jsdoc': 'off',
'unicorn/no-null': 'off', // GraphQL returns `null` when there is no value
},
},
];
2 changes: 1 addition & 1 deletion node-src/git/getParentCommits.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ describe('getParentCommits', () => {
const mockIndex = createMockIndex(repository, [['A', 'main']]);
const mockIndexWithNullFirstBuildCommittedAt = (queryName, variables) => {
if (queryName === 'FirstCommittedAtQuery') {
return { app: { firstBuild: {} } };
return { app: { firstBuild: { committedAt: null } } };
}
return mockIndex(queryName, variables);
};
Expand Down
2 changes: 1 addition & 1 deletion node-src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ vi.mock('node-fetch', () => ({
}

if (query?.match('FirstCommittedAtQuery')) {
return { data: { app: { firstBuild: {} } } };
return { data: { app: { firstBuild: { committedAt: null } } } };
}

if (query?.match('HasBuildsWithCommitsQuery')) {
Expand Down
3 changes: 1 addition & 2 deletions node-src/lib/findChangedPackageFiles.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ describe('findChangedPackageFiles', () => {
it('considers the file changed if it fails to parse', async () => {
mockFileContents({
'package.json': {
A: '',
A: null,
HEAD: { dependencies: { a: '2' } },
},
});
Expand Down Expand Up @@ -445,7 +445,6 @@ describe('arePackageDependenciesEqual', () => {
});

it('returns true if dependencies are null', () => {
// eslint-disable-next-line unicorn/no-null
expect(arePackageDependenciesEqual({ dependencies: null }, { dependencies: null })).toBe(true);
});
});
10 changes: 5 additions & 5 deletions node-src/lib/getDependentStoryFiles.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ describe('getDependentStoryFiles', () => {
const changedFiles = ['src/foo.css'];
const modules = [
{
id: '',
id: null,
name: './src/foo.css?ngResource ',
reasons: [{ moduleName: './src/foo.component.ts' }],
},
Expand Down Expand Up @@ -614,22 +614,22 @@ describe('getDependentStoryFiles', () => {
],
},
{
id: '',
id: null,
name: './src/stories/Page.jsx', // changed
reasons: [{ moduleName: './src/stories/Page.stories.jsx' }],
},
{
id: '',
id: null,
name: './src/stories/button.css',
reasons: [{ moduleName: './src/stories/Button.jsx' }],
},
{
id: '',
id: null,
name: './src/stories/header.css',
reasons: [{ moduleName: './src/stories/Header.jsx' }],
},
{
id: '',
id: null,
name: './src/stories/page.css',
reasons: [{ moduleName: './src/stories/Page.jsx' }],
},
Expand Down
4 changes: 2 additions & 2 deletions node-src/tasks/report.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ const mockTests = [
result: '',
spec: { name: '', component: { name: '' } },
parameters: { viewportIsDefault: true, viewport: 1080 },
mode: { name: '' },
mode: { name: null },
},
{
status: 'FAILED',
result: '',
spec: { name: '', component: { name: '' } },
parameters: { viewportIsDefault: false, viewport: 1080 },
mode: { name: '' },
mode: { name: null },
},
];

Expand Down
16 changes: 6 additions & 10 deletions node-src/tasks/verify.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,7 @@ describe('verifyBuild', () => {
app: {},
startedAt: Date.now(),
};
const publishedBuild = {
...build,
status: 'PUBLISHED',
startedAt: undefined,
upgradeBuilds: [],
};
const publishedBuild = { ...build, status: 'PUBLISHED', startedAt: null, upgradeBuilds: [] };
const client = { runQuery: vi.fn() };
client.runQuery
// We can safely poll three times without hitting the timeout
Expand Down Expand Up @@ -111,6 +106,7 @@ describe('verifyBuild', () => {
status: 'PUBLISHED',
features: { uiTests: true, uiReview: false },
app: {},
startedAt: null,
upgradeBuilds: [],
};
const client = { runQuery: vi.fn() };
Expand All @@ -129,9 +125,9 @@ describe('verifyBuild', () => {
app: {},
startedAt: Date.now(),
};
const upgradeBuilds = [{}];
const upgradeBuilds = [{ completedAt: null }];
const completed = [{ completedAt: Date.now() }];
const publishedBuild = { ...build, status: 'PUBLISHED', startedAt: undefined, upgradeBuilds };
const publishedBuild = { ...build, status: 'PUBLISHED', startedAt: null, upgradeBuilds };
const client = { runQuery: vi.fn() };
client.runQuery
// Polling while upgrade builds are in progress is irrelevant
Expand Down Expand Up @@ -159,8 +155,8 @@ describe('verifyBuild', () => {
app: {},
startedAt: Date.now(),
};
const upgradeBuilds = [{}];
const publishedBuild = { ...build, status: 'PUBLISHED', startedAt: undefined, upgradeBuilds };
const upgradeBuilds = [{ completedAt: null }];
const publishedBuild = { ...build, status: 'PUBLISHED', startedAt: null, upgradeBuilds };
const client = { runQuery: vi.fn() };
client.runQuery.mockReturnValue({ app: { build: publishedBuild } });

Expand Down
4 changes: 3 additions & 1 deletion node-src/ui/tasks/verify.stories.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable unicorn/no-null -- GraphQL returns `null` if a value doesn't exist */
import task from '../components/task';
import {
awaitingUpgrades,
Expand Down Expand Up @@ -46,7 +47,8 @@ export const RunOnlyNames = () =>
options: { onlyStoryNames: ['MyComponent/**'] },
} as any);

export const AwaitingUpgrades = () => awaitingUpgrades({} as any, [{ completedAt: 123 }, {}]);
export const AwaitingUpgrades = () =>
awaitingUpgrades({} as any, [{ completedAt: 123 }, { completedAt: null }]);

export const Started = () => success({ build } as any);

Expand Down

0 comments on commit 3d61a79

Please sign in to comment.