Skip to content

Commit

Permalink
Fix checks getting deleted sometimes (#502)
Browse files Browse the repository at this point in the history
* Fix checks getting deleted sometimes

* Wait for flaky test
  • Loading branch information
garrettjstevens authored Dec 19, 2024
1 parent 9927905 commit 66036f5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ export class ChecksService {
doc: FeatureDocument,
checkTimestamps = true,
): Promise<void> {
await this.clearChecksForFeature(doc)
const flatDoc: AnnotationFeatureSnapshot = doc.toObject({
flattenMaps: true,
})
Expand All @@ -103,6 +102,7 @@ export class ChecksService {
if (checkTimestamps && doc.updatedAt && check.updatedAt < doc.updatedAt) {
continue
}
await this.clearChecksForFeature(doc, check.name)
const c = checkRegistry.getCheck(check.name)
if (!c) {
throw new Error(`Check "${check.name}" not registered`)
Expand All @@ -113,7 +113,9 @@ export class ChecksService {
return this.getSequence({ start, end, featureDoc: doc })
},
)
await this.checkResultModel.insertMany(result)
if (result.length > 0) {
await this.checkResultModel.insertMany(result)
}
}
}

Expand All @@ -130,9 +132,9 @@ export class ChecksService {
return this.sequenceService.getSequence({ start, end, refSeq: refSeqId })
}

async clearChecksForFeature(featureDoc: FeatureDocument) {
async clearChecksForFeature(featureDoc: FeatureDocument, checkName: string) {
return this.checkResultModel
.deleteMany({ ids: { $in: featureDoc.allIds } })
.deleteMany({ ids: { $in: featureDoc.allIds }, name: checkName })
.exec()
}

Expand Down
2 changes: 2 additions & 0 deletions packages/jbrowse-plugin-apollo/cypress/e2e/editFeature.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ describe('Different ways of editing features', () => {
})
})
cy.get('body').click(0, 0)
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(5000)

// Check edit is done
cy.reload()
Expand Down

0 comments on commit 66036f5

Please sign in to comment.