@@ -16,22 +16,26 @@ import (
16
16
"github.com/reearth/reearth/server/pkg/storytelling"
17
17
"github.com/reearth/reearth/server/pkg/visualizer"
18
18
"github.com/reearth/reearthx/account/accountdomain"
19
+ "github.com/reearth/reearthx/account/accountdomain/workspace"
19
20
"github.com/stretchr/testify/assert"
20
21
)
21
22
22
- // go test -v -run TestInternalAPI_GetProjectList ./e2e/...
23
+ // go test -v -run TestInternalAPI_GetProjectList_Owner ./e2e/...
23
24
24
- func TestInternalAPI_GetProjectList (t * testing.T ) {
25
- _ , r , _ := GRPCServer (t , baseSeeder )
25
+ func TestInternalAPI_GetProjectList_Owner (t * testing.T ) {
26
+ _ , r , _ , _ := GRPCServeWithCtx (t , baseSeeder )
26
27
27
28
testDataCount := 20
28
29
testWorkspace2 := wID2 .String ()
29
30
limit := 5
30
31
31
- // user2 call api
32
+ // user2(Owner) call api
32
33
runTestWithUser (t , uID2 .String (), func (client pb.ReEarthVisualizerClient , ctx context.Context ) {
33
34
35
+ //####################################
36
+ // Add TestData for user2 workspace
34
37
SetupTestProjectDatas (t , ctx , r , wID2 , testDataCount )
38
+ //####################################
35
39
36
40
// ASC UpdateAt
37
41
checkGetProjectsASC (t , client , ctx , true ,
@@ -92,7 +96,32 @@ func TestInternalAPI_GetProjectList(t *testing.T) {
92
96
93
97
})
94
98
95
- // user1 call api
99
+ }
100
+
101
+ // go test -v -run TestInternalAPI_GetProjectList_Member ./e2e/...
102
+ func TestInternalAPI_GetProjectList_Member (t * testing.T ) {
103
+ _ , r , _ , ctx := GRPCServeWithCtx (t , baseSeeder )
104
+
105
+ testDataCount := 20
106
+ testWorkspace2 := wID2 .String ()
107
+ limit := 5
108
+
109
+ // user2(Owner) call api
110
+ runTestWithUser (t , uID2 .String (), func (client pb.ReEarthVisualizerClient , ctx context.Context ) {
111
+
112
+ //####################################
113
+ // Add TestData for user2 workspace
114
+ SetupTestProjectDatas (t , ctx , r , wID2 , testDataCount )
115
+ //####################################
116
+
117
+ })
118
+
119
+ // add user1 to workspace2(user2)
120
+ user1 , err := r .User .FindByID (ctx , uID )
121
+ assert .Nil (t , err )
122
+ assert .Nil (t , JoinMembers (ctx , r , wID2 , user1 , workspace .RoleReader , uID2 ))
123
+
124
+ // user1(Member) call api
96
125
runTestWithUser (t , uID .String (), func (client pb.ReEarthVisualizerClient , ctx context.Context ) {
97
126
98
127
// ASC UpdateAt
@@ -103,7 +132,89 @@ func TestInternalAPI_GetProjectList(t *testing.T) {
103
132
Direction : pb .SortDirection_ASC ,
104
133
},
105
134
limit ,
106
- testDataCount , // public and not deleted only
135
+ testDataCount * 4 , // all project
136
+ )
137
+
138
+ // ASC Name
139
+ checkGetProjectsASC (t , client , ctx , true ,
140
+ & testWorkspace2 , // user2 workspace
141
+ & pb.ProjectSort {
142
+ Field : pb .ProjectSortField_NAME ,
143
+ Direction : pb .SortDirection_ASC ,
144
+ },
145
+ limit ,
146
+ testDataCount * 4 , // all project
147
+ )
148
+
149
+ // DESC UpdateAt
150
+ checkGetProjectsDESC (t , client , ctx , true ,
151
+ & testWorkspace2 , // user2 workspace
152
+ & pb.ProjectSort {
153
+ Field : pb .ProjectSortField_UPDATEDAT ,
154
+ Direction : pb .SortDirection_DESC ,
155
+ },
156
+ limit ,
157
+ testDataCount * 4 , // all project
158
+ )
159
+
160
+ // DESC Name
161
+ checkGetProjectsDESC (t , client , ctx , true ,
162
+ & testWorkspace2 , // user2 workspace
163
+ & pb.ProjectSort {
164
+ Field : pb .ProjectSortField_NAME ,
165
+ Direction : pb .SortDirection_DESC ,
166
+ },
167
+ limit ,
168
+ testDataCount * 4 , // all project
169
+ )
170
+
171
+ // keyword search
172
+ keyword := "2"
173
+ checkGetProjectsASCWithKeyword (t , client , ctx , true ,
174
+ & testWorkspace2 , // user2 workspace
175
+ & pb.ProjectSort {
176
+ Field : pb .ProjectSortField_UPDATEDAT ,
177
+ Direction : pb .SortDirection_ASC ,
178
+ },
179
+ & keyword ,
180
+ limit ,
181
+ 26 ,
182
+ )
183
+
184
+ })
185
+
186
+ }
187
+
188
+ // go test -v -run TestInternalAPI_GetProjectList_Anonymous ./e2e/...
189
+ func TestInternalAPI_GetProjectList_Anonymous (t * testing.T ) {
190
+ _ , r , _ , _ := GRPCServeWithCtx (t , baseSeeder )
191
+
192
+ testDataCount := 20
193
+ testWorkspace2 := wID2 .String ()
194
+ limit := 5
195
+
196
+ // user2(Owner) call api
197
+ runTestWithUser (t , uID2 .String (), func (client pb.ReEarthVisualizerClient , ctx context.Context ) {
198
+
199
+ //####################################
200
+ // Add TestData for user2 workspace
201
+ SetupTestProjectDatas (t , ctx , r , wID2 , testDataCount )
202
+ //####################################
203
+
204
+ })
205
+
206
+ // user3(Anonymous) call api
207
+ runTestWithUser (t , uID3 .String (), func (client pb.ReEarthVisualizerClient , ctx context.Context ) {
208
+
209
+ // ASC UpdateAt
210
+ checkGetProjectsASC (t , client , ctx , true ,
211
+ & testWorkspace2 , // user2 workspace
212
+ & pb.ProjectSort {
213
+ Field : pb .ProjectSortField_UPDATEDAT ,
214
+ Direction : pb .SortDirection_ASC ,
215
+ },
216
+ limit ,
217
+ testDataCount * 2 , // public project only
107
218
)
108
219
109
220
// ASC Name
@@ -114,7 +225,7 @@ func TestInternalAPI_GetProjectList(t *testing.T) {
114
225
Direction : pb .SortDirection_ASC ,
115
226
},
116
227
limit ,
117
- testDataCount , // public and not deleted only
228
+ testDataCount * 2 , // public project only
118
229
)
119
230
120
231
// DESC UpdateAt
@@ -125,7 +236,7 @@ func TestInternalAPI_GetProjectList(t *testing.T) {
125
236
Direction : pb .SortDirection_DESC ,
126
237
},
127
238
limit ,
128
- testDataCount , // public and not deleted only
239
+ testDataCount * 2 , // public project only
129
240
)
130
241
131
242
// DESC Name
@@ -136,7 +247,7 @@ func TestInternalAPI_GetProjectList(t *testing.T) {
136
247
Direction : pb .SortDirection_DESC ,
137
248
},
138
249
limit ,
139
- testDataCount , // public and not deleted only
250
+ testDataCount * 2 , // public project only
140
251
)
141
252
142
253
// keyword search
@@ -149,7 +260,7 @@ func TestInternalAPI_GetProjectList(t *testing.T) {
149
260
},
150
261
& keyword ,
151
262
limit ,
152
- 20 ,
263
+ 22 ,
153
264
)
154
265
155
266
})
0 commit comments