Skip to content

Commit

Permalink
Fix broken story
Browse files Browse the repository at this point in the history
  • Loading branch information
EMaksy committed Nov 7, 2024
1 parent 941d971 commit c704f16
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { upgradablePackageFactory } from '@lib/test-utils/factories/upgradablePackage';
import { upgradablePackageFactory } from '@lib/test-utils/factories/relevantPatches';
import UpgradablePackagesList from './UpgradablePackagesList';

export default {
Expand All @@ -10,6 +10,10 @@ export default {
control: { type: 'text' },
description: 'The name of the host',
},
onPatchClick: {
action: 'patch clicked',
description: 'Callback when patch is clicked',
},
upgradablePackages: {
control: {
type: 'array',
Expand All @@ -25,14 +29,15 @@ export default {
export const Default = {
args: {
hostname: 'Example Host',
upgradablePackages: upgradablePackageFactory.buildList(4),
patchesLoading: false,
upgradablePackages: upgradablePackageFactory.buildList(2),
},
};

export const PatchesLoading = {
args: {
hostname: 'Example Host',
patchesLoading: true,
upgradablePackages: upgradablePackageFactory.buildList(4),
upgradablePackages: upgradablePackageFactory.buildList(2),
},
};
13 changes: 12 additions & 1 deletion assets/js/lib/test-utils/factories/relevantPatches.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import { faker } from '@faker-js/faker';
import { Factory } from 'fishery';

export const advisoryType = ['security_advisory', 'bugfix', 'enhancement'];

function generateCustomVersion() {
const major = faker.number.int({ min: 0, max: 10 });
const minor = faker.number.int({ min: 0, max: 20 });
const patch = faker.number.int({ min: 0, max: 30 });
return `${major}.${minor}.${patch}`;
}
export const relevantPatchFactory = Factory.define(({ sequence }) => ({
advisory_name: `${faker.animal.cat()}${sequence}`,
advisory_type: faker.helpers.arrayElement(advisoryType),
Expand All @@ -21,3 +26,9 @@ export const patchForPackageFactory = Factory.define(({ sequence }) => ({
update_date: faker.date.anytime().toString(),
last_modified_date: faker.date.anytime().toString(),
}));

export const upgradablePackageFactory = Factory.define(() => ({
installed_package: `Package ${faker.animal.cat()}`,
latest_package: generateCustomVersion(),
patches: [{ advisory: faker.animal.cat() }],
}));

0 comments on commit c704f16

Please sign in to comment.