File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -339,4 +339,14 @@ describe('Discord Groups Page', () => {
339
339
expect . arrayContaining ( [ 'DSA' , 'DSA-Coding-Group' ] ) ,
340
340
) ;
341
341
} ) ;
342
+
343
+ test ( 'should select the group from URL and have active-group class' , async ( ) => {
344
+ await page . goto ( 'http://localhost:8000/groups?DSA' ) ;
345
+ const activeGroup = await page . $ ( '.active-group' ) ;
346
+ const groupName = await page . evaluate (
347
+ ( element ) => element . innerText ,
348
+ activeGroup ,
349
+ ) ;
350
+ expect ( groupName ) . toMatch ( 'DSA' ) ;
351
+ } ) ;
342
352
} ) ;
Original file line number Diff line number Diff line change @@ -154,6 +154,9 @@ groupRoles?.addEventListener('click', function (event) {
154
154
} ) ;
155
155
const groupListItem = event . target ?. closest ( 'li' ) ;
156
156
if ( groupListItem ) {
157
+ const groupName = `${ groupListItem . querySelector ( 'p' ) . textContent } ` ;
158
+ const newURL = `${ window . location . pathname } ?${ groupName } ` ;
159
+ window . history . pushState ( { } , '' , newURL ) ;
157
160
groupListItem . classList . add ( 'active-group' ) ;
158
161
memberAddRoleBody . roleid = groupListItem . id ;
159
162
if ( IsUserVerified ) {
@@ -349,3 +352,20 @@ createGroupButton.addEventListener('click', async () => {
349
352
location . reload ( ) ;
350
353
} ) ;
351
354
} ) ;
355
+
356
+ /**
357
+ * TO SELECT A GROUP ROLE
358
+ */
359
+
360
+ if ( searchValue ) {
361
+ const groupName = searchValue ;
362
+ const paragraphs = document . querySelectorAll ( 'p' ) ;
363
+
364
+ const groupElement = Array . from ( paragraphs ) . find ( ( paragraph ) =>
365
+ paragraph . textContent . includes ( groupName ) ,
366
+ ) ;
367
+
368
+ if ( groupElement ) {
369
+ groupElement . parentElement . click ( ) ;
370
+ }
371
+ }
You can’t perform that action at this time.
0 commit comments