-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4816 from relative-ci/asset-meta-tag-changes
Asset meta tag changes
- Loading branch information
Showing
31 changed files
with
1,087 additions
and
366 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
import React from 'react'; | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { createJobs } from '@bundle-stats/utils'; | ||
import merge from 'lodash/merge'; | ||
|
||
/* eslint-disable import/no-unresolved, import/no-relative-packages */ | ||
import currentData from '../../../../fixtures/job.current'; | ||
import baselineData from '../../../../fixtures/job.baseline'; | ||
/* eslint-enable import/no-unresolved, import/no-relative-packages */ | ||
import { App } from '.'; | ||
|
||
const CURRENT_SOURCE = { | ||
webpack: { | ||
...currentData.rawData.webpack, | ||
builtAt: currentData.createdAt, | ||
hash: currentData.commit, | ||
}, | ||
}; | ||
|
||
const BASELINE_SOURCE = { | ||
webpack: { | ||
...baselineData.rawData.webpack, | ||
builtAt: baselineData.createdAt, | ||
hash: baselineData.commit, | ||
}, | ||
}; | ||
|
||
const JOBS = createJobs([CURRENT_SOURCE, BASELINE_SOURCE]); | ||
|
||
const MULTIPLE_JOBS = createJobs([ | ||
CURRENT_SOURCE, | ||
BASELINE_SOURCE, | ||
{ | ||
webpack: { | ||
...baselineData.rawData.webpack, | ||
builtAt: baselineData.createdAt, | ||
hash: 'aaaa1111', | ||
assets: baselineData.rawData.webpack.assets.filter((asset) => asset.name.match(/.(css|js)$/)), | ||
modules: baselineData.rawData.webpack.modules.slice(0, 100), | ||
}, | ||
}, | ||
]); | ||
|
||
const [CURRENT_JOB, BASELINE_JOB] = JOBS; | ||
|
||
const meta: Meta<typeof App> = { | ||
title: 'App', | ||
component: App, | ||
parameters: { | ||
layout: 'fullscreen', | ||
}, | ||
args: { | ||
version: '1.0', | ||
}, | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
render: (args) => <App jobs={JOBS} {...args} />, | ||
}; | ||
|
||
export const NoInsights: Story = { | ||
render: (args) => ( | ||
<App | ||
jobs={[ | ||
{ | ||
...CURRENT_JOB, | ||
insights: undefined, | ||
}, | ||
BASELINE_JOB, | ||
]} | ||
{...args} | ||
/> | ||
), | ||
}; | ||
|
||
export const AssetMetaChanges: Story = { | ||
render: (args) => { | ||
const current = merge({}, CURRENT_SOURCE); | ||
const baseline = merge({}, CURRENT_SOURCE); | ||
|
||
current.webpack.assets.push({ | ||
name: 'assets/js/vendors-auth.1a278dc.js', | ||
size: 26364, | ||
}); | ||
current.webpack.chunks.push({ | ||
id: 100, | ||
entry: false, | ||
initial: false, | ||
files: ['assets/js/vendors-auth.1a278dc.js'], | ||
names: ['vendors-auth'], | ||
}); | ||
|
||
baseline.webpack.assets.push({ | ||
name: 'assets/js/vendors-auth.1a278dc.js', | ||
size: 26364, | ||
}); | ||
baseline.webpack.chunks.push({ | ||
id: 100, | ||
entry: false, | ||
initial: true, | ||
files: ['assets/js/vendors-auth.1a278dc.js'], | ||
names: ['vendors-auth'], | ||
}); | ||
|
||
return <App jobs={createJobs([current, baseline])} {...args} />; | ||
}, | ||
}; | ||
|
||
export const NoBaseline: Story = { | ||
render: (args) => <App jobs={createJobs([CURRENT_SOURCE])} {...args} />, | ||
}; | ||
|
||
export const EmptyBaseline: Story = { | ||
render: (args) => <App jobs={createJobs([CURRENT_SOURCE, { webpack: null }])} {...args} />, | ||
}; | ||
|
||
export const MultipleBaselines: Story = { | ||
render: (args) => <App jobs={MULTIPLE_JOBS} {...args} />, | ||
}; | ||
|
||
export const Empty: Story = { | ||
render: (args) => <App {...args} />, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.