@@ -12,11 +12,6 @@ describe("ManageGoals", function () {
1212
1313 const manageGoalsUrl = "?module=CoreHome&action=index&idSite=1&period=year&date=2009-01-01#?idSite=1&period=year&date=2009-01-01&category=Goals_Goals&subcategory=Goals_ManageGoals" ;
1414
15- async function openManageGoalsPage ( ) {
16- await page . goto ( manageGoalsUrl ) ;
17- await page . waitForNetworkIdle ( ) ;
18- }
19-
2015 async function fillField ( selector , value ) {
2116 await page . $eval ( selector , ( el ) => {
2217 el . value = '' ;
@@ -27,7 +22,9 @@ describe("ManageGoals", function () {
2722 }
2823
2924 it ( "should show correct notification when creating a new goal" , async function ( ) {
30- await openManageGoalsPage ( ) ;
25+ await page . goto ( manageGoalsUrl ) ;
26+ await page . waitForNetworkIdle ( ) ;
27+
3128 await page . waitForSelector ( '#add-goal' ) ;
3229 await page . click ( '#add-goal' ) ;
3330 await page . waitForSelector ( '.addEditGoal' , { visible : true } ) ;
@@ -41,7 +38,17 @@ describe("ManageGoals", function () {
4138
4239 await page . waitForNetworkIdle ( ) ;
4340 expect ( await page . screenshot ( ) ) . to . matchImage ( 'goals_created' ) ;
44- await page . waitForNetworkIdle ( ) ;
41+
42+ // We check that the created goal id is in the View Goal Report url
43+ const createdGoalId = await page . $eval (
44+ 'div.manageGoals table.entityTable tbody tr:last-child td:first-child' ,
45+ ( cell ) => cell . textContent . trim ( )
46+ ) ;
47+ const viewGoalLinkHref = await page . $eval (
48+ '.notification.notification-success a' ,
49+ ( link ) => link . getAttribute ( 'href' )
50+ ) ;
51+ expect ( viewGoalLinkHref ) . to . include ( `subcategory=${ createdGoalId } ` ) ;
4552 } ) ;
4653 it ( "should show the correct notification when editing the goal" , async function ( ) {
4754 const goalEditButtonSelector = 'table.entityTable tbody tr:nth-last-child(1) button.icon-edit' ;
@@ -54,5 +61,16 @@ describe("ManageGoals", function () {
5461 await updateButton . click ( ) ;
5562 await page . waitForNetworkIdle ( ) ;
5663 expect ( await page . screenshot ( ) ) . to . matchImage ( 'goals_updated' ) ;
64+
65+ // We check that the edited goal id is in the View Goal Report url
66+ const editedGoalId = await page . $eval (
67+ 'div.manageGoals table.entityTable tbody tr:last-child td:first-child' ,
68+ ( cell ) => cell . textContent . trim ( )
69+ ) ;
70+ const viewGoalLinkHref = await page . $eval (
71+ '.notification.notification-success a' ,
72+ ( link ) => link . getAttribute ( 'href' )
73+ ) ;
74+ expect ( viewGoalLinkHref ) . to . include ( `subcategory=${ editedGoalId } ` ) ;
5775 } ) ;
5876} ) ;
0 commit comments