|
1 | 1 | import { describe, expect, it } from 'vitest' |
2 | | -import type { UnifiedFlowItem } from '@windsland52/maa-log-parser/types' |
3 | | -import { LogParser } from '@windsland52/maa-log-parser' |
| 2 | +import type { UnifiedFlowItem } from '../shared/types' |
| 3 | +import { LogParser } from '../core/logParser' |
4 | 4 |
|
5 | 5 | const formatTimestamp = (eventIndex: number): string => { |
6 | 6 | const second = Math.floor(eventIndex / 1000) |
@@ -411,6 +411,36 @@ describe('LogParser sub task scoped node aggregation', () => { |
411 | 411 | expect(matchedTasks[0].nodes.length).toBe(1) |
412 | 412 | }) |
413 | 413 |
|
| 414 | + it('deduplicates delayed mirrored cross-source Tasker.Task.Succeeded without creating an empty terminal task', async () => { |
| 415 | + const lines = [ |
| 416 | + makeEventLine(200, 'Tasker.Task.Starting', { task_id: 92, entry: 'MainTask', hash: 'h-main-92', uuid: 'u-main-92' }, { |
| 417 | + processId: 'Px1', |
| 418 | + threadId: 'Tx1', |
| 419 | + }), |
| 420 | + makeEventLine(201, 'Node.PipelineNode.Starting', { task_id: 92, node_id: 9201, name: 'MainNode' }), |
| 421 | + makeEventLine(202, 'Node.PipelineNode.Succeeded', { task_id: 92, node_id: 9201, name: 'MainNode' }), |
| 422 | + makeEventLine(203, 'Tasker.Task.Succeeded', { task_id: 92, entry: 'MainTask', hash: 'h-main-92', uuid: 'u-main-92' }, { |
| 423 | + processId: 'Px1', |
| 424 | + threadId: 'Tx1', |
| 425 | + }), |
| 426 | + makeEventLine(230, 'Tasker.Task.Succeeded', { task_id: 92, entry: 'MainTask', hash: 'h-main-92', uuid: 'u-main-92' }, { |
| 427 | + processId: 'Px2', |
| 428 | + threadId: 'Tx2', |
| 429 | + }), |
| 430 | + ] |
| 431 | + |
| 432 | + const parser = new LogParser() |
| 433 | + await parser.parseFile(lines.join('\n')) |
| 434 | + const tasks = parser.getTasksSnapshot() |
| 435 | + const matchedTasks = tasks.filter(item => item.task_id === 92) |
| 436 | + |
| 437 | + expect(matchedTasks).toHaveLength(1) |
| 438 | + expect(matchedTasks[0]?.status).toBe('succeeded') |
| 439 | + expect(matchedTasks[0]?.nodes).toHaveLength(1) |
| 440 | + expect(matchedTasks[0]?.start_time).toBe('2026-04-06 10:00:00.200') |
| 441 | + expect(matchedTasks[0]?.end_time).toBe('2026-04-06 10:00:00.203') |
| 442 | + }) |
| 443 | + |
414 | 444 | it('keeps same-source duplicate Tasker.Task.Starting as separate task scopes', async () => { |
415 | 445 | const lines = [ |
416 | 446 | makeEventLine(191, 'Tasker.Task.Starting', { task_id: 91, entry: 'MainTask', hash: 'h-main-91', uuid: 'u-main-91' }), |
|
0 commit comments