@@ -6,6 +6,7 @@ import 'dart:convert';
6
6
7
7
import 'package:http/http.dart' as http;
8
8
import 'package:pub_integration/src/fake_test_context_provider.dart' ;
9
+ import 'package:pub_integration/src/pub_puppeteer_helpers.dart' ;
9
10
import 'package:pub_integration/src/test_browser.dart' ;
10
11
import 'package:test/test.dart' ;
11
12
@@ -31,13 +32,31 @@ void main() {
31
32
'defaultUser' : 'admin@pub.dev' ,
32
33
'generatedPackages' : [
33
34
{'name' : 'test_pkg' },
35
+ {'name' : 'other_pkg' },
34
36
],
35
37
},
36
38
},
37
39
),
38
40
);
39
41
40
42
final user = await fakeTestScenario.createTestUser (email: 'user@pub.dev' );
43
+ final anon = await fakeTestScenario.createAnonymousTestUser ();
44
+
45
+ // checking that regular search returns two packages
46
+ await user.withBrowserPage ((page) async {
47
+ await page.gotoOrigin ('/packages?q=pkg' );
48
+ final info = await listingPageInfo (page);
49
+ expect (info.packageNames.toSet (), {'test_pkg' , 'other_pkg' });
50
+ });
51
+
52
+ // checking that anonymous page request gets an error
53
+ await anon.withBrowserPage ((page) async {
54
+ await page.gotoOrigin ('/experimental?my-liked-search=1' );
55
+ await page.gotoOrigin ('/packages?q=pkg+is:liked-by-me' );
56
+ expect (await page.content, contains ('is only for authenticated users' ));
57
+ final info = await listingPageInfo (page);
58
+ expect (info.packageNames, isEmpty);
59
+ });
41
60
42
61
await user.withBrowserPage ((page) async {
43
62
Future <List <String >> getCountLabels () async {
@@ -53,13 +72,20 @@ void main() {
53
72
];
54
73
}
55
74
75
+ await page.gotoOrigin ('/experimental?my-liked-search=1' );
76
+
56
77
await page.gotoOrigin ('/packages/test_pkg' );
57
78
expect (await getCountLabels (), ['0' , '0' , '' ]);
58
79
59
80
await page.click ('.like-button-and-label--button' );
60
81
await Future .delayed (Duration (seconds: 1 ));
61
82
expect (await getCountLabels (), ['1' , '1' , '' ]);
62
83
84
+ // checking search with my-liked packages
85
+ await page.gotoOrigin ('/packages?q=pkg+is:liked-by-me' );
86
+ final info = await listingPageInfo (page);
87
+ expect (info.packageNames.toSet (), {'test_pkg' });
88
+
63
89
// displaying all three
64
90
await page.gotoOrigin ('/packages/test_pkg/score' );
65
91
expect (await getCountLabels (), ['1' , '1' , '1' ]);
0 commit comments