Revert "Lint fix3"

This commit is contained in:
Kari Lintulaakso
2026-03-23 18:22:09 +02:00
committed by GitHub
parent c42b88c5b9
commit 62db76259c
2 changed files with 28 additions and 59 deletions
+8 -25
View File
@@ -61,11 +61,9 @@ export const validateOccurrencePayload = (payload: EditableOccurrenceData) => {
type RawOccurrenceLogRow = Awaited<ReturnType<typeof logDb.log.findMany>>[number]
type OccurrenceLogCandidate = Omit<RawOccurrenceLogRow, 'luid' | 'suid'> & {
type OccurrenceLogCandidate = RawOccurrenceLogRow & {
pk_data: string
table_name: 'now_ls'
luid: number | null
suid: number | null
}
type OccurrenceLogRow = Omit<OccurrenceLogCandidate, 'luid' | 'suid'> & {
@@ -90,33 +88,15 @@ const collectUniqueIds = (rows: OccurrenceLogRow[], fieldName: 'luid' | 'suid')
return Array.from(ids)
}
const isOccurrenceLogCandidate = (row: RawOccurrenceLogRow): row is OccurrenceLogCandidate =>
row.table_name === 'now_ls' && typeof row.pk_data === 'string'
const normalizeOccurrenceLogRow = (row: OccurrenceLogCandidate): OccurrenceLogRow => ({
...row,
luid: readNumericField(row, 'luid'),
suid: readNumericField(row, 'suid'),
})
const getOccurrenceLogRows = (rows: RawOccurrenceLogRow[], speciesPk: string): OccurrenceLogRow[] => {
const occurrenceRows: OccurrenceLogRow[] = []
for (const row of rows) {
if (row.table_name !== 'now_ls' || typeof row.pk_data !== 'string') continue
if (!row.pk_data.includes(speciesPk)) continue
const occurrenceLogCandidate: OccurrenceLogCandidate = {
...row,
table_name: 'now_ls',
pk_data: row.pk_data,
luid: readNumericField(row, 'luid'),
suid: readNumericField(row, 'suid'),
}
occurrenceRows.push(normalizeOccurrenceLogRow(occurrenceLogCandidate))
}
return occurrenceRows
}
type OccurrenceUpdate = {
occ_date: Date | null
occ_authorizer: string
@@ -187,7 +167,10 @@ const getOccurrenceUpdates = async (lid: number, speciesId: number) => {
},
})
const nowLsLogs = getOccurrenceLogRows(candidateLogsRaw, speciesPk)
const nowLsLogs = candidateLogsRaw
.filter(isOccurrenceLogCandidate)
.filter(logRow => logRow.pk_data.includes(speciesPk))
.map(normalizeOccurrenceLogRow)
const luids = collectUniqueIds(nowLsLogs, 'luid')
const suids = collectUniqueIds(nowLsLogs, 'suid')
+5 -19
View File
@@ -163,15 +163,7 @@ describe('Creating a time unit', () => {
cy.get('[id=low_bnd-tableselection]').first().click()
cy.get('[data-cy=add-button-14]').first().click()
cy.intercept('PUT', '**/time-unit').as('createTimeUnit')
cy.addReferenceAndSave()
cy.wait('@createTimeUnit').then(({ response }) => {
expect(response?.statusCode).to.eq(200)
const createdSlug = response?.body?.tu_name
expect(createdSlug, 'created time unit slug').to.be.a('string')
expect(createdSlug, 'created time unit slug').to.not.equal('')
cy.visit(`/time-unit/${createdSlug}`)
cy.contains(displayName)
cy.contains('C2N-o')
cy.contains('C2N-y')
@@ -181,18 +173,13 @@ describe('Creating a time unit', () => {
cy.get('[id=low_bnd-tableselection]').first().click()
cy.get('[data-cy=add-button-49]').first().click()
cy.intercept('PUT', '**/time-unit').as('updateTimeUnit')
cy.addReferenceAndSave()
cy.wait('@updateTimeUnit').its('response.statusCode').should('eq', 200)
cy.visit(`/time-unit/${createdSlug}`)
cy.contains(displayName)
cy.get('[id=edit-button]').click()
cy.get('[id=sequence-tableselection]').should('have.value', 'Calatayud-Teruel local biozone')
cy.contains('Langhian/Serravallian')
})
})
})
describe('Editing a time unit', () => {
beforeEach('Reset database and login as admin', () => {
@@ -336,17 +323,16 @@ describe('Deleting a time unit', () => {
cy.get('[id=low_bnd-tableselection]').first().click()
cy.get('[data-cy=add-button-14]').first().click()
cy.intercept('PUT', '**/time-unit').as('saveTimeUnitForDelete')
cy.addReferenceAndSave()
cy.wait('@saveTimeUnitForDelete').then(({ response }) => {
expect(response?.statusCode).to.eq(200)
const slug = response?.body?.tu_name
expect(slug, 'time unit slug').to.be.a('string').and.to.have.length.greaterThan(0)
cy.visit(`/time-unit/${slug}`)
cy.location('pathname').should('match', /\/time-unit\/[^/]+$/)
cy.contains('Creating new time-unit').should('not.exist')
cy.get('[id=delete-button]', { timeout: 10000 }).should('be.visible')
cy.url().then(url => {
const slug = new URL(url).pathname.split('/').pop()
expect(slug, 'time unit slug').to.be.a('string').and.to.have.length.greaterThan(0)
const deletePath = `**/time-unit/${slug}`
cy.intercept('DELETE', deletePath).as('deleteTimeUnit')