@@ -33,18 +33,24 @@ import { editDisplayName } from '../../utils/user';
3333
3434const test = base ;
3535
36- const adminUser = new UserClass ( ) ;
37- const user1 = new UserClass ( ) ;
38- const entity = new TableClass ( ) ;
39- const extraEntity = new TableClass ( ) ;
40- const testPersona = new PersonaClass ( ) ;
41-
4236test . describe ( 'FeedWidget on landing page' , ( ) => {
37+ let adminUser : UserClass ;
38+ let user1 : UserClass ;
39+ let entity : TableClass ;
40+ let extraEntity : TableClass ;
41+ let testPersona : PersonaClass ;
42+
4343 test . beforeAll (
4444 'setup: seed entities, users, create persona, and customize widget' ,
4545 async ( { browser } ) => {
4646 test . slow ( true ) ;
4747
48+ adminUser = new UserClass ( ) ;
49+ user1 = new UserClass ( ) ;
50+ entity = new TableClass ( ) ;
51+ extraEntity = new TableClass ( ) ;
52+ testPersona = new PersonaClass ( ) ;
53+
4854 const { apiContext, afterAction } = await performAdminLogin ( browser ) ;
4955
5056 try {
@@ -369,9 +375,9 @@ test.describe('FeedWidget on landing page', () => {
369375} ) ;
370376
371377test . describe ( 'Mention notifications in Notification Box' , ( ) => {
372- const adminUser = new UserClass ( ) ;
373- const user1 = new UserClass ( ) ;
374- const entity = new TableClass ( ) ;
378+ let adminUser : UserClass ;
379+ let user1 : UserClass ;
380+ let entity : TableClass ;
375381
376382 const test = base . extend < {
377383 adminPage : Page ;
@@ -392,12 +398,26 @@ test.describe('Mention notifications in Notification Box', () => {
392398 } ) ;
393399
394400 test . beforeAll ( 'Setup entities and users' , async ( { browser } ) => {
401+ adminUser = new UserClass ( ) ;
402+ user1 = new UserClass ( ) ;
403+ entity = new TableClass ( ) ;
404+
395405 const { apiContext, afterAction } = await performAdminLogin ( browser ) ;
396406
397407 await adminUser . create ( apiContext ) ;
398408 await adminUser . setAdminRole ( apiContext ) ;
399409 await user1 . create ( apiContext ) ;
400410 await entity . create ( apiContext ) ;
411+
412+ await apiContext . post ( '/api/v1/feed' , {
413+ data : {
414+ from : adminUser . responseData . name ,
415+ message : 'Initial conversation thread for mention test' ,
416+ about : `<#E::table::${ entity . entityResponseData . fullyQualifiedName } >` ,
417+ type : 'Conversation' ,
418+ } ,
419+ } ) ;
420+
401421 await afterAction ( ) ;
402422 } ) ;
403423
@@ -407,60 +427,23 @@ test.describe('Mention notifications in Notification Box', () => {
407427 } ) => {
408428 test . slow ( ) ;
409429
410- await test . step ( 'Admin user creates a conversation on an entity' , async ( ) => {
411- await entity . visitEntityPage ( adminPage ) ;
412- // Added a safety check on waiting for activity feed count to avoid missing feed
413- // Poll the activity feed tab count from the page until it's a valid non-negative number
414- let count = NaN ;
415- const maxRetries = 30 ;
416- for ( let i = 0 ; i < maxRetries && ( isNaN ( count ) || count <= 0 ) ; i ++ ) {
417- const countText = await adminPage
418- . getByRole ( 'tab' , { name : 'Activity Feeds & Tasks' } )
419- . getByTestId ( 'count' )
420- . textContent ( ) ;
421- count = Number ( countText ?? '0' ) ;
422- if ( isNaN ( count ) || count <= 0 ) {
423- await adminPage . reload ( ) ;
424- await waitForAllLoadersToDisappear ( adminPage ) ;
425- }
426- }
427-
428- await adminPage . getByTestId ( 'activity_feed' ) . click ( ) ;
429-
430- await waitForAllLoadersToDisappear ( adminPage ) ;
431-
432- await adminPage . getByTestId ( 'comments-input-field' ) . click ( ) ;
433-
434- await adminPage
435- . locator (
436- '[data-testid="editor-wrapper"] [contenteditable="true"].ql-editor'
437- )
438- . fill ( 'Initial conversation thread for mention test' ) ;
439-
440- await expect (
441- adminPage . locator ( '[data-testid="send-button"]' )
442- ) . toBeVisible ( ) ;
443- await expect (
444- adminPage . locator ( '[data-testid="send-button"]' )
445- ) . not . toBeDisabled ( ) ;
446-
447- const postConversation = adminPage . waitForResponse (
448- ( response ) =>
449- response . url ( ) . includes ( '/api/v1/feed' ) &&
450- response . request ( ) . method ( ) === 'POST' &&
451- response . url ( ) . includes ( '/posts' )
452- ) ;
453- await adminPage . locator ( '[data-testid="send-button"]' ) . click ( ) ;
454- await postConversation ;
455- } ) ;
456-
457430 await test . step ( 'User1 mentions admin user in a reply' , async ( ) => {
458431 await entity . visitEntityPage ( user1Page ) ;
459432
460433 await user1Page . getByTestId ( 'activity_feed' ) . click ( ) ;
461434
462435 await waitForAllLoadersToDisappear ( user1Page ) ;
463436
437+ const seededThread = user1Page
438+ . locator ( '[data-testid="message-container"]' )
439+ . filter ( { hasText : 'Initial conversation thread for mention test' } )
440+ . first ( ) ;
441+
442+ await expect ( seededThread ) . toBeVisible ( { timeout : 30_000 } ) ;
443+ await seededThread . click ( ) ;
444+
445+ await waitForAllLoadersToDisappear ( user1Page ) ;
446+
464447 await user1Page . getByTestId ( 'comments-input-field' ) . click ( ) ;
465448
466449 const editorLocator = user1Page . locator (
@@ -616,15 +599,21 @@ test.describe('Mention notifications in Notification Box', () => {
616599} ) ;
617600
618601test . describe ( 'Mentions: Chinese character encoding in activity feed' , ( ) => {
619- const database = new DatabaseClass ( ) ;
620- const endpointName = `测试Endpoint- ${ uuid ( ) } ` ;
621- const apiEndpoint = new ApiEndpointClass ( undefined , endpointName ) ;
602+ let adminUser : UserClass ;
603+ let database : DatabaseClass ;
604+ let apiEndpoint : ApiEndpointClass ;
622605 let schemaFqn : string ;
623- const userName = `测试- ${ uuid ( ) } ` ;
606+ let userName : string ;
624607
625608 test . beforeAll (
626609 'Create database, schema, and user with Chinese name' ,
627610 async ( { browser } ) => {
611+ adminUser = new UserClass ( ) ;
612+ database = new DatabaseClass ( ) ;
613+ userName = `测试-${ uuid ( ) } ` ;
614+ const endpointName = `测试Endpoint-${ uuid ( ) } ` ;
615+ apiEndpoint = new ApiEndpointClass ( undefined , endpointName ) ;
616+
628617 const { apiContext, afterAction } = await performAdminLogin ( browser ) ;
629618
630619 await database . create ( apiContext ) ;
@@ -798,15 +787,15 @@ test.describe('Mentions: Chinese character encoding in activity feed', () => {
798787 const url = response . url ( ) ;
799788 return (
800789 url . includes ( '/api/v1/search/query' ) &&
801- url . includes ( encodeURIComponent ( endpointName ) )
790+ url . includes ( encodeURIComponent ( apiEndpoint . entity . name ) )
802791 ) ;
803792 } ) ;
804793
805- await editorLocator . pressSequentially ( endpointName ) ;
794+ await editorLocator . pressSequentially ( apiEndpoint . entity . name ) ;
806795 await endpointSuggestionsResponse ;
807796
808797 await page
809- . locator ( `[data-value="#apiEndpoint/${ endpointName } "]` )
798+ . locator ( `[data-value="#apiEndpoint/${ apiEndpoint . entity . name } "]` )
810799 . first ( )
811800 . click ( ) ;
812801
@@ -852,7 +841,7 @@ test.describe('Mentions: Chinese character encoding in activity feed', () => {
852841 await waitForAllLoadersToDisappear ( newPage ) ;
853842
854843 await expect ( newPage . getByTestId ( 'entity-header-display-name' ) ) . toHaveText (
855- endpointName
844+ apiEndpoint . entity . name
856845 ) ;
857846 } ) ;
858847} ) ;
0 commit comments