Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

do not pass user using async storage in test mode #9166

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/server-core/src/hooks/authenticate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default async (context: HookContext<Application>, next: NextFunction): Pr

// If user param is already stored then we don't need to
// authenticate. This is typically an internal service call.
if (store && store.user) {
if (!config.testEnabled && store && store.user) {
if (!context.params.user) {
context.params.user = store.user
}
Expand Down
153 changes: 79 additions & 74 deletions packages/server-core/src/social/invite/invite.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ describe('invite.service', () => {
})

after(async () => {
// Remove test user
await app.service(userPath).remove(testUser.id)
await destroyEngine()
})
Expand All @@ -97,14 +96,17 @@ describe('invite.service', () => {
const token = `${v1()}@etherealengine.io`
const identityProviderType = 'email'

const createdInvite = await app.service(invitePath).create({
inviteType,
token,
targetObjectId: testLocation.id,
identityProviderType,
deleteOnUse: true,
inviteeId: testUser.id
})
const createdInvite = await app.service(invitePath).create(
{
inviteType,
token,
targetObjectId: testLocation.id,
identityProviderType,
deleteOnUse: true,
inviteeId: testUser.id
},
{ user: testUser }
)

invites.push(createdInvite)

Expand All @@ -118,71 +120,74 @@ describe('invite.service', () => {
})
})

// it('should find invites by searching', async () => {
// const lastInvite = invites.at(-1)!
// const foundInvites = await app.service(invitePath).find({
// query: {
// $or: [
// {
// inviteType: {
// $like: '%' + lastInvite.passcode + '%'
// }
// },
// {
// passcode: {
// $like: '%' + lastInvite.passcode + '%'
// }
// }
// ]
// },
// isInternal: true
// })

// assert.equal(foundInvites.data[0].passcode, lastInvite?.passcode)
// })

// it('should find received invites', async () => {
// const receivedInvites = await app.service(invitePath).find({
// query: {
// action: 'received'
// }
// })

// assert.ok(receivedInvites.total > 0)
// })

// it('should find sent invites', async () => {
// const sentInvites = await app.service(invitePath).find({
// query: {
// action: 'sent'
// }
// })

// assert.ok(sentInvites.total > 0)
// })

// it('should find invites by searching and query action present', async () => {
// const secondLastInvite = invites.at(-2)!
// const foundInvites = await app.service(invitePath).find({
// query: {
// action: 'sent',
// $or: [
// {
// inviteType: {
// $like: '%' + secondLastInvite.passcode + '%'
// }
// },
// {
// passcode: {
// $like: '%' + secondLastInvite.passcode + '%'
// }
// }
// ]
// }
// })

// assert.equal(foundInvites.data[0].passcode, secondLastInvite?.passcode)
// })
it('should find invites by searching', async () => {
const lastInvite = invites.at(-1)!
const foundInvites = await app.service(invitePath).find({
query: {
$or: [
{
inviteType: {
$like: '%' + lastInvite.passcode + '%'
}
},
{
passcode: {
$like: '%' + lastInvite.passcode + '%'
}
}
]
},
isInternal: true
})

assert.equal(foundInvites.data[0].passcode, lastInvite?.passcode)
})

it('should find received invites', async () => {
const receivedInvites = await app.service(invitePath).find({
query: {
action: 'received'
},
user: testUser
})

assert.ok(receivedInvites.total > 0)
})

it('should find sent invites', async () => {
const sentInvites = await app.service(invitePath).find({
query: {
action: 'sent'
},
user: testUser
})

assert.ok(sentInvites.total > 0)
})

it('should find invites by searching and query action present', async () => {
const secondLastInvite = invites.at(-2)!
const foundInvites = await app.service(invitePath).find({
query: {
action: 'sent',
$or: [
{
inviteType: {
$like: '%' + secondLastInvite.passcode + '%'
}
},
{
passcode: {
$like: '%' + secondLastInvite.passcode + '%'
}
}
]
},
user: testUser
})

assert.equal(foundInvites.data[0].passcode, secondLastInvite?.passcode)
})

it('should have "total" in find method', async () => {
const item = await app.service(invitePath).find({ isInternal: true })
Expand Down