mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
4e74fb2694
* Ordering of log entries in the new errors UI * Don't show the expand-collapse widget when not needed; smaller font size in the raw log output * Expose log actions in the log pane. * Use "This project" instead of "Your project" in the new errors UI * Better handling of long log messages; left-ellipsize the file/line number button * Make log location more button-like; add tooltip when needed. * Add a PDF expand button to the toolbar. * Add a stop compilation button to the new compile UI * Use aria-label for button accessible text; improve handling of long filenames in the log location button * Set max-height correctly for the logs pane dropdown * Avoid changing raw logs sizing when expanded and collapsed * Add comment on the solution for right-to-left text and ellipsis * Improve logs pane actions GitOrigin-RevId: 4098d77a9ee6d333644906876b9ff27035b79319
118 lines
3.7 KiB
JavaScript
118 lines
3.7 KiB
JavaScript
import React from 'react'
|
|
import { expect } from 'chai'
|
|
import { screen, render } from '@testing-library/react'
|
|
|
|
import PreviewLogsToggleButton from '../../../../../frontend/js/features/preview/components/preview-logs-toggle-button'
|
|
|
|
describe('<PreviewLogsToggleButton />', function() {
|
|
function renderPreviewLogsToggleButton(
|
|
logsState,
|
|
onToggleLogs,
|
|
showLogs,
|
|
showText
|
|
) {
|
|
if (showText === undefined) showText = true
|
|
render(
|
|
<PreviewLogsToggleButton
|
|
logsState={logsState}
|
|
onToggle={onToggleLogs}
|
|
showLogs={showLogs}
|
|
showText={showText}
|
|
/>
|
|
)
|
|
}
|
|
|
|
describe('basic toggle functionality', function() {
|
|
const logsState = {
|
|
nErrors: 0,
|
|
nWarnings: 0,
|
|
nLogEntries: 0
|
|
}
|
|
const onToggleLogs = () => {}
|
|
it('should render a view logs button when previewing the PDF', function() {
|
|
const showLogs = false
|
|
renderPreviewLogsToggleButton(logsState, onToggleLogs, showLogs)
|
|
screen.getByText('View logs')
|
|
})
|
|
it('should render a view PDF button when viewing logs', function() {
|
|
const showLogs = true
|
|
renderPreviewLogsToggleButton(logsState, onToggleLogs, showLogs)
|
|
screen.getByText('View PDF')
|
|
})
|
|
})
|
|
describe('compile status indicator', function() {
|
|
const showLogs = false
|
|
const onToggleLogs = () => {}
|
|
it('should render a view logs button by default', function() {
|
|
const logsState = {
|
|
nErrors: 0,
|
|
nWarnings: 0,
|
|
nLogEntries: 0
|
|
}
|
|
renderPreviewLogsToggleButton(logsState, onToggleLogs, showLogs)
|
|
screen.getByText('View logs')
|
|
})
|
|
|
|
it('should render an error status message when there are errors', function() {
|
|
const logsState = {
|
|
nErrors: 1,
|
|
nWarnings: 0,
|
|
nLogEntries: 0
|
|
}
|
|
renderPreviewLogsToggleButton(logsState, onToggleLogs, showLogs)
|
|
screen.getByText(`This project has errors (${logsState.nErrors})`)
|
|
})
|
|
|
|
it('should render an error status message when there are both errors and warnings', function() {
|
|
const logsState = {
|
|
nErrors: 1,
|
|
nWarnings: 1,
|
|
nLogEntries: 0
|
|
}
|
|
renderPreviewLogsToggleButton(logsState, onToggleLogs, showLogs)
|
|
screen.getByText(`This project has errors (${logsState.nErrors})`)
|
|
})
|
|
|
|
it('should render a warning status message when there are warnings but no errors', function() {
|
|
const logsState = {
|
|
nErrors: 0,
|
|
nWarnings: 1,
|
|
nLogEntries: 0
|
|
}
|
|
renderPreviewLogsToggleButton(logsState, onToggleLogs, showLogs)
|
|
screen.getByText(`View warnings (${logsState.nWarnings})`)
|
|
})
|
|
|
|
it('should render 9+ errors when there are more than nine errors', function() {
|
|
const logsState = {
|
|
nErrors: 10,
|
|
nWarnings: 0,
|
|
nLogEntries: 0
|
|
}
|
|
renderPreviewLogsToggleButton(logsState, onToggleLogs, showLogs)
|
|
screen.getByText('This project has errors (9+)')
|
|
})
|
|
it('should show the button text when prop showText=true', function() {
|
|
const logsState = {
|
|
nErrors: 0,
|
|
nWarnings: 0,
|
|
nLogEntries: 0
|
|
}
|
|
const showText = true
|
|
renderPreviewLogsToggleButton(logsState, onToggleLogs, showLogs, showText)
|
|
expect(screen.getByText('View logs').getAttribute('style')).to.be.null
|
|
})
|
|
it('should not show the button text when prop showText=false', function() {
|
|
const logsState = {
|
|
nErrors: 0,
|
|
nWarnings: 0,
|
|
nLogEntries: 0
|
|
}
|
|
const showText = false
|
|
renderPreviewLogsToggleButton(logsState, onToggleLogs, showLogs, showText)
|
|
expect(screen.getByText('View logs').getAttribute('style')).to.equal(
|
|
'position: absolute; right: -100vw;'
|
|
)
|
|
})
|
|
})
|
|
})
|