@@ -70,6 +70,7 @@ describe('locked documents', () => {
70
70
71
71
describe ( 'list view - collections' , ( ) => {
72
72
let postDoc
73
+ let anotherPostDoc
73
74
let user2
74
75
let lockedDoc
75
76
@@ -78,6 +79,10 @@ describe('locked documents', () => {
78
79
text : 'hello' ,
79
80
} )
80
81
82
+ anotherPostDoc = await createPostDoc ( {
83
+ text : 'another post' ,
84
+ } )
85
+
81
86
user2 = await payload . create ( {
82
87
collection : 'users' ,
83
88
data : {
@@ -114,6 +119,11 @@ describe('locked documents', () => {
114
119
id : postDoc . id ,
115
120
} )
116
121
122
+ await payload . delete ( {
123
+ collection : 'posts' ,
124
+ id : anotherPostDoc . id ,
125
+ } )
126
+
117
127
await payload . delete ( {
118
128
collection : 'users' ,
119
129
id : user2 . id ,
@@ -124,22 +134,37 @@ describe('locked documents', () => {
124
134
await page . goto ( postsUrl . list )
125
135
await page . waitForURL ( postsUrl . list )
126
136
127
- await expect ( page . locator ( '.table .row-1 .locked svg' ) ) . toBeVisible ( )
137
+ await expect ( page . locator ( '.table .row-2 .locked svg' ) ) . toBeVisible ( )
128
138
} )
129
139
130
- test ( 'should show no lock icon on document row if unlocked' , async ( ) => {
140
+ test ( 'should not show lock icon on document row if unlocked' , async ( ) => {
141
+ await page . goto ( postsUrl . list )
142
+ await page . waitForURL ( postsUrl . list )
143
+
144
+ await expect ( page . locator ( '.table .row-3 .checkbox-input__input' ) ) . toBeVisible ( )
145
+ } )
146
+
147
+ test ( 'should not show lock icon on document row if locked by current user' , async ( ) => {
148
+ await page . goto ( postsUrl . edit ( anotherPostDoc . id ) )
149
+ await page . waitForURL ( postsUrl . edit ( anotherPostDoc . id ) )
150
+
151
+ const textInput = page . locator ( '#field-text' )
152
+ await textInput . fill ( 'testing' )
153
+
154
+ await page . reload ( )
155
+
131
156
await page . goto ( postsUrl . list )
132
157
await page . waitForURL ( postsUrl . list )
133
158
134
- await expect ( page . locator ( '.table .row-2 .checkbox-input__input' ) ) . toBeVisible ( )
159
+ await expect ( page . locator ( '.table .row-1 .checkbox-input__input' ) ) . toBeVisible ( )
135
160
} )
136
161
137
162
test ( 'should only allow bulk delete on unlocked documents' , async ( ) => {
138
163
await page . goto ( postsUrl . list )
139
164
await page . locator ( 'input#select-all' ) . check ( )
140
165
await page . locator ( '.delete-documents__toggle' ) . click ( )
141
166
await expect ( page . locator ( '.delete-documents__content p' ) ) . toHaveText (
142
- 'You are about to delete 1 Posts' ,
167
+ 'You are about to delete 2 Posts' ,
143
168
)
144
169
} )
145
170
} )
@@ -744,6 +769,7 @@ describe('locked documents', () => {
744
769
745
770
describe ( 'dashboard - globals' , ( ) => {
746
771
let user2
772
+ let lockedGlobal
747
773
748
774
beforeAll ( async ( ) => {
749
775
user2 = await payload . create ( {
@@ -753,17 +779,8 @@ describe('locked documents', () => {
753
779
password : '1234' ,
754
780
} ,
755
781
} )
756
- } )
757
-
758
- afterAll ( async ( ) => {
759
- await payload . delete ( {
760
- collection : 'users' ,
761
- id : user2 . id ,
762
- } )
763
- } )
764
782
765
- test ( 'should show lock on document card in dashboard view if locked' , async ( ) => {
766
- const lockedGlobal = await payload . create ( {
783
+ lockedGlobal = await payload . create ( {
767
784
collection : lockedDocumentCollection ,
768
785
data : {
769
786
document : undefined ,
@@ -775,23 +792,48 @@ describe('locked documents', () => {
775
792
} ,
776
793
} ,
777
794
} )
795
+ } )
778
796
779
- // eslint-disable-next-line payload/no-wait-function
780
- await wait ( 500 )
797
+ afterAll ( async ( ) => {
798
+ await payload . delete ( {
799
+ collection : 'users' ,
800
+ id : user2 . id ,
801
+ } )
802
+ } )
781
803
804
+ test ( 'should show lock on document card in dashboard view if locked' , async ( ) => {
782
805
await page . goto ( postsUrl . admin )
783
806
await page . waitForURL ( postsUrl . admin )
784
807
785
808
const globalCardList = page . locator ( '.dashboard__group' ) . nth ( 1 )
786
809
await expect ( globalCardList . locator ( '#card-menu .locked svg' ) ) . toBeVisible ( )
810
+ } )
787
811
812
+ test ( 'should not show lock on document card in dashboard view if unlocked' , async ( ) => {
788
813
await payload . delete ( {
789
814
collection : lockedDocumentCollection ,
790
815
id : lockedGlobal . id ,
791
816
} )
817
+
818
+ // eslint-disable-next-line payload/no-wait-function
819
+ await wait ( 500 )
820
+
821
+ await page . goto ( postsUrl . admin )
822
+ await page . waitForURL ( postsUrl . admin )
823
+
824
+ const globalCardList = page . locator ( '.dashboard__group' ) . nth ( 1 )
825
+ await expect ( globalCardList . locator ( '#card-menu .locked' ) ) . toBeHidden ( )
792
826
} )
793
827
794
- test ( 'should show no lock on document card in dashboard view if unlocked' , async ( ) => {
828
+ test ( 'should not show lock on document card in dashboard view if locked by current user' , async ( ) => {
829
+ await page . goto ( postsUrl . edit ( 'menu' ) )
830
+ await page . waitForURL ( postsUrl . edit ( 'menu' ) )
831
+
832
+ const textInput = page . locator ( '#field-text' )
833
+ await textInput . fill ( 'this is a global menu text field' )
834
+
835
+ await page . reload ( )
836
+
795
837
await page . goto ( postsUrl . admin )
796
838
await page . waitForURL ( postsUrl . admin )
797
839
0 commit comments