@@ -9,6 +9,7 @@ import 'dart:async';
9
9
import 'package:test/test.dart' ;
10
10
import 'package:yaml/yaml.dart' ;
11
11
12
+ import 'package:pub_dartlang_org/dartdoc/backend.dart' ;
12
13
import 'package:pub_dartlang_org/frontend/backend.dart' ;
13
14
import 'package:pub_dartlang_org/frontend/handlers_redirects.dart' ;
14
15
import 'package:pub_dartlang_org/frontend/models.dart' ;
@@ -18,6 +19,7 @@ import 'package:pub_dartlang_org/shared/analyzer_client.dart';
18
19
import 'package:pub_dartlang_org/shared/dartdoc_client.dart' ;
19
20
import 'package:pub_dartlang_org/shared/search_service.dart' ;
20
21
22
+ import '../dartdoc/handlers_test.dart' show DartdocBackendMock;
21
23
import '../shared/handlers_test_utils.dart' ;
22
24
import '../shared/utils.dart' ;
23
25
@@ -441,6 +443,56 @@ void main() {
441
443
});
442
444
});
443
445
446
+ group ('/documentation' , () {
447
+ test ('/documentation/flutter redirect' , () async {
448
+ expectRedirectResponse (
449
+ await issueGet ('/documentation/flutter' ),
450
+ 'https://docs.flutter.io/' ,
451
+ );
452
+ });
453
+
454
+ test ('/documentation/flutter/version redirect' , () async {
455
+ expectRedirectResponse (
456
+ await issueGet ('/documentation/flutter/version' ),
457
+ 'https://docs.flutter.io/' ,
458
+ );
459
+ });
460
+
461
+ test ('/documentation/foo/bar redirect' , () async {
462
+ expectRedirectResponse (
463
+ await issueGet ('/documentation/foor/bar' ),
464
+ 'https://pub.dartlang.org/documentation/foor/bar/' ,
465
+ );
466
+ });
467
+
468
+ scopedTest ('trailing slash redirect' , () async {
469
+ expectRedirectResponse (
470
+ await issueGet ('/documentation/foo' ), '/documentation/foo/latest/' );
471
+ });
472
+
473
+ scopedTest ('/documentation/no_pkg redirect' , () async {
474
+ registerDartdocBackend (new DartdocBackendMock ());
475
+ expectRedirectResponse (await issueGet ('/documentation/no_pkg/latest/' ),
476
+ '/packages/no_pkg/versions' );
477
+ });
478
+
479
+ test ('dartdocs.org redirect' , () async {
480
+ expectRedirectResponse (
481
+ await issueGetUri (
482
+ Uri .parse ('https://dartdocs.org/documentation/pkg/latest/' )),
483
+ 'https://pub.dartlang.org/documentation/pkg/latest/' ,
484
+ );
485
+ });
486
+
487
+ test ('www.dartdocs.org redirect' , () async {
488
+ expectRedirectResponse (
489
+ await issueGetUri (
490
+ Uri .parse ('https://www.dartdocs.org/documentation/pkg/latest/' )),
491
+ 'https://pub.dartlang.org/documentation/pkg/latest/' ,
492
+ );
493
+ });
494
+ });
495
+
444
496
group ('old api' , () {
445
497
scopedTest ('/packages.json' , () async {
446
498
final backend =
0 commit comments