Files
Artemis-Eapil/apps/showcase_ui/src/app/components/agent-stream/agent-stream-selection.spec.ts
T
chenmingxuan be6e8c2abd feat: release 2.2.0 with PC-only tests and execution reliability fixes
Unify task scheduling and queue state, fix Android input and observation recovery, preserve screenshot paths, and match final review criteria accurately. Add collapsible copyable results and publish the complete 2.1.0 upgrade notes. Validation: 3189 backend tests, 326 frontend tests, 24 client tests, production build and quality gates.
2026-10-27 01:13:41 +08:00

59 lines
2.1 KiB
TypeScript

import { provideHttpClient } from '@angular/common/http';
import { provideHttpClientTesting } from '@angular/common/http/testing';
import { TestBed } from '@angular/core/testing';
import { provideRouter } from '@angular/router';
import { AgentStreamComponent } from './agent-stream.component';
describe('action card text selection', () => {
let component: AgentStreamComponent;
let header: HTMLDivElement;
let outside: HTMLDivElement;
beforeEach(() => {
TestBed.configureTestingModule({
providers: [provideHttpClient(), provideHttpClientTesting(), provideRouter([])]
});
component = TestBed.createComponent(AgentStreamComponent).componentInstance;
header = document.createElement('div');
header.textContent = '点击元素 Projects';
header.addEventListener('click', event => component.toggleActionExpanded('action-1', event));
outside = document.createElement('div');
outside.textContent = '其他步骤';
document.body.append(header, outside);
window.getSelection()?.removeAllRanges();
});
afterEach(() => {
window.getSelection()?.removeAllRanges();
header.remove();
outside.remove();
});
function selectText(element: HTMLElement): void {
const range = document.createRange();
range.selectNodeContents(element);
window.getSelection()?.addRange(range);
}
it('keeps selected header text and the expanded card in place for copying', () => {
component.toggleActionExpanded('action-1');
selectText(header);
header.click();
expect(component.isActionExpanded('action-1')).toBeTrue();
expect(window.getSelection()?.toString()).toBe('点击元素 Projects');
});
it('expands and collapses normally without selected text', () => {
header.click();
expect(component.isActionExpanded('action-1')).toBeTrue();
header.click();
expect(component.isActionExpanded('action-1')).toBeFalse();
});
it('allows another card to open while unrelated text is selected', () => {
selectText(outside);
header.click();
expect(component.isActionExpanded('action-1')).toBeTrue();
});
});