mirror of
https://github.com/nowcommunity/nowdatabase.git
synced 2026-10-12 19:13:52 +03:00
Revert "Lint fix3"
This commit is contained in:
@@ -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')
|
||||
|
||||
+20
-34
@@ -163,34 +163,21 @@ 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.contains(displayName)
|
||||
cy.contains('C2N-o')
|
||||
cy.contains('C2N-y')
|
||||
cy.get('[id=edit-button]').click()
|
||||
cy.get('[id=sequence-tableselection]').first().click()
|
||||
cy.get('[data-cy=add-button-CalatayudTeruellocalbiozone]').first().click()
|
||||
cy.get('[id=low_bnd-tableselection]').first().click()
|
||||
cy.get('[data-cy=add-button-49]').first().click()
|
||||
|
||||
cy.visit(`/time-unit/${createdSlug}`)
|
||||
cy.contains(displayName)
|
||||
cy.contains('C2N-o')
|
||||
cy.contains('C2N-y')
|
||||
cy.get('[id=edit-button]').click()
|
||||
cy.get('[id=sequence-tableselection]').first().click()
|
||||
cy.get('[data-cy=add-button-CalatayudTeruellocalbiozone]').first().click()
|
||||
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')
|
||||
})
|
||||
cy.addReferenceAndSave()
|
||||
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')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -336,16 +323,15 @@ 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.contains('Creating new time-unit').should('not.exist')
|
||||
cy.get('[id=delete-button]', { timeout: 10000 }).should('be.visible')
|
||||
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')
|
||||
|
||||
Reference in New Issue
Block a user