|
| 1 | +// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file |
| 2 | +// for details. All rights reserved. Use of this source code is governed by a |
| 3 | +// BSD-style license that can be found in the LICENSE file. |
| 4 | + |
| 5 | +import 'dart:convert'; |
| 6 | + |
| 7 | +import 'package:http/http.dart' as http; |
| 8 | +import 'package:pub_integration/src/fake_test_context_provider.dart'; |
| 9 | +import 'package:pub_integration/src/pub_puppeteer_helpers.dart'; |
| 10 | +import 'package:pub_integration/src/test_browser.dart'; |
| 11 | +import 'package:test/test.dart'; |
| 12 | + |
| 13 | +void main() { |
| 14 | + group('Search with SDK and regular results', () { |
| 15 | + late final TestContextProvider fakeTestScenario; |
| 16 | + |
| 17 | + setUpAll(() async { |
| 18 | + fakeTestScenario = await TestContextProvider.start(); |
| 19 | + }); |
| 20 | + |
| 21 | + tearDownAll(() async { |
| 22 | + await fakeTestScenario.close(); |
| 23 | + }); |
| 24 | + |
| 25 | + test('bulk tests', () async { |
| 26 | + // init server data |
| 27 | + await http.post( |
| 28 | + Uri.parse('${fakeTestScenario.pubHostedUrl}/fake-test-profile'), |
| 29 | + body: json.encode( |
| 30 | + { |
| 31 | + 'testProfile': { |
| 32 | + 'defaultUser': 'admin@pub.dev', |
| 33 | + 'generatedPackages': [ |
| 34 | + {'name': 'json_pkg', 'description': 'Some JSON utility'}, |
| 35 | + ], |
| 36 | + }, |
| 37 | + }, |
| 38 | + ), |
| 39 | + ); |
| 40 | + |
| 41 | + final anon = await fakeTestScenario.createAnonymousTestUser(); |
| 42 | + |
| 43 | + await anon.withBrowserPage((page) async { |
| 44 | + await page.gotoOrigin('/packages?q=json'); |
| 45 | + final info = await listingPageInfo(page); |
| 46 | + expect( |
| 47 | + info.packageNames, |
| 48 | + [ |
| 49 | + 'dart:convert', // SDK package |
| 50 | + 'flutter_driver', // SDK package |
| 51 | + 'json_pkg', // regular package |
| 52 | + ], |
| 53 | + ); |
| 54 | + }); |
| 55 | + }); |
| 56 | + }); |
| 57 | +} |
0 commit comments