mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-26 21:21:41 +00:00
1a6f3fc256
[web] Fix incorrect error log parsing and imprecise package recommendations GitOrigin-RevId: a0b9c6c51ebf680bb77be88167ab6d35eaa8fa70
81 lines
2.3 KiB
JavaScript
81 lines
2.3 KiB
JavaScript
import { expect } from 'chai'
|
|
import HumanReadableLogs from '../../../../frontend/js/ide/human-readable-logs/HumanReadableLogs'
|
|
import { readFile } from 'fs/promises'
|
|
import { join } from 'path'
|
|
import { some } from 'lodash'
|
|
|
|
const fixturePath = '../../helpers/fixtures/logs/'
|
|
|
|
async function parse(fixtureName) {
|
|
const filePath = join(__dirname, fixturePath, fixtureName)
|
|
const data = await readFile(filePath, 'utf-8', 'r')
|
|
return HumanReadableLogs.parse(data)
|
|
}
|
|
|
|
describe('HumanReadableLogs', function () {
|
|
describe('Undefined commands', function () {
|
|
before(async function () {
|
|
this.errors = (await parse('undefined-control-sequence.log')).errors
|
|
})
|
|
|
|
describe('For unknown commands', function () {
|
|
it('Identifies command at beginning of line', function () {
|
|
expect(
|
|
some(this.errors, {
|
|
line: 3,
|
|
level: 'error',
|
|
message: 'Undefined control sequence.',
|
|
})
|
|
).to.be.true
|
|
})
|
|
it('Identifies command at end of line', function () {
|
|
expect(
|
|
some(this.errors, {
|
|
line: 4,
|
|
level: 'error',
|
|
message: 'Undefined control sequence.',
|
|
})
|
|
).to.be.true
|
|
})
|
|
it('Identifies command inside argument', function () {
|
|
expect(
|
|
some(this.errors, {
|
|
line: 5,
|
|
level: 'error',
|
|
message: 'Undefined control sequence.',
|
|
})
|
|
).to.be.true
|
|
})
|
|
})
|
|
|
|
describe('For known commands', function () {
|
|
it('Identifies command at beginning of line', function () {
|
|
expect(
|
|
some(this.errors, {
|
|
line: 6,
|
|
level: 'error',
|
|
message: 'Is \\usepackage{url} missing?',
|
|
})
|
|
).to.be.true
|
|
})
|
|
it('Identifies command at end of line', function () {
|
|
expect(
|
|
some(this.errors, {
|
|
line: 7,
|
|
level: 'error',
|
|
message: 'Is \\usepackage{amsmath} missing?',
|
|
})
|
|
).to.be.true
|
|
})
|
|
it('Identifies command inside argument', function () {
|
|
expect(
|
|
some(this.errors, {
|
|
line: 8,
|
|
level: 'error',
|
|
message: 'Is \\usepackage{array} missing?',
|
|
})
|
|
).to.be.true
|
|
})
|
|
})
|
|
})
|
|
})
|