@@ -761,6 +761,171 @@ describe('Note', () => {
761
761
762
762
assert . strictEqual ( note1 . status , 400 ) ;
763
763
} ) ;
764
+
765
+ test ( 'メンションの数が上限を超えるとエラーになる' , async ( ) => {
766
+ const res = await api ( 'admin/roles/create' , {
767
+ name : 'test' ,
768
+ description : '' ,
769
+ color : null ,
770
+ iconUrl : null ,
771
+ displayOrder : 0 ,
772
+ target : 'manual' ,
773
+ condFormula : { } ,
774
+ isAdministrator : false ,
775
+ isModerator : false ,
776
+ isPublic : false ,
777
+ isExplorable : false ,
778
+ asBadge : false ,
779
+ canEditMembersByModerator : false ,
780
+ policies : {
781
+ mentionLimit : {
782
+ useDefault : false ,
783
+ priority : 1 ,
784
+ value : 0 ,
785
+ } ,
786
+ } ,
787
+ } , alice ) ;
788
+
789
+ assert . strictEqual ( res . status , 200 ) ;
790
+
791
+ await new Promise ( x => setTimeout ( x , 2 ) ) ;
792
+
793
+ const assign = await api ( 'admin/roles/assign' , {
794
+ userId : alice . id ,
795
+ roleId : res . body . id ,
796
+ } , alice ) ;
797
+
798
+ assert . strictEqual ( assign . status , 204 ) ;
799
+
800
+ await new Promise ( x => setTimeout ( x , 2 ) ) ;
801
+
802
+ const note = await api ( '/notes/create' , {
803
+ text : '@bob potentially annoying text' ,
804
+ } , alice ) ;
805
+
806
+ assert . strictEqual ( note . status , 400 ) ;
807
+ assert . strictEqual ( note . body . error . code , 'CONTAINS_TOO_MANY_MENTIONS' ) ;
808
+
809
+ await api ( 'admin/roles/unassign' , {
810
+ userId : alice . id ,
811
+ roleId : res . body . id ,
812
+ } ) ;
813
+
814
+ await api ( 'admin/roles/delete' , {
815
+ roleId : res . body . id ,
816
+ } , alice ) ;
817
+ } ) ;
818
+
819
+ test ( 'ダイレクト投稿もエラーになる' , async ( ) => {
820
+ const res = await api ( 'admin/roles/create' , {
821
+ name : 'test' ,
822
+ description : '' ,
823
+ color : null ,
824
+ iconUrl : null ,
825
+ displayOrder : 0 ,
826
+ target : 'manual' ,
827
+ condFormula : { } ,
828
+ isAdministrator : false ,
829
+ isModerator : false ,
830
+ isPublic : false ,
831
+ isExplorable : false ,
832
+ asBadge : false ,
833
+ canEditMembersByModerator : false ,
834
+ policies : {
835
+ mentionLimit : {
836
+ useDefault : false ,
837
+ priority : 1 ,
838
+ value : 0 ,
839
+ } ,
840
+ } ,
841
+ } , alice ) ;
842
+
843
+ assert . strictEqual ( res . status , 200 ) ;
844
+
845
+ await new Promise ( x => setTimeout ( x , 2 ) ) ;
846
+
847
+ const assign = await api ( 'admin/roles/assign' , {
848
+ userId : alice . id ,
849
+ roleId : res . body . id ,
850
+ } , alice ) ;
851
+
852
+ assert . strictEqual ( assign . status , 204 ) ;
853
+
854
+ await new Promise ( x => setTimeout ( x , 2 ) ) ;
855
+
856
+ const note = await api ( '/notes/create' , {
857
+ text : 'potentially annoying text' ,
858
+ visibility : 'specified' ,
859
+ visibleUserIds : [ bob . id ] ,
860
+ } , alice ) ;
861
+
862
+ assert . strictEqual ( note . status , 400 ) ;
863
+ assert . strictEqual ( note . body . error . code , 'CONTAINS_TOO_MANY_MENTIONS' ) ;
864
+
865
+ await api ( 'admin/roles/unassign' , {
866
+ userId : alice . id ,
867
+ roleId : res . body . id ,
868
+ } ) ;
869
+
870
+ await api ( 'admin/roles/delete' , {
871
+ roleId : res . body . id ,
872
+ } , alice ) ;
873
+ } ) ;
874
+
875
+ test ( 'ダイレクトの宛先とメンションが同じ場合は重複してカウントしない' , async ( ) => {
876
+ const res = await api ( 'admin/roles/create' , {
877
+ name : 'test' ,
878
+ description : '' ,
879
+ color : null ,
880
+ iconUrl : null ,
881
+ displayOrder : 0 ,
882
+ target : 'manual' ,
883
+ condFormula : { } ,
884
+ isAdministrator : false ,
885
+ isModerator : false ,
886
+ isPublic : false ,
887
+ isExplorable : false ,
888
+ asBadge : false ,
889
+ canEditMembersByModerator : false ,
890
+ policies : {
891
+ mentionLimit : {
892
+ useDefault : false ,
893
+ priority : 1 ,
894
+ value : 1 ,
895
+ } ,
896
+ } ,
897
+ } , alice ) ;
898
+
899
+ assert . strictEqual ( res . status , 200 ) ;
900
+
901
+ await new Promise ( x => setTimeout ( x , 2 ) ) ;
902
+
903
+ const assign = await api ( 'admin/roles/assign' , {
904
+ userId : alice . id ,
905
+ roleId : res . body . id ,
906
+ } , alice ) ;
907
+
908
+ assert . strictEqual ( assign . status , 204 ) ;
909
+
910
+ await new Promise ( x => setTimeout ( x , 2 ) ) ;
911
+
912
+ const note = await api ( '/notes/create' , {
913
+ text : '@bob potentially annoying text' ,
914
+ visibility : 'specified' ,
915
+ visibleUserIds : [ bob . id ] ,
916
+ } , alice ) ;
917
+
918
+ assert . strictEqual ( note . status , 200 ) ;
919
+
920
+ await api ( 'admin/roles/unassign' , {
921
+ userId : alice . id ,
922
+ roleId : res . body . id ,
923
+ } ) ;
924
+
925
+ await api ( 'admin/roles/delete' , {
926
+ roleId : res . body . id ,
927
+ } , alice ) ;
928
+ } ) ;
764
929
} ) ;
765
930
766
931
describe ( 'notes/delete' , ( ) => {
0 commit comments