@@ -21,22 +21,19 @@ import { EventEmitter } from "events";
21
21
import * as Matrix from 'matrix-js-sdk/src/matrix' ;
22
22
import FakeTimers from '@sinonjs/fake-timers' ;
23
23
import { mount } from "enzyme" ;
24
+ import * as TestUtils from "react-dom/test-utils" ;
24
25
25
26
import { MatrixClientPeg } from '../../../src/MatrixClientPeg' ;
26
27
import sdk from '../../skinned-sdk' ;
27
28
import SettingsStore from "../../../src/settings/SettingsStore" ;
28
29
import MatrixClientContext from "../../../src/contexts/MatrixClientContext" ;
29
30
import RoomContext from "../../../src/contexts/RoomContext" ;
30
31
import DMRoomMap from "../../../src/utils/DMRoomMap" ;
31
- import { upsertRoomStateEvents } from '../../test-utils' ;
32
-
33
- const TestUtils = require ( 'react-dom/test-utils' ) ;
34
- const expect = require ( 'expect' ) ;
32
+ import { UnwrappedEventTile } from "../../../src/components/views/rooms/EventTile" ;
33
+ import * as TestUtilsMatrix from "../../test-utils" ;
35
34
36
35
const MessagePanel = sdk . getComponent ( 'structures.MessagePanel' ) ;
37
36
38
- const TestUtilsMatrix = require ( '../../test-utils' ) ;
39
-
40
37
let client ;
41
38
const room = new Matrix . Room ( "!roomId:server_name" ) ;
42
39
@@ -288,8 +285,7 @@ describe('MessagePanel', function() {
288
285
) ;
289
286
290
287
// just check we have the right number of tiles for now
291
- const tiles = TestUtils . scryRenderedComponentsWithType (
292
- res , sdk . getComponent ( 'rooms.EventTile' ) ) ;
288
+ const tiles = TestUtils . scryRenderedComponentsWithType ( res , UnwrappedEventTile ) ;
293
289
expect ( tiles . length ) . toEqual ( 10 ) ;
294
290
} ) ;
295
291
@@ -299,9 +295,7 @@ describe('MessagePanel', function() {
299
295
) ;
300
296
301
297
// just check we have the right number of tiles for now
302
- const tiles = TestUtils . scryRenderedComponentsWithType (
303
- res , sdk . getComponent ( 'rooms.EventTile' ) ,
304
- ) ;
298
+ const tiles = TestUtils . scryRenderedComponentsWithType ( res , UnwrappedEventTile ) ;
305
299
expect ( tiles . length ) . toEqual ( 2 ) ;
306
300
307
301
const summaryTiles = TestUtils . scryRenderedComponentsWithType (
@@ -320,8 +314,7 @@ describe('MessagePanel', function() {
320
314
/> ,
321
315
) ;
322
316
323
- const tiles = TestUtils . scryRenderedComponentsWithType (
324
- res , sdk . getComponent ( 'rooms.EventTile' ) ) ;
317
+ const tiles = TestUtils . scryRenderedComponentsWithType ( res , UnwrappedEventTile ) ;
325
318
326
319
// find the <li> which wraps the read marker
327
320
const rm = TestUtils . findRenderedDOMComponentWithClass ( res , 'mx_RoomView_myReadMarker_container' ) ;
@@ -390,8 +383,7 @@ describe('MessagePanel', function() {
390
383
readMarkerVisible = { true }
391
384
/> , parentDiv ) ;
392
385
393
- const tiles = TestUtils . scryRenderedComponentsWithType (
394
- mp , sdk . getComponent ( 'rooms.EventTile' ) ) ;
386
+ const tiles = TestUtils . scryRenderedComponentsWithType ( mp , UnwrappedEventTile ) ;
395
387
const tileContainers = tiles . map ( function ( t ) {
396
388
return ReactDOM . findDOMNode ( t ) ;
397
389
} ) ;
@@ -437,7 +429,7 @@ describe('MessagePanel', function() {
437
429
438
430
it ( 'should collapse creation events' , function ( ) {
439
431
const events = mkCreationEvents ( ) ;
440
- upsertRoomStateEvents ( room , events ) ;
432
+ TestUtilsMatrix . upsertRoomStateEvents ( room , events ) ;
441
433
const res = mount (
442
434
< WrappedMessagePanel className = "cls" events = { events } /> ,
443
435
) ;
@@ -447,23 +439,23 @@ describe('MessagePanel', function() {
447
439
// should be outside of the room creation summary
448
440
// - all other events should be inside the room creation summary
449
441
450
- const tiles = res . find ( sdk . getComponent ( 'views.rooms.EventTile' ) ) ;
442
+ const tiles = res . find ( UnwrappedEventTile ) ;
451
443
452
444
expect ( tiles . at ( 0 ) . props ( ) . mxEvent . getType ( ) ) . toEqual ( "m.room.create" ) ;
453
445
expect ( tiles . at ( 1 ) . props ( ) . mxEvent . getType ( ) ) . toEqual ( "m.room.encryption" ) ;
454
446
455
447
const summaryTiles = res . find ( sdk . getComponent ( 'views.elements.GenericEventListSummary' ) ) ;
456
448
const summaryTile = summaryTiles . at ( 0 ) ;
457
449
458
- const summaryEventTiles = summaryTile . find ( sdk . getComponent ( 'views.rooms.EventTile' ) ) ;
450
+ const summaryEventTiles = summaryTile . find ( UnwrappedEventTile ) ;
459
451
// every event except for the room creation, room encryption, and Bob's
460
452
// invite event should be in the event summary
461
453
expect ( summaryEventTiles . length ) . toEqual ( tiles . length - 3 ) ;
462
454
} ) ;
463
455
464
456
it ( 'should hide read-marker at the end of creation event summary' , function ( ) {
465
457
const events = mkCreationEvents ( ) ;
466
- upsertRoomStateEvents ( room , events ) ;
458
+ TestUtilsMatrix . upsertRoomStateEvents ( room , events ) ;
467
459
const res = mount (
468
460
< WrappedMessagePanel
469
461
className = "cls"
0 commit comments