Skip to content
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
60 changes: 60 additions & 0 deletions extension/src/plots/errors/collect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,66 @@ describe('collectErrors', () => {
expect(errors).toStrictEqual([])
})

it('should correctly handle the cliIdToLabel mapping for removing existing errors', () => {
const errors = collectErrors(
{ data: {} },
[EXPERIMENT_WORKSPACE_ID, 'ff2489c'],
[
{
msg: 'unexpected error',
name: 'fun::plot',
rev: EXPERIMENT_WORKSPACE_ID,
source: 'metrics.json',
type: 'unexpected'
},
{
msg: 'unexpected error',
name: 'fun::plot',
rev: 'main',
source: 'metrics.json',
type: 'unexpected'
}
],
{ [EXPERIMENT_WORKSPACE_ID]: EXPERIMENT_WORKSPACE_ID, ff2489c: 'main' }
)

expect(errors).toStrictEqual([])
})

it('should correctly handle the cliIdToLabel mapping for replacing errors', () => {
const newError = {
msg: 'new error',
name: 'fun::plot',
rev: 'ff2489c',
source: 'metrics.json',
type: 'unexpected'
}

const errors = collectErrors(
{ data: {}, errors: [newError] },
[EXPERIMENT_WORKSPACE_ID, 'ff2489c'],
[
{
msg: 'unexpected error',
name: 'fun::plot',
rev: EXPERIMENT_WORKSPACE_ID,
source: 'metrics.json',
type: 'unexpected'
},
{
msg: 'unexpected error',
name: 'fun::plot',
rev: 'main',
source: 'metrics.json',
type: 'unexpected'
}
],
{ [EXPERIMENT_WORKSPACE_ID]: EXPERIMENT_WORKSPACE_ID, ff2489c: 'main' }
)

expect(errors).toStrictEqual([{ ...newError, rev: 'main' }])
})

it('should collect new errors', () => {
const newError = {
msg: 'Blue screen of death',
Expand Down
6 changes: 4 additions & 2 deletions extension/src/plots/errors/collect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ export const collectErrors = (
errors: PlotError[],
cliIdToLabel: { [id: string]: string }
) => {
const existingErrors = errors.filter(
({ rev }) => !revs.includes(cliIdToLabel[rev] || rev)
const fetchedRevs = new Set(
revs.map((rev: string) => cliIdToLabel[rev] || rev)
)

const existingErrors = errors.filter(({ rev }) => !fetchedRevs.has(rev))
const newErrors = data?.errors || []

return [
Expand Down