@@ -21,7 +21,10 @@ test.describe('OC - Tags Visibility', () => {
2121 let departmentA : Awaited < ReturnType < typeof createDepartment > > ;
2222 let departmentB : Awaited < ReturnType < typeof createDepartment > > ;
2323 let agent : Awaited < ReturnType < typeof createAgent > > ;
24- let tags : Awaited < ReturnType < typeof createTag > > [ ] = [ ] ;
24+ let tagA : Awaited < ReturnType < typeof createTag > > ;
25+ let tagB : Awaited < ReturnType < typeof createTag > > ;
26+ let globalTag : Awaited < ReturnType < typeof createTag > > ;
27+ let sharedTag : Awaited < ReturnType < typeof createTag > > ;
2528
2629 test . beforeAll ( 'Create departments' , async ( { api } ) => {
2730 departmentA = await createDepartment ( api , { name : 'Department A' } ) ;
@@ -40,16 +43,12 @@ test.describe('OC - Tags Visibility', () => {
4043 } ) ;
4144
4245 test . beforeAll ( 'Create tags' , async ( { api } ) => {
43- tags = await Promise . all ( [
44- createTag ( api , { name : 'TagA' , description : 'tag A' , departments : [ departmentA . data . _id ] } ) ,
45- createTag ( api , { name : 'TagB' , description : 'tag B' , departments : [ departmentB . data . _id ] } ) ,
46- createTag ( api , { name : 'GlobalTag' , description : 'public tag' , departments : [ ] } ) ,
47- createTag ( api , {
48- name : 'SharedTag' ,
49- description : 'tag for both departments' ,
50- departments : [ departmentA . data . _id , departmentB . data . _id ] ,
51- } ) ,
52- ] ) ;
46+ tagA = await createTag ( api , { departments : [ departmentA . data . _id ] } ) ;
47+ tagB = await createTag ( api , { departments : [ departmentB . data . _id ] } ) ;
48+ globalTag = await createTag ( api , { departments : [ ] } ) ;
49+ sharedTag = await createTag ( api , {
50+ departments : [ departmentA . data . _id , departmentB . data . _id ] ,
51+ } ) ;
5352 } ) ;
5453
5554 test . beforeAll ( 'Create conversations' , async ( { api } ) => {
@@ -66,7 +65,7 @@ test.describe('OC - Tags Visibility', () => {
6665
6766 test . afterAll ( async ( ) => {
6867 await Promise . all ( conversations . map ( ( conversation ) => conversation . delete ( ) ) ) ;
69- await Promise . all ( tags . map ( ( tag ) => tag . delete ( ) ) ) ;
68+ await Promise . all ( [ tagA , tagB , globalTag , sharedTag ] . map ( ( tag ) => tag . delete ( ) ) ) ;
7069 await agent . delete ( ) ;
7170 await departmentA . delete ( ) ;
7271 await departmentB . delete ( ) ;
@@ -88,31 +87,31 @@ test.describe('OC - Tags Visibility', () => {
8887 } ) ;
8988
9089 await test . step ( 'Should see TagA (department A specific)' , async ( ) => {
91- await expect ( poOmnichannel . roomInfo . optionTags ( 'TagA' ) ) . toBeVisible ( ) ;
90+ await expect ( poOmnichannel . roomInfo . optionTags ( tagA . data . name ) ) . toBeVisible ( ) ;
9291 } ) ;
9392
9493 await test . step ( 'Should see SharedTag (both departments)' , async ( ) => {
95- await expect ( poOmnichannel . roomInfo . optionTags ( 'SharedTag' ) ) . toBeVisible ( ) ;
94+ await expect ( poOmnichannel . roomInfo . optionTags ( sharedTag . data . name ) ) . toBeVisible ( ) ;
9695 } ) ;
9796
9897 await test . step ( 'Should see Public Tags for all chats (no department restriction)' , async ( ) => {
99- await expect ( poOmnichannel . roomInfo . optionTags ( 'GlobalTag' ) ) . toBeVisible ( ) ;
98+ await expect ( poOmnichannel . roomInfo . optionTags ( globalTag . data . name ) ) . toBeVisible ( ) ;
10099 } ) ;
101100
102101 await test . step ( 'Should not see TagB (department B specific)' , async ( ) => {
103- await expect ( poOmnichannel . roomInfo . optionTags ( 'TagB' ) ) . not . toBeVisible ( ) ;
102+ await expect ( poOmnichannel . roomInfo . optionTags ( tagB . data . name ) ) . not . toBeVisible ( ) ;
104103 } ) ;
105104
106105 await test . step ( 'add tags and save' , async ( ) => {
107- await poOmnichannel . roomInfo . selectTag ( 'TagA' ) ;
108- await poOmnichannel . roomInfo . selectTag ( 'GlobalTag' ) ;
106+ await poOmnichannel . roomInfo . selectTag ( tagA . data . name ) ;
107+ await poOmnichannel . roomInfo . selectTag ( globalTag . data . name ) ;
109108 await poOmnichannel . roomInfo . btnSaveEditRoom . click ( ) ;
110109 } ) ;
111110
112111 await test . step ( 'verify selected tags are displayed under room information' , async ( ) => {
113112 await expect ( poOmnichannel . roomInfo . getLabel ( 'Tags' ) ) . toBeVisible ( ) ;
114- await expect ( poOmnichannel . roomInfo . getTagInfoByLabel ( 'TagA' ) ) . toBeVisible ( ) ;
115- await expect ( poOmnichannel . roomInfo . getTagInfoByLabel ( 'GlobalTag' ) ) . toBeVisible ( ) ;
113+ await expect ( poOmnichannel . roomInfo . getTagInfoByLabel ( tagA . data . name ) ) . toBeVisible ( ) ;
114+ await expect ( poOmnichannel . roomInfo . getTagInfoByLabel ( globalTag . data . name ) ) . toBeVisible ( ) ;
116115 } ) ;
117116 } ) ;
118117
@@ -125,11 +124,11 @@ test.describe('OC - Tags Visibility', () => {
125124 } ) ;
126125
127126 await test . step ( 'Agent associated with DepartmentB should be able to see tags for Department B' , async ( ) => {
128- await expect ( poOmnichannel . roomInfo . optionTags ( 'TagB' ) ) . toBeVisible ( ) ;
127+ await expect ( poOmnichannel . roomInfo . optionTags ( tagB . data . name ) ) . toBeVisible ( ) ;
129128 } ) ;
130129
131130 await test . step ( 'Agent associated with DepartmentB should not be able to see tags for DepartmentA' , async ( ) => {
132- await expect ( poOmnichannel . roomInfo . optionTags ( 'TagA' ) ) . not . toBeVisible ( ) ;
131+ await expect ( poOmnichannel . roomInfo . optionTags ( tagA . data . name ) ) . not . toBeVisible ( ) ;
133132 } ) ;
134133 } ) ;
135134} ) ;
0 commit comments