Skip to content

Fix statuses validation #1269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/build/src/plugins/child/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const validateShowArgs = function(showArgs) {
}

const validateStringArg = function([key, value]) {
if (typeof value !== 'string' || value.trim() === '') {
if (value !== undefined && (typeof value !== 'string' || value.trim() === '')) {
throw new Error(`"${key}" property must be a non-empty string`)
}
}
Expand Down
67 changes: 44 additions & 23 deletions packages/build/tests/plugins/status/snapshots/tests.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,50 @@ The actual snapshot is saved in `tests.js.snap`.

Generated by [AVA](https://ava.li).

## utils.status.show() allow other fields to be optional

> Snapshot 1

`␊
┌─────────────────────────────┐␊
│ Netlify Build │␊
└─────────────────────────────┘␊
> Version␊
@netlify/build 1.0.0␊
> Flags␊
repositoryRoot: /file/path␊
> Current directory␊
/file/path␊
> Config file␊
/file/path␊
> Resolved config␊
plugins:␊
- package: /file/path␊
> Context␊
production␊
> Loading plugins␊
- /file/path␊
┌────────────────────────────────────┐␊
│ 1. onInit command from /file/path │␊
└────────────────────────────────────┘␊
(/file/path onInit completed in 1ms)␊
┌─────────────────────────────┐␊
│ Netlify Build Complete │␊
└─────────────────────────────┘␊
(Netlify Build completed in 1ms)`

## utils.status.show() argument should be an object

> Snapshot 1
Expand Down Expand Up @@ -587,26 +631,3 @@ Generated by [AVA](https://ava.li).
Error location␊
In "onInit" event in local plugin "/file/path"␊
`

## utils.status.show() argument should be an object

> Snapshot 2

`␊
┌─────────────────────────────┐␊
│ Netlify Build │␊
└─────────────────────────────┘␊
> Version␊
@netlify/build 1.0.0␊
> Flags␊
repositoryRoot: /file/path␊
┌─────────────────────────────┐␊
│ Configuration error │␊
└─────────────────────────────┘␊
Error message␊
Option 'repositoryRoot' points to a non-existing directory: /file/path␊
`
Binary file modified packages/build/tests/plugins/status/snapshots/tests.js.snap
Binary file not shown.
4 changes: 4 additions & 0 deletions packages/build/tests/plugins/status/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ test('utils.status.show() requires a summary', async t => {
await runUtilsStatusShow(t, { title: 'title', text: 'text' })
})

test('utils.status.show() allow other fields to be optional', async t => {
await runUtilsStatusShow(t, { summary: 'summary' })
})

test('utils.status.show() title should be a string', async t => {
await runUtilsStatusShow(t, { title: true, summary: 'summary', text: 'text' })
})
Expand Down