Revert "Revert "Improve copy for single errors or warnings""

This reverts commit f01e0726b9a0119bc7f8bda3a98c2c0df5026e51.

GitOrigin-RevId: fc44d227e50c46260fbedb8c80fdca24092f81eb
This commit is contained in:
Paulo Jorge Reis
2021-07-07 02:05:40 +00:00
committed by Copybot
parent db8173011e
commit 0ee18df3e4
6 changed files with 50 additions and 16 deletions
@@ -68,12 +68,21 @@ describe('<PreviewLogsToggleButton />', function () {
screen.getByText('Code check failed')
})
it('should render an error status message when there are errors', function () {
it('should render an error status message without a count when there is a single error', function () {
const logsState = {
nErrors: 1,
nWarnings: 0,
}
renderPreviewLogsToggleButton(logsState, onToggleLogs, showLogs)
screen.getByText('This project has an error')
})
it('should render an error status message with a count when there are multiple errors', function () {
const logsState = {
nErrors: 10,
nWarnings: 0,
}
renderPreviewLogsToggleButton(logsState, onToggleLogs, showLogs)
screen.getByText(`This project has errors (${logsState.nErrors})`)
})
@@ -83,15 +92,24 @@ describe('<PreviewLogsToggleButton />', function () {
nWarnings: 1,
}
renderPreviewLogsToggleButton(logsState, onToggleLogs, showLogs)
screen.getByText(`This project has errors (${logsState.nErrors})`)
screen.getByText('This project has an error')
})
it('should render a warning status message when there are warnings but no errors', function () {
it('should render a warning status message without a count when there is a single warning and no errors', function () {
const logsState = {
nErrors: 0,
nWarnings: 1,
}
renderPreviewLogsToggleButton(logsState, onToggleLogs, showLogs)
screen.getByText('View warning')
})
it('should render a warning status message with a count when there are multiple warnings and no errors', function () {
const logsState = {
nErrors: 0,
nWarnings: 10,
}
renderPreviewLogsToggleButton(logsState, onToggleLogs, showLogs)
screen.getByText(`View warnings (${logsState.nWarnings})`)
})
@@ -103,6 +121,7 @@ describe('<PreviewLogsToggleButton />', function () {
renderPreviewLogsToggleButton(logsState, onToggleLogs, showLogs)
screen.getByText('This project has errors (99+)')
})
it('should show the button text when prop showText=true', function () {
const logsState = {
nErrors: 0,