Files
platforms/apps/user_app/test/data/gas_contracts_test.dart
czl231 3ef33b531d 已完成用户APP首期功能开发
交付用户端首期页面、配套接口、后台资源及测试文档。用户APP构建、静态分析和三个管理后台构建通过;完整测试仍有2项失败,后端模型注释检查未通过,详见交付记录。
2026-09-13 00:57:32 +08:00

49 lines
1.7 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 功能描述合同列表类型、会话隔离及真实状态回归版本1.0.0。
import 'dart:convert';
import 'package:flutter_test/flutter_test.dart';
import 'package:http/http.dart' as http;
import 'package:http/testing.dart';
import 'package:user_app/data/repositories/client_repository.dart';
import 'package:user_app/data/services/api_client.dart';
void main() {
test('合同草稿保持真实状态并拦截跨会话迟到响应', () async {
var token = 'first';
var changeSession = false;
final repo = ClientRepository(
ApiClient(
() => token,
client: MockClient((request) async {
expect(request.url.path.endsWith('/gas/contracts'), isTrue);
if (changeSession) token = 'second';
return http.Response(
jsonEncode({
'code': 0,
'details': [
{
'identity': 'c1',
'contract_no': 'HT1',
'title': '合同',
'terms': '条款',
'contract_status': 0,
'station_name': '气站',
'has_attachment': false,
'signed_at': '0001-01-01T00:00:00Z',
},
],
}),
200,
headers: {'content-type': 'application/json; charset=utf-8'},
);
}),
),
);
final contracts = await repo.gasContracts();
expect(contracts.single.statusName, '草稿');
expect(contracts.single.signedAt, isNull);
expect(contracts.single.stationName, '气站');
changeSession = true;
await expectLater(repo.gasContracts(), throwsA(isA<SessionExpiredException>()));
});
}