Skip to content

Commit 413635b

Browse files
committed
test: update pagination assertions to use canLoadMore in state tests
1 parent 6dd0a13 commit 413635b

14 files changed

+51
-117
lines changed

packages/stream_feeds/test/state/activity_comment_list_test.dart

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ void main() {
5757
body: (tester) async {
5858
// Initial state - has comment
5959
expect(tester.activityCommentListState.comments, hasLength(1));
60+
expect(tester.activityCommentListState.canLoadMore, isTrue);
6061

6162
final nextPageQuery = tester.activityCommentList.query.copyWith(
6263
next: tester.activityCommentListState.pagination?.next,
@@ -70,10 +71,8 @@ void main() {
7071
sort: nextPageQuery.sort,
7172
limit: nextPageQuery.limit,
7273
next: nextPageQuery.next,
73-
prev: nextPageQuery.previous,
7474
),
7575
result: createDefaultCommentsResponse(
76-
prev: 'prev-cursor',
7776
comments: [
7877
createDefaultThreadedCommentResponse(
7978
id: 'comment-test-2',
@@ -96,11 +95,7 @@ void main() {
9695

9796
// Verify state was updated with merged comments
9897
expect(tester.activityCommentListState.comments, hasLength(2));
99-
expect(tester.activityCommentListState.pagination?.next, isNull);
100-
expect(
101-
tester.activityCommentListState.pagination?.previous,
102-
'prev-cursor',
103-
);
98+
expect(tester.activityCommentListState.canLoadMore, isFalse);
10499
},
105100
verify: (tester) {
106101
final nextPageQuery = tester.activityCommentList.query.copyWith(
@@ -115,7 +110,6 @@ void main() {
115110
sort: nextPageQuery.sort,
116111
limit: nextPageQuery.limit,
117112
next: nextPageQuery.next,
118-
prev: nextPageQuery.previous,
119113
),
120114
);
121115
},
@@ -140,7 +134,7 @@ void main() {
140134
body: (tester) async {
141135
// Initial state - has comment but no pagination
142136
expect(tester.activityCommentListState.comments, hasLength(1));
143-
expect(tester.activityCommentListState.pagination?.next, isNull);
137+
expect(tester.activityCommentListState.canLoadMore, isFalse);
144138

145139
// Query more comments (should return empty immediately)
146140
final result = await tester.activityCommentList.queryMoreComments();

packages/stream_feeds/test/state/activity_list_test.dart

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ void main() {
127127
body: (tester) async {
128128
// Initial state - has activity
129129
expect(tester.activityListState.activities, hasLength(1));
130+
expect(tester.activityListState.canLoadMore, isTrue);
130131

131132
final nextPageQuery = tester.activityList.query.copyWith(
132133
next: tester.activityListState.pagination?.next,
@@ -137,7 +138,6 @@ void main() {
137138
queryActivitiesRequest: nextPageQuery.toRequest(),
138139
),
139140
result: createDefaultQueryActivitiesResponse(
140-
prev: 'prev-cursor',
141141
activities: [
142142
createDefaultActivityResponse(id: 'activity-2'),
143143
],
@@ -154,8 +154,7 @@ void main() {
154154

155155
// Verify state was updated with merged activities
156156
expect(tester.activityListState.activities, hasLength(2));
157-
expect(tester.activityListState.pagination?.next, isNull);
158-
expect(tester.activityListState.pagination?.previous, 'prev-cursor');
157+
expect(tester.activityListState.canLoadMore, isFalse);
159158
},
160159
verify: (tester) {
161160
final nextPageQuery = tester.activityList.query.copyWith(
@@ -183,9 +182,7 @@ void main() {
183182
body: (tester) async {
184183
// Initial state - has activity but no pagination
185184
expect(tester.activityListState.activities, hasLength(1));
186-
expect(tester.activityListState.pagination?.next, isNull);
187-
expect(tester.activityListState.pagination?.previous, isNull);
188-
185+
expect(tester.activityListState.canLoadMore, isFalse);
189186
// Query more activities (should return empty immediately)
190187
final result = await tester.activityList.queryMoreActivities();
191188

@@ -195,8 +192,7 @@ void main() {
195192

196193
// Verify state was not updated (no new activities, pagination remains null)
197194
expect(tester.activityListState.activities, hasLength(1));
198-
expect(tester.activityListState.pagination?.next, isNull);
199-
expect(tester.activityListState.pagination?.previous, isNull);
195+
expect(tester.activityListState.canLoadMore, isFalse);
200196
},
201197
);
202198
});

packages/stream_feeds/test/state/activity_reaction_list_test.dart

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ void main() {
5252
body: (tester) async {
5353
// Initial state - has reaction
5454
expect(tester.activityReactionListState.reactions, hasLength(1));
55+
expect(tester.activityReactionListState.canLoadMore, isTrue);
5556

5657
final nextPageQuery = tester.activityReactionList.query.copyWith(
5758
next: tester.activityReactionListState.pagination?.next,
@@ -63,7 +64,6 @@ void main() {
6364
queryActivityReactionsRequest: nextPageQuery.toRequest(),
6465
),
6566
result: createDefaultQueryActivityReactionsResponse(
66-
prev: 'prev-cursor',
6767
reactions: [
6868
createDefaultReactionResponse(
6969
activityId: activityId,
@@ -84,11 +84,7 @@ void main() {
8484

8585
// Verify state was updated with merged reactions
8686
expect(tester.activityReactionListState.reactions, hasLength(2));
87-
expect(tester.activityReactionListState.pagination?.next, isNull);
88-
expect(
89-
tester.activityReactionListState.pagination?.previous,
90-
'prev-cursor',
91-
);
87+
expect(tester.activityReactionListState.canLoadMore, isFalse);
9288
},
9389
verify: (tester) {
9490
final nextPageQuery = tester.activityReactionList.query.copyWith(
@@ -122,7 +118,7 @@ void main() {
122118
body: (tester) async {
123119
// Initial state - has reaction but no pagination
124120
expect(tester.activityReactionListState.reactions, hasLength(1));
125-
expect(tester.activityReactionListState.pagination?.next, isNull);
121+
expect(tester.activityReactionListState.canLoadMore, isFalse);
126122

127123
// Query more reactions (should return empty immediately)
128124
final result = await tester.activityReactionList.queryMoreReactions();

packages/stream_feeds/test/state/activity_test.dart

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ void main() {
4343
body: (tester) async {
4444
// Initial state - has comment
4545
expect(tester.activityState.comments, hasLength(1));
46+
expect(tester.activityState.canLoadMoreComments, isTrue);
4647

4748
tester.mockApi(
4849
(api) => api.getComments(
@@ -52,7 +53,6 @@ void main() {
5253
depth: 3,
5354
),
5455
result: createDefaultCommentsResponse(
55-
prev: 'prev-cursor',
5656
comments: [
5757
createDefaultThreadedCommentResponse(
5858
id: 'comment-2',
@@ -72,11 +72,7 @@ void main() {
7272

7373
// Verify state was updated
7474
expect(tester.activityState.comments, hasLength(2));
75-
expect(tester.activityState.commentsPagination?.next, isNull);
76-
expect(
77-
tester.activityState.commentsPagination?.previous,
78-
'prev-cursor',
79-
);
75+
expect(tester.activityState.canLoadMoreComments, isFalse);
8076
},
8177
verify: (tester) => tester.verifyApi(
8278
(api) => api.getComments(

packages/stream_feeds/test/state/bookmark_folder_list_test.dart

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ void main() {
4242
body: (tester) async {
4343
// Initial state - has folder
4444
expect(tester.bookmarkFolderListState.bookmarkFolders, hasLength(1));
45+
expect(tester.bookmarkFolderListState.canLoadMore, isTrue);
4546

4647
final nextPageQuery = tester.bookmarkFolderList.query.copyWith(
4748
next: tester.bookmarkFolderListState.pagination?.next,
@@ -52,7 +53,6 @@ void main() {
5253
queryBookmarkFoldersRequest: nextPageQuery.toRequest(),
5354
),
5455
result: createDefaultQueryBookmarkFoldersResponse(
55-
prev: 'prev-cursor',
5656
bookmarkFolders: [
5757
createDefaultBookmarkFolderResponse(id: 'folder-2'),
5858
],
@@ -70,11 +70,7 @@ void main() {
7070

7171
// Verify state was updated with merged folders
7272
expect(tester.bookmarkFolderListState.bookmarkFolders, hasLength(2));
73-
expect(tester.bookmarkFolderListState.pagination?.next, isNull);
74-
expect(
75-
tester.bookmarkFolderListState.pagination?.previous,
76-
'prev-cursor',
77-
);
73+
expect(tester.bookmarkFolderListState.canLoadMore, isFalse);
7874
},
7975
verify: (tester) {
8076
final nextPageQuery = tester.bookmarkFolderList.query.copyWith(
@@ -102,9 +98,7 @@ void main() {
10298
body: (tester) async {
10399
// Initial state - has folder but no pagination
104100
expect(tester.bookmarkFolderListState.bookmarkFolders, hasLength(1));
105-
expect(tester.bookmarkFolderListState.pagination?.next, isNull);
106-
expect(tester.bookmarkFolderListState.pagination?.previous, isNull);
107-
101+
expect(tester.bookmarkFolderListState.canLoadMore, isFalse);
108102
// Query more folders (should return empty immediately)
109103
final result =
110104
await tester.bookmarkFolderList.queryMoreBookmarkFolders();
@@ -115,8 +109,7 @@ void main() {
115109

116110
// Verify state was not updated (no new folders, pagination remains null)
117111
expect(tester.bookmarkFolderListState.bookmarkFolders, hasLength(1));
118-
expect(tester.bookmarkFolderListState.pagination?.next, isNull);
119-
expect(tester.bookmarkFolderListState.pagination?.previous, isNull);
112+
expect(tester.bookmarkFolderListState.canLoadMore, isFalse);
120113
},
121114
);
122115
});

packages/stream_feeds/test/state/bookmark_list_test.dart

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ void main() {
4646
body: (tester) async {
4747
// Initial state - has bookmark
4848
expect(tester.bookmarkListState.bookmarks, hasLength(1));
49+
expect(tester.bookmarkListState.canLoadMore, isTrue);
4950

5051
final nextPageQuery = tester.bookmarkList.query.copyWith(
5152
next: tester.bookmarkListState.pagination?.next,
@@ -56,7 +57,6 @@ void main() {
5657
queryBookmarksRequest: nextPageQuery.toRequest(),
5758
),
5859
result: createDefaultQueryBookmarksResponse(
59-
prev: 'prev-cursor',
6060
bookmarks: [
6161
createDefaultBookmarkResponse(
6262
folderId: folderId,
@@ -76,8 +76,7 @@ void main() {
7676

7777
// Verify state was updated with merged bookmarks
7878
expect(tester.bookmarkListState.bookmarks, hasLength(2));
79-
expect(tester.bookmarkListState.pagination?.next, isNull);
80-
expect(tester.bookmarkListState.pagination?.previous, 'prev-cursor');
79+
expect(tester.bookmarkListState.canLoadMore, isFalse);
8180
},
8281
verify: (tester) {
8382
final nextPageQuery = tester.bookmarkList.query.copyWith(
@@ -108,9 +107,7 @@ void main() {
108107
body: (tester) async {
109108
// Initial state - has bookmark but no pagination
110109
expect(tester.bookmarkListState.bookmarks, hasLength(1));
111-
expect(tester.bookmarkListState.pagination?.next, isNull);
112-
expect(tester.bookmarkListState.pagination?.previous, isNull);
113-
110+
expect(tester.bookmarkListState.canLoadMore, isFalse);
114111
// Query more bookmarks (should return empty immediately)
115112
final result = await tester.bookmarkList.queryMoreBookmarks();
116113

@@ -120,8 +117,7 @@ void main() {
120117

121118
// Verify state was not updated (no new bookmarks, pagination remains null)
122119
expect(tester.bookmarkListState.bookmarks, hasLength(1));
123-
expect(tester.bookmarkListState.pagination?.next, isNull);
124-
expect(tester.bookmarkListState.pagination?.previous, isNull);
120+
expect(tester.bookmarkListState.canLoadMore, isFalse);
125121
},
126122
);
127123
});

packages/stream_feeds/test/state/comment_list_test.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ void main() {
4141
body: (tester) async {
4242
// Initial state - has comments
4343
expect(tester.commentListState.comments, hasLength(3));
44+
expect(tester.commentListState.canLoadMore, isTrue);
4445

4546
final nextPageQuery = tester.commentList.query.copyWith(
4647
next: tester.commentListState.pagination?.next,
@@ -51,7 +52,6 @@ void main() {
5152
queryCommentsRequest: nextPageQuery.toRequest(),
5253
),
5354
result: createDefaultQueryCommentsResponse(
54-
prev: 'prev-cursor',
5555
comments: [
5656
createDefaultCommentResponse(id: 'comment-4', objectId: 'obj-1'),
5757
],
@@ -68,8 +68,7 @@ void main() {
6868

6969
// Verify state was updated with merged comments
7070
expect(tester.commentListState.comments, hasLength(4));
71-
expect(tester.commentListState.pagination?.next, isNull);
72-
expect(tester.commentListState.pagination?.previous, 'prev-cursor');
71+
expect(tester.commentListState.canLoadMore, isFalse);
7372
},
7473
verify: (tester) {
7574
final nextPageQuery = tester.commentList.query.copyWith(
@@ -99,7 +98,7 @@ void main() {
9998
body: (tester) async {
10099
// Initial state - has comments, no next cursor
101100
expect(tester.commentListState.comments, hasLength(3));
102-
expect(tester.commentListState.pagination?.next, isNull);
101+
expect(tester.commentListState.canLoadMore, isFalse);
103102

104103
// Query more comments when no next cursor
105104
final result = await tester.commentList.queryMoreComments();

packages/stream_feeds/test/state/comment_reaction_list_test.dart

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ void main() {
4343
body: (tester) async {
4444
// Initial state - has reaction
4545
expect(tester.commentReactionListState.reactions, hasLength(1));
46+
expect(tester.commentReactionListState.canLoadMore, isTrue);
4647

4748
final nextPageQuery = tester.commentReactionList.query.copyWith(
4849
next: tester.commentReactionListState.pagination?.next,
@@ -54,7 +55,6 @@ void main() {
5455
queryCommentReactionsRequest: nextPageQuery.toRequest(),
5556
),
5657
result: createDefaultQueryCommentReactionsResponse(
57-
prev: 'prev-cursor',
5858
reactions: [
5959
createDefaultReactionResponse(
6060
commentId: query.commentId,
@@ -75,11 +75,7 @@ void main() {
7575

7676
// Verify state was updated with merged reactions
7777
expect(tester.commentReactionListState.reactions, hasLength(2));
78-
expect(tester.commentReactionListState.pagination?.next, isNull);
79-
expect(
80-
tester.commentReactionListState.pagination?.previous,
81-
'prev-cursor',
82-
);
78+
expect(tester.commentReactionListState.canLoadMore, isFalse);
8379
},
8480
verify: (tester) {
8581
final nextPageQuery = tester.commentReactionList.query.copyWith(
@@ -111,9 +107,7 @@ void main() {
111107
body: (tester) async {
112108
// Initial state - has reaction but no pagination
113109
expect(tester.commentReactionListState.reactions, hasLength(1));
114-
expect(tester.commentReactionListState.pagination?.next, isNull);
115-
expect(tester.commentReactionListState.pagination?.previous, isNull);
116-
110+
expect(tester.commentReactionListState.canLoadMore, isFalse);
117111
// Query more reactions (should return empty immediately)
118112
final result = await tester.commentReactionList.queryMoreReactions();
119113

@@ -123,8 +117,7 @@ void main() {
123117

124118
// State should remain unchanged
125119
expect(tester.commentReactionListState.reactions, hasLength(1));
126-
expect(tester.commentReactionListState.pagination?.next, isNull);
127-
expect(tester.commentReactionListState.pagination?.previous, isNull);
120+
expect(tester.commentReactionListState.canLoadMore, isFalse);
128121
},
129122
);
130123
});

0 commit comments

Comments
 (0)