Skip to content

Commit

Permalink
chore: Fix metadata test (#839)
Browse files Browse the repository at this point in the history
The new `runId` shows "Not Applicable" for some metadata fields instead
of "--".

Also add a lint exception to allow `continue` (I believe it's the Airbnb
plugin that's disallowing it, but supposedly their company also
disallows loops entirely...) since in this case it reduced nesting, but
lmk if we want to keep it banned.
  • Loading branch information
bchu1 authored Jul 8, 2024
1 parent 4ee7921 commit d9bcaa6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { expect, Page, test } from '@playwright/test'
import { getApolloClient } from 'e2e/apollo'
import { E2E_CONFIG, translations } from 'e2e/constants'
import { goTo } from 'e2e/filters/utils'
import { isArray, isNumber } from 'lodash-es'
import { isArray } from 'lodash-es'

import { TestIds } from 'app/constants/testIds'

Expand Down Expand Up @@ -90,6 +90,7 @@ export function testMetadataDrawer({
const label = translations[key as keyof typeof translations]
const cells = drawer.locator(`tr:has-text("${label}") td`)

// Array:
if (isArray(value)) {
const nodeValue = await cells.last().innerText()
expect(
Expand All @@ -98,17 +99,32 @@ export function testMetadataDrawer({
', ',
)}`,
).toBe(true)
} else if (isNumber(value) || value) {
continue
}
// String or number:
if (value !== null) {
await expect(
cells.last(),
`Test for ${label} to have value ${value}`,
).toContainText(`${value}`)
} else {
continue
}
// Empty because N/A:
if (
data.metadata.groundTruthStatus &&
['groundTruthUsed', 'precision', 'recall'].includes(key)
) {
await expect(
cells.last(),
`Test for ${label} to be empty`,
).toContainText('--')
`Test for ${label} to be "Not Applicable"`,
).toContainText('Not Applicable')
continue
}
// Empty:
await expect(
cells.last(),
`Test for ${label} to be empty`,
).toContainText('--')
}
})
},
Expand Down
3 changes: 3 additions & 0 deletions frontend/packages/eslint-config/typescript.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ module.exports = {
(rule) => rule.selector !== 'ForOfStatement',
),

// Allow use of continue in loops
'no-continue': 'off',

// Sometimes it's safe to call async functions and not handle their errors.
'@typescript-eslint/no-misused-promises': 'off',

Expand Down

0 comments on commit d9bcaa6

Please sign in to comment.