@@ -60,8 +60,6 @@ import {
6060 UserMarketingCta ,
6161 UserNotification ,
6262 UserPost ,
63- UserState ,
64- UserStateKey ,
6563 UserStreak ,
6664 UserStreakAction ,
6765 UserStreakActionType ,
@@ -103,7 +101,6 @@ import {
103101 notifySourcePrivacyUpdated ,
104102 notifySourceReport ,
105103 notifySquadFeaturedUpdated ,
106- notifySubmissionGrantedAccess ,
107104 notifySubmissionRejected ,
108105 notifyUsernameChanged ,
109106 notifyUserReadmeUpdated ,
@@ -131,7 +128,6 @@ import {
131128import { randomUUID } from 'crypto' ;
132129import { DataSource , Not } from 'typeorm' ;
133130import createOrGetConnection from '../../../src/db' ;
134- import { TypeOrmError } from '../../../src/errors' ;
135131import { SourceMemberRoles } from '../../../src/roles' ;
136132import { CommentReport } from '../../../src/entity/CommentReport' ;
137133import { badUsersFixture , usersFixture } from '../../fixture/user' ;
@@ -216,7 +212,6 @@ jest.mock('../../../src/common', () => ({
216212 notifySourceFeedRemoved : jest . fn ( ) ,
217213 notifySettingsUpdated : jest . fn ( ) ,
218214 notifySubmissionRejected : jest . fn ( ) ,
219- notifySubmissionGrantedAccess : jest . fn ( ) ,
220215 notifyNewPostMention : jest . fn ( ) ,
221216 notifyNewCommentMention : jest . fn ( ) ,
222217 notifyNewNotification : jest . fn ( ) ,
@@ -843,52 +838,6 @@ describe('user', () => {
843838 table : 'user' ,
844839 } ) ,
845840 ) ;
846- const [ state ] = await con . getRepository ( UserState ) . find ( ) ;
847- expect ( state ?. key ) . toEqual ( UserStateKey . CommunityLinkAccess ) ;
848- } ) ;
849-
850- it ( 'should throw an error when creating user state and not related to duplicate entry' , async ( ) => {
851- const after : ChangeObject < ObjectType > = {
852- ...base ,
853- reputation : submissionAccessThreshold ,
854- } ;
855- after . id = '1234567890123456789012345678901234567' ; // 37 characters - exceeds limit
856- try {
857- await expectSuccessfulBackground (
858- worker ,
859- mockChangeMessage < ObjectType > ( {
860- after,
861- before : base ,
862- op : 'u' ,
863- table : 'user' ,
864- } ) ,
865- ) ;
866- expect ( true ) . toBeFalsy ( ) ; // ensure the worker threw an error and not reach this code
867- } catch ( ex ) {
868- const state = await con . getRepository ( UserState ) . find ( ) ;
869- expect ( state . length ) . toEqual ( 0 ) ;
870- expect ( ex . code ) . not . toEqual ( TypeOrmError . DUPLICATE_ENTRY ) ;
871- }
872- } ) ;
873-
874- it ( 'should handle the thrown error when user state already exists' , async ( ) => {
875- const after : ChangeObject < ObjectType > = {
876- ...base ,
877- reputation : submissionAccessThreshold ,
878- } ;
879- const repo = con . getRepository ( UserState ) ;
880- await repo . save ( { userId : '1' , key : UserStateKey . CommunityLinkAccess } ) ;
881- await expectSuccessfulBackground (
882- worker ,
883- mockChangeMessage < ObjectType > ( {
884- after,
885- before : base ,
886- op : 'u' ,
887- table : 'user' ,
888- } ) ,
889- ) ;
890- const state = await con . getRepository ( UserState ) . find ( ) ;
891- expect ( state . length ) . toEqual ( 1 ) ;
892841 } ) ;
893842
894843 it ( 'should call notifyReputationIncrease when the user reputation has increased' , async ( ) => {
@@ -1134,28 +1083,6 @@ describe('user', () => {
11341083 } ) ;
11351084} ) ;
11361085
1137- describe ( 'user_state' , ( ) => {
1138- type ObjectType = UserState ;
1139- it ( 'should notify on user state is created with the right key' , async ( ) => {
1140- await expectSuccessfulBackground (
1141- worker ,
1142- mockChangeMessage < ObjectType > ( {
1143- after : {
1144- userId : defaultUser . id ,
1145- key : UserStateKey . CommunityLinkAccess ,
1146- value : false ,
1147- } ,
1148- op : 'c' ,
1149- table : 'user_state' ,
1150- } ) ,
1151- ) ;
1152- expect ( notifySubmissionGrantedAccess ) . toHaveBeenCalledTimes ( 1 ) ;
1153- expect (
1154- jest . mocked ( notifySubmissionGrantedAccess ) . mock . calls [ 0 ] . slice ( 1 ) ,
1155- ) . toEqual ( [ '1' ] ) ;
1156- } ) ;
1157- } ) ;
1158-
11591086describe ( 'comment mention' , ( ) => {
11601087 type ObjectType = CommentMention ;
11611088 const base : ChangeObject < ObjectType > = {
0 commit comments