@@ -6,6 +6,7 @@ import 'dart:convert';
66
77import 'package:http/http.dart' as http;
88import 'package:pub_integration/src/fake_test_context_provider.dart' ;
9+ import 'package:pub_integration/src/pub_puppeteer_helpers.dart' ;
910import 'package:pub_integration/src/test_browser.dart' ;
1011import 'package:test/test.dart' ;
1112
@@ -31,13 +32,31 @@ void main() {
3132 'defaultUser' : '[email protected] ' ,
3233 'generatedPackages' : [
3334 {'name' : 'test_pkg' },
35+ {'name' : 'other_pkg' },
3436 ],
3537 },
3638 },
3739 ),
3840 );
3941
4042 final user
= await fakeTestScenario.
createTestUser (email
: '[email protected] ' );
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+ });
4160
4261 await user.withBrowserPage ((page) async {
4362 Future <List <String >> getCountLabels () async {
@@ -53,13 +72,20 @@ void main() {
5372 ];
5473 }
5574
75+ await page.gotoOrigin ('/experimental?my-liked-search=1' );
76+
5677 await page.gotoOrigin ('/packages/test_pkg' );
5778 expect (await getCountLabels (), ['0' , '0' , '' ]);
5879
5980 await page.click ('.like-button-and-label--button' );
6081 await Future .delayed (Duration (seconds: 1 ));
6182 expect (await getCountLabels (), ['1' , '1' , '' ]);
6283
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+
6389 // displaying all three
6490 await page.gotoOrigin ('/packages/test_pkg/score' );
6591 expect (await getCountLabels (), ['1' , '1' , '1' ]);
0 commit comments