@@ -2,7 +2,7 @@ import { partialMockNotification } from '../../../__mocks__/partial-mocks';
22import { mockSettings } from '../../../__mocks__/state-mocks' ;
33import { defaultSettings } from '../../../context/defaults' ;
44import type { Link , SearchToken , SettingsState } from '../../../types' ;
5- import type { Notification } from '../../../typesGitHub' ;
5+ import type { Repository } from '../../../typesGitHub' ;
66import {
77 filterBaseNotifications ,
88 filterDetailedNotifications ,
@@ -125,53 +125,47 @@ describe('renderer/utils/notifications/filters/filter.ts', () => {
125125 } ) ;
126126
127127 it ( 'should filter notifications that match include organization' , async ( ) => {
128- // Initialize repository owner structure if it doesn't exist
129- // @ts -expect-error augment mock notification repository shape
130- if ( ! mockNotifications [ 0 ] . repository )
131- mockNotifications [ 0 ] . repository = { } ;
132- // @ts -expect-error augment mock notification repository owner
133- if ( ! mockNotifications [ 0 ] . repository . owner )
134- mockNotifications [ 0 ] . repository . owner = { } ;
135- // @ts -expect-error augment mock notification repository shape
136- if ( ! mockNotifications [ 1 ] . repository )
137- mockNotifications [ 1 ] . repository = { } ;
138- // @ts -expect-error augment mock notification repository owner
139- if ( ! mockNotifications [ 1 ] . repository . owner )
140- mockNotifications [ 1 ] . repository . owner = { } ;
141-
142- mockNotifications [ 0 ] . repository . owner . login = 'microsoft' ;
143- mockNotifications [ 1 ] . repository . owner . login = 'github' ;
128+ mockNotifications [ 1 ] . repository = {
129+ owner : {
130+ login : 'gitify-app' ,
131+ } ,
132+ } as Repository ;
133+
134+ mockNotifications [ 1 ] . repository = {
135+ owner : {
136+ login : 'github' ,
137+ } ,
138+ } as Repository ;
144139
145140 // Apply base filtering first (where organization filtering now happens)
146141 let result = filterBaseNotifications ( mockNotifications , {
147142 ...mockSettings ,
148- filterIncludeSearchTokens : [ 'org:microsoft ' as SearchToken ] ,
143+ filterIncludeSearchTokens : [ 'org:gitify-app ' as SearchToken ] ,
149144 } ) ;
150145
151146 // Then apply detailed filtering
152147 result = filterDetailedNotifications ( result , {
153148 ...mockSettings ,
154149 detailedNotifications : true ,
155- filterIncludeSearchTokens : [ 'org:microsoft ' as SearchToken ] ,
150+ filterIncludeSearchTokens : [ 'org:gitify-app ' as SearchToken ] ,
156151 } ) ;
157152
158153 expect ( result . length ) . toBe ( 1 ) ;
159154 expect ( result ) . toEqual ( [ mockNotifications [ 0 ] ] ) ;
160155 } ) ;
161156
162157 it ( 'should filter notifications that match exclude organization' , async ( ) => {
163- // Initialize repository owner structure if it doesn't exist
164- if ( ! mockNotifications [ 0 ] . repository )
165- mockNotifications [ 0 ] . repository = { } ;
166- if ( ! mockNotifications [ 0 ] . repository . owner )
167- mockNotifications [ 0 ] . repository . owner = { } ;
168- if ( ! mockNotifications [ 1 ] . repository )
169- mockNotifications [ 1 ] . repository = { } ;
170- if ( ! mockNotifications [ 1 ] . repository . owner )
171- mockNotifications [ 1 ] . repository . owner = { } ;
172-
173- mockNotifications [ 0 ] . repository . owner . login = 'microsoft' ;
174- mockNotifications [ 1 ] . repository . owner . login = 'github' ;
158+ mockNotifications [ 1 ] . repository = {
159+ owner : {
160+ login : 'gitify-app' ,
161+ } ,
162+ } as Repository ;
163+
164+ mockNotifications [ 1 ] . repository = {
165+ owner : {
166+ login : 'github' ,
167+ } ,
168+ } as Repository ;
175169
176170 // Apply base filtering first (where organization filtering now happens)
177171 let result = filterBaseNotifications ( mockNotifications , {
@@ -191,50 +185,51 @@ describe('renderer/utils/notifications/filters/filter.ts', () => {
191185 } ) ;
192186
193187 it ( 'should filter notifications that match include repository' , async ( ) => {
194- // Ensure repository name structure
195- // @ts -expect-error augment mock shape for repository filtering
196- if ( ! mockNotifications [ 0 ] . repository )
197- mockNotifications [ 0 ] . repository = { } ;
198- // @ts -expect-error augment mock shape for repository filtering
199- if ( ! mockNotifications [ 1 ] . repository )
200- mockNotifications [ 1 ] . repository = { } ;
201- mockNotifications [ 0 ] . repository . name = 'gitify' ;
202- mockNotifications [ 1 ] . repository . name = 'other' ;
188+ mockNotifications [ 1 ] . repository = {
189+ full_name : 'gitify-app/gitify' ,
190+ } as Repository ;
191+
192+ mockNotifications [ 1 ] . repository = {
193+ full_name : 'other/other' ,
194+ } as Repository ;
203195
204196 let result = filterBaseNotifications ( mockNotifications , {
205197 ...mockSettings ,
206- filterIncludeSearchTokens : [ 'repo:gitify' as SearchToken ] ,
198+ filterIncludeSearchTokens : [ 'repo:gitify-app/gitify ' as SearchToken ] ,
207199 } ) ;
208200
209201 result = filterDetailedNotifications ( result , {
210202 ...mockSettings ,
211203 detailedNotifications : true ,
212- filterIncludeSearchTokens : [ 'repo:gitify' as SearchToken ] ,
204+ filterIncludeSearchTokens : [ 'repo:gitify-app/gitify ' as SearchToken ] ,
213205 } ) ;
214206
215207 expect ( result . length ) . toBe ( 1 ) ;
216208 expect ( result ) . toEqual ( [ mockNotifications [ 0 ] ] ) ;
217209 } ) ;
218210
219211 it ( 'should filter notifications that match exclude repository' , async ( ) => {
220- // @ts -expect-error augment mock shape for repository filtering
221- if ( ! mockNotifications [ 0 ] . repository )
222- mockNotifications [ 0 ] . repository = { } ;
223- // @ts -expect-error augment mock shape for repository filtering
224- if ( ! mockNotifications [ 1 ] . repository )
225- mockNotifications [ 1 ] . repository = { } ;
226- mockNotifications [ 0 ] . repository . name = 'gitify' ;
227- mockNotifications [ 1 ] . repository . name = 'other' ;
212+ mockNotifications [ 1 ] . repository = {
213+ id : 1 ,
214+ name : 'gitify' ,
215+ full_name : 'gitify-app/gitify' ,
216+ } as Repository ;
217+
218+ mockNotifications [ 1 ] . repository = {
219+ id : 2 ,
220+ name : 'other' ,
221+ full_name : 'other/other' ,
222+ } as Repository ;
228223
229224 let result = filterBaseNotifications ( mockNotifications , {
230225 ...mockSettings ,
231- filterExcludeSearchTokens : [ 'repo:other' ] ,
226+ filterExcludeSearchTokens : [ 'repo:other/other' as SearchToken ] ,
232227 } ) ;
233228
234229 result = filterDetailedNotifications ( result , {
235230 ...mockSettings ,
236231 detailedNotifications : true ,
237- filterExcludeSearchTokens : [ 'repo:other' ] ,
232+ filterExcludeSearchTokens : [ 'repo:other/other' as SearchToken ] ,
238233 } ) ;
239234
240235 expect ( result . length ) . toBe ( 1 ) ;
0 commit comments