Skip to content

Commit

Permalink
Merge pull request #1935 from alphagov/fix-upgrade-kit-error
Browse files Browse the repository at this point in the history
Fix upgrade prototype kit error
  • Loading branch information
BenSurgisonGDS authored Jan 26, 2023
2 parents 69814ec + 62276a0 commit 801eee8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
The Task list template has been moved to the new
[Task list plugin](https://github.com/alphagov/govuk-prototype-kit-task-list)

### Fixes

- [#1935: Fix upgrade prototype kit error](https://github.com/alphagov/govuk-prototype-kit/pull/1935)

## 13.2.2

### Fixes
Expand Down
4 changes: 2 additions & 2 deletions lib/manage-prototype-handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,8 @@ async function postPluginsStatusHandler (req, res) {
let status = 'processing'
try {
const chosenPlugin = await getPluginForRequest(req)
if (!chosenPlugin && mode !== 'uninstall') {
status = 'error'
if (chosenPlugin && modeIsComplete(mode, chosenPlugin)) {
status = 'completed'
}
} catch (e) {
if (mode !== 'uninstall') {
Expand Down
16 changes: 12 additions & 4 deletions lib/manage-prototype-handlers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jest.mock('fs-extra', () => {
exists: jest.fn().mockResolvedValue(true),
existsSync: jest.fn().mockReturnValue(true),
pathExistsSync: jest.fn().mockReturnValue(true),
readJson: jest.fn().mockResolvedValue({}),
readJsonSync: jest.fn().mockReturnValue({})
}
})
Expand Down Expand Up @@ -401,10 +402,17 @@ describe('manage-prototype-handlers', () => {
describe('postPluginsStatusHandler', () => {
beforeEach(() => {
req.params.mode = 'install'
req.query.package = packageName
const pkg = {
name: packageName,
version: latestVersion,
dependencies: { [packageName]: latestVersion }
}
fse.readJson.mockResolvedValue(pkg)
fse.readJsonSync.mockReturnValue(pkg)
})

it('is processing', async () => {
req.query.package = packageName
await postPluginsStatusHandler(req, res)
expect(res.json).toHaveBeenCalledWith(
expect.objectContaining({
Expand All @@ -413,12 +421,12 @@ describe('manage-prototype-handlers', () => {
)
})

it('is in error', async () => {
req.query.package = 'invalid-package'
it('is complete', async () => {
plugins.listInstalledPlugins.mockReturnValue([packageName])
await postPluginsStatusHandler(req, res)
expect(res.json).toHaveBeenCalledWith(
expect.objectContaining({
status: 'error'
status: 'completed'
})
)
})
Expand Down

0 comments on commit 801eee8

Please sign in to comment.