Skip to content

Commit

Permalink
Merge branch 'temp-branch' into migrate/3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
harryadel committed Sep 18, 2024
2 parents 7b20671 + 637a7be commit 2ecf8ac
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/testsuite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ jobs:
strategy:
matrix:
meteorRelease:
- '--release 3.0.3'
# Latest version
- '--release 3.0.2'
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -27,6 +26,7 @@ jobs:
run: |
curl https://install.meteor.com | /bin/sh
npm i -g @zodern/mtest
- name: Run Tests
run: |
mtest --package ./ --once ${{ matrix.meteorRelease }}
6 changes: 3 additions & 3 deletions package.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Package.describe({
})

Package.onUse(function (api) {
api.versionsFrom(['3.0.3'])
api.versionsFrom(['3.0.2'])

api.use([
'mongo',
Expand All @@ -29,12 +29,12 @@ Package.onUse(function (api) {
})

Package.onTest(function (api) {
api.versionsFrom(['3.0.3'])
api.versionsFrom(['3.0.2'])

api.use([
'matb33:collection-hooks',
'accounts-base',
'accounts-password@3.0.1',
'accounts-password',
'mongo',
'ddp',
'tinytest',
Expand Down
34 changes: 34 additions & 0 deletions tests/find_after_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,37 @@ Tinytest.addAsync('issue #296 - after insert hook always finds all inserted', as
test.equal(beforeCalled, true)
test.equal(afterCalled, true)
})

Tinytest.addAsync('async find hook - after insert hook always finds all inserted', async function (test, next) {
const collection = new Mongo.Collection(null)

collection.before.find(async (userId, selector) => {
await new Promise(resolve => setTimeout(resolve, 10)) // Simulate async operation
selector.removedAt = { $exists: false }
return true
})

let beforeCalled = false
collection.before.insert(() => {
beforeCalled = true
})

let afterCalled = false
collection.after.insert(() => {
afterCalled = true
})

await collection.insertAsync({ removedAt: new Date() })

// Wait for a short time to ensure async find hook has completed
await new Promise(resolve => setTimeout(resolve, 20))

test.equal(beforeCalled, true)
test.equal(afterCalled, true)

// Verify that the find hook is working
const result = await collection.findOneAsync({})
test.isUndefined(result, 'Document should not be found due to async find hook')

next()
})

0 comments on commit 2ecf8ac

Please sign in to comment.