diff --git a/lib/core/widgets/paste_type_url_navigation.dart b/lib/core/widgets/paste_type_url_navigation.dart index 919ee5750def5b7ac22260b48fd9ac83179e265c..361728b98142007bf72a04f296e09eaf816915c7 100644 --- a/lib/core/widgets/paste_type_url_navigation.dart +++ b/lib/core/widgets/paste_type_url_navigation.dart @@ -69,7 +69,7 @@ class PasteTypeUrlNavigationModel { query (\$fullPath: ID!, \$iid: String!) { project(fullPath: \$fullPath) { id - nameWithNamespace + fullPath issue(iid: \$iid) { id iid @@ -84,7 +84,7 @@ class PasteTypeUrlNavigationModel { 'issueIid': int.parse(res.body()['data']['project']['issue']['iid']), 'targetId': Id.fromGid(res.body()['data']['project']['issue']['id']).id, 'targetIid': int.parse(res.body()['data']['project']['issue']['iid']), - 'pathWithNamespace': res.body()['data']['project']['nameWithNamespace'], + 'pathWithNamespace': res.body()['data']['project']['fullPath'], 'targetUrl': url, 'showLeading': true }; diff --git a/test/core/widgets/paste_type_url_navigation_test.dart b/test/core/widgets/paste_type_url_navigation_test.dart index fdd61b657b999ee9b16c571ed1765117cabf93cc..53f1e45e02ee82086cb05509e8be5721d7e9ddb0 100644 --- a/test/core/widgets/paste_type_url_navigation_test.dart +++ b/test/core/widgets/paste_type_url_navigation_test.dart @@ -13,11 +13,14 @@ import 'package:jihu_gitlab_app/modules/issues/details/models/issue_details_mode import 'package:jihu_gitlab_app/modules/mr/merge_request_page.dart'; import 'package:jihu_gitlab_app/modules/mr/models/graphql_request_body.dart'; import 'package:jihu_gitlab_app/modules/root/model/root_store.dart'; +import 'package:jihu_gitlab_app/routers.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; import 'package:provider/provider.dart'; +import '../../finder/svg_finder.dart'; import '../../mocker/tester.dart'; +import '../../test_data/issue.dart'; import '../../test_data/merge_request.dart'; import '../net/http_request_test.mocks.dart'; import 'paste_type_url_navigation_test.mocks.dart'; @@ -67,16 +70,17 @@ void main() { }); testWidgets('Should navigate to expect issue details page', (tester) async { - var params = {'projectId': 72936, 'issueId': 3242, 'issueIid': 0, 'targetId': 45345, 'targetIid': 6, 'pathWithNamespace': 'ultimate-plan/jihu-gitlab-app/demo-mr-test'}; when(clipboard.fromClipboard()).thenAnswer((_) => Future(() => 'https://jihulab.com/ultimate-plan/jihu-gitlab-app/jihu-gitlab-app/-/issues/531/')); - when(client.post('/api/graphql', getIssueDetailsGraphQLRequestBody('ultimate-plan/jihu-gitlab-app/demo-mr-test', 6))).thenAnswer((_) => Future(() => Response.of<dynamic>({}))); + when(client.post('/api/graphql', getIssueDetailsGraphQLRequestBody('ultimate-plan/jihu-gitlab-app/demo-mr-test', 531))) + .thenAnswer((_) => Future(() => Response.of<dynamic>(issueDetailsGraphQLResponse))); + when(client.get<List<dynamic>>("/api/v4/projects/59893/issues/531/discussions?page=1&per_page=50")).thenAnswer((_) => Future(() => Response.of<List<dynamic>>([]))); when(client.post('/api/graphql', { "variables": {"fullPath": 'ultimate-plan/jihu-gitlab-app/jihu-gitlab-app', "iid": "531"}, "query": """ query (\$fullPath: ID!, \$iid: String!) { project(fullPath: \$fullPath) { id - nameWithNamespace + fullPath issue(iid: \$iid) { id iid @@ -88,8 +92,8 @@ void main() { "data": { "project": { "id": "gid://gitlab/Project/59893", - "nameWithNamespace": "旗舰版演示 / æžç‹ GitLab App 产å“线 / æžç‹ GitLab APP 代ç ", - "issue": {"id": "gid://gitlab/Issue/299306", "iid": "350"} + "fullPath": "ultimate-plan/jihu-gitlab-app/demo-mr-test", + "issue": {"id": "gid://gitlab/Issue/299306", "iid": "531"} } } }))); @@ -102,7 +106,7 @@ void main() { ChangeNotifierProvider(create: (context) => ConnectionProvider()), ], child: MaterialApp( - routes: {IssueDetailsPage.routeName: (context) => IssueDetailsPage(arguments: params)}, + onGenerateRoute: onGenerateRoute, home: Scaffold( body: PasteTypeUrlNavigation( child: SvgPicture.asset( @@ -121,6 +125,11 @@ void main() { await tester.pump(const Duration(seconds: 1)); } expect(find.byType(IssueDetailsPage), findsOneWidget); + expect(find.text('回å¤è¯„论'), findsOneWidget); + expect(find.text('issue description for test'), findsOneWidget); + expect(SvgFinder("assets/images/comment.svg"), findsOneWidget); + expect(SvgFinder("assets/images/share.svg"), findsOneWidget); + expect(SvgFinder("assets/images/operate.svg"), findsOneWidget); ConnectionProvider().fullReset(); locator.unregister<IssueDetailsModel>(); });