mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-12 23:35:58 +00:00
revokeBadge also removes selection (#8437)
This commit is contained in:
parent
2fd138697f
commit
2f808f8fcc
@ -524,25 +524,30 @@ describe('Badges', () => {
|
||||
beforeEach(async () => {
|
||||
await regularUser.relateTo(badge, 'rewarded')
|
||||
await regularUser.relateTo(verification, 'verifies')
|
||||
await regularUser.relateTo(badge, 'selected', { slot: 6 })
|
||||
})
|
||||
|
||||
const revokeBadgeMutation = gql`
|
||||
mutation ($badgeId: ID!, $userId: ID!) {
|
||||
revokeBadge(badgeId: $badgeId, userId: $userId) {
|
||||
id
|
||||
badgeTrophies {
|
||||
id
|
||||
}
|
||||
badgeVerification {
|
||||
id
|
||||
isDefault
|
||||
}
|
||||
badgeTrophies {
|
||||
badgeTrophiesSelected {
|
||||
id
|
||||
isDefault
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
describe('check test setup', () => {
|
||||
it('user has one badge', async () => {
|
||||
it('user has one badge and has it selected', async () => {
|
||||
authenticatedUser = regularUser.toJson()
|
||||
const userQuery = gql`
|
||||
{
|
||||
@ -551,11 +556,68 @@ describe('Badges', () => {
|
||||
badgeTrophies {
|
||||
id
|
||||
}
|
||||
badgeVerification {
|
||||
id
|
||||
isDefault
|
||||
}
|
||||
badgeTrophiesSelected {
|
||||
id
|
||||
isDefault
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
const expected = {
|
||||
data: { User: [{ badgeTrophiesCount: 1, badgeTrophies: [{ id: 'trophy_rhino' }] }] },
|
||||
data: {
|
||||
User: [
|
||||
{
|
||||
badgeTrophiesCount: 1,
|
||||
badgeTrophies: [{ id: 'trophy_rhino' }],
|
||||
badgeVerification: {
|
||||
id: 'verification_moderator',
|
||||
isDefault: false,
|
||||
},
|
||||
badgeTrophiesSelected: [
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
{
|
||||
id: 'trophy_rhino',
|
||||
isDefault: false,
|
||||
},
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
errors: undefined,
|
||||
}
|
||||
await expect(query({ query: userQuery })).resolves.toMatchObject(expected)
|
||||
@ -601,6 +663,44 @@ describe('Badges', () => {
|
||||
id: 'regular-user-id',
|
||||
badgeVerification: { id: 'verification_moderator', isDefault: false },
|
||||
badgeTrophies: [],
|
||||
badgeTrophiesSelected: [
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
errors: undefined,
|
||||
@ -615,6 +715,44 @@ describe('Badges', () => {
|
||||
id: 'regular-user-id',
|
||||
badgeVerification: { id: 'verification_moderator', isDefault: false },
|
||||
badgeTrophies: [],
|
||||
badgeTrophiesSelected: [
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
errors: undefined,
|
||||
@ -636,6 +774,44 @@ describe('Badges', () => {
|
||||
id: 'regular-user-id',
|
||||
badgeVerification: { id: 'default_verification', isDefault: true },
|
||||
badgeTrophies: [{ id: 'trophy_rhino' }],
|
||||
badgeTrophiesSelected: [
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
{
|
||||
id: 'trophy_rhino',
|
||||
isDefault: false,
|
||||
},
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
errors: undefined,
|
||||
@ -664,6 +840,44 @@ describe('Badges', () => {
|
||||
id: 'regular-user-id',
|
||||
badgeVerification: { id: 'default_verification', isDefault: true },
|
||||
badgeTrophies: [{ id: 'trophy_rhino' }],
|
||||
badgeTrophiesSelected: [
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
{
|
||||
id: 'trophy_rhino',
|
||||
isDefault: false,
|
||||
},
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
{
|
||||
id: 'default_trophy',
|
||||
isDefault: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
errors: undefined,
|
||||
|
||||
@ -119,8 +119,10 @@ export default {
|
||||
const response = await transaction.run(
|
||||
`
|
||||
MATCH (user:User {id: $userId})
|
||||
OPTIONAL MATCH (badge:Badge {id: $badgeId})-[relation:REWARDED|VERIFIES]->(user)
|
||||
DELETE relation
|
||||
OPTIONAL MATCH (badge:Badge {id: $badgeId})-[rewarded:REWARDED|VERIFIES]->(user)
|
||||
OPTIONAL MATCH (user)-[selected:SELECTED]->(badge)
|
||||
DELETE rewarded
|
||||
DELETE selected
|
||||
RETURN user {.*}
|
||||
`,
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user