Implement tender workflows and dashboard integration
continuous-integration/drone/push Build encountered an error
continuous-integration/drone/push Build encountered an error
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:tm_app/data/services/model/tender_submission/tender_submission.dart';
|
||||
|
||||
void main() {
|
||||
group('TenderSubmissionsResponse', () {
|
||||
test('parses root pagination metadata and a reduced tender payload', () {
|
||||
final response = TenderSubmissionsResponse.fromJson({
|
||||
'success': true,
|
||||
'message': 'Tender submissions retrieved successfully',
|
||||
'data': [
|
||||
{
|
||||
'id': 'submission-1',
|
||||
'tender_id': 'tender-1',
|
||||
'company_id': 'company-1',
|
||||
'customer_id': 'customer-1',
|
||||
'status': 'validating',
|
||||
'stage': 'in_progress',
|
||||
'created_at': 1710000000,
|
||||
'updated_at': 1710003600,
|
||||
'status_history': [
|
||||
{
|
||||
'status': 'validating',
|
||||
'changed_at': 1710003600,
|
||||
'description': 'User accepted tender',
|
||||
},
|
||||
],
|
||||
'tender': {
|
||||
'id': 'tender-1',
|
||||
'title': 'IT Infrastructure Services',
|
||||
'description': 'A reduced tender payload',
|
||||
'submission_deadline': 1714000000,
|
||||
'country_code': 'DE',
|
||||
'status': 'active',
|
||||
},
|
||||
},
|
||||
],
|
||||
'meta': {
|
||||
'total': 42,
|
||||
'limit': 20,
|
||||
'offset': 0,
|
||||
'page': 1,
|
||||
'pages': 3,
|
||||
'has_more': true,
|
||||
},
|
||||
});
|
||||
|
||||
expect(response.success, isTrue);
|
||||
expect(response.data, hasLength(1));
|
||||
expect(response.data.single.status, 'validating');
|
||||
expect(response.data.single.stage, 'in_progress');
|
||||
expect(response.data.single.tender?.title, 'IT Infrastructure Services');
|
||||
expect(response.data.single.statusHistory.single.changedAt, 1710003600);
|
||||
expect(response.meta?.total, 42);
|
||||
expect(response.meta?.hasMore, isTrue);
|
||||
});
|
||||
|
||||
test('keeps a submission when its tender is null', () {
|
||||
final response = TenderSubmissionResponse.fromJson({
|
||||
'success': true,
|
||||
'data': {
|
||||
'id': 'submission-2',
|
||||
'tender_id': 'tender-2',
|
||||
'status': 'not_applied',
|
||||
'stage': 'not_applied',
|
||||
'tender': null,
|
||||
},
|
||||
});
|
||||
|
||||
expect(response.data?.tender, isNull);
|
||||
expect(response.data?.isTerminal, isTrue);
|
||||
});
|
||||
});
|
||||
|
||||
test('parses company stats maps', () {
|
||||
final response = TenderSubmissionStatsResponse.fromJson({
|
||||
'success': true,
|
||||
'data': {
|
||||
'company_id': 'company-1',
|
||||
'total': 15,
|
||||
'by_stage': {'opportunity': 3, 'in_progress': 5},
|
||||
'by_status': {'validating': 2, 'contract': 2},
|
||||
'last_updated': 1710003600,
|
||||
},
|
||||
});
|
||||
|
||||
expect(response.data?.total, 15);
|
||||
expect(response.data?.byStage['in_progress'], 5);
|
||||
expect(response.data?.byStatus['contract'], 2);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user