Skip to content

Commit

Permalink
Merge pull request #2380 from alphagov/only-display-packages-with-a-p…
Browse files Browse the repository at this point in the history
…lugin-config

Only display packages that are plugins
  • Loading branch information
BenSurgisonGDS authored Nov 23, 2023
2 parents f7d87a9 + 205c49a commit 1afd0e4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Fixes

- [#2380: Only display packages that are plugins](https://github.com/alphagov/govuk-prototype-kit/pull/2380)

## 13.15.2

### Fixes
Expand Down
3 changes: 2 additions & 1 deletion lib/manage-prototype-handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,8 @@ function buildPluginData (pluginData) {
}

async function prepareForPluginPage (isInstalledPage, search) {
const allPlugins = await getAllPackages()
const allPackages = await getAllPackages()
const allPlugins = allPackages.filter(({ pluginConfig }) => !!pluginConfig)
const installedPlugins = await getInstalledPackages()

const plugins = isInstalledPage
Expand Down
21 changes: 17 additions & 4 deletions lib/manage-prototype-handlers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ jest.mock('./plugins/plugins', () => {
})

jest.mock('./plugins/packages', () => {
const availablePackage = {
const packageWithPluginConfig = {
packageName: 'test-package',
installed: false,
available: true,
Expand All @@ -101,18 +101,31 @@ jest.mock('./plugins/packages', () => {
'2.0.0',
'1.0.0'
],
packageJson: {},
pluginConfig: {}
}
const packageWithoutPluginConfig = {
packageName: 'test-package-not-a-plugin',
installed: false,
available: true,
required: false,
latestVersion: '2.0.0',
versions: [
'2.0.0',
'1.0.0'
],
packageJson: {}
}
return {
lookupPackageInfo: jest.fn().mockImplementation((packageName) => {
if (packageName === availablePackage.packageName) {
return availablePackage
if (packageName === packageWithPluginConfig.packageName) {
return packageWithPluginConfig
} else {
return undefined
}
}),
getInstalledPackages: jest.fn().mockResolvedValue([]),
getAllPackages: jest.fn().mockResolvedValue([availablePackage]),
getAllPackages: jest.fn().mockResolvedValue([packageWithPluginConfig, packageWithoutPluginConfig]),
getDependentPackages: jest.fn().mockResolvedValue([]),
getDependencyPackages: jest.fn().mockResolvedValue([])
}
Expand Down

0 comments on commit 1afd0e4

Please sign in to comment.