Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

test(tasks): align existing list fixtures with teammate attribution

zqchris0ebc2d3e2d84
diff --git a/apps/desktop/src/renderer/__tests__/botGroupLampRendering.test.tsx b/apps/desktop/src/renderer/__tests__/botGroupLampRendering.test.tsx
index 208b4b1722..bb2b0f983c 100644
--- a/apps/desktop/src/renderer/__tests__/botGroupLampRendering.test.tsx
+++ b/apps/desktop/src/renderer/__tests__/botGroupLampRendering.test.tsx
@@ -60,6 +60,7 @@ function props(groupDevice: boolean): ProjectsSectionProps {
unclassified: [], projects: [], dialogues: [], allKnownProjects: [], allProjectKeysForOrder: ['local:known-project'],
bots: [{ botId: 'demo', displayName: 'Demo Bot', avatar: '', avatarColor: '', sessions, latestActivityAt: sessions[0].updatedAt }],
filter: {
+ creators: 'all', creatorOptions: [], toggleCreator: vi.fn(), setCreatorsAll: vi.fn(),
groupBy: 'project', groupDialogue: true, groupDevice, sortBy: 'recency',
projectOrder: 'activity', manualProjectOrder: [], projects: 'all', status: 'active', isFilterActive: false,
projectsAsSet: null, isSessionContentFiltered: false, vendor: 'all', lastActivity: 'all', manualPinnedOrder: [],
diff --git a/apps/desktop/src/renderer/__tests__/onlineDeviceHeaders.test.tsx b/apps/desktop/src/renderer/__tests__/onlineDeviceHeaders.test.tsx
index b1aa7aa81b..a3744eb3f2 100644
--- a/apps/desktop/src/renderer/__tests__/onlineDeviceHeaders.test.tsx
+++ b/apps/desktop/src/renderer/__tests__/onlineDeviceHeaders.test.tsx
@@ -79,6 +79,7 @@ function props(groupDevice: boolean): ProjectsSectionProps {
allProjectKeysForOrder: [],
bots: [],
filter: {
+ creators: 'all', creatorOptions: [], toggleCreator: vi.fn(), setCreatorsAll: vi.fn(),
groupBy: 'project',
groupDialogue: true,
groupDevice,
diff --git a/apps/mobile/src/__tests__/automationGroupPress.test.ts b/apps/mobile/src/__tests__/automationGroupPress.test.ts
index dbfc1ca814..9c022e519c 100644
--- a/apps/mobile/src/__tests__/automationGroupPress.test.ts
+++ b/apps/mobile/src/__tests__/automationGroupPress.test.ts
@@ -12,7 +12,9 @@ const body = source.slice(start, source.indexOf(' return (', start));
const handler = new Function('group', 'statusTarget', 'attention', 'rightStatus', 'groupExpanded',
'selectionMode', 'onPressSelection', 'onOpenSession', 'onToggleAutomationGroup', 'item',
'sharedRole', 't',
- `${body}\nreturn handlePress;`);
+ ts.transpileModule(`${body}\nreturn handlePress;`, {
+ compilerOptions: { target: ts.ScriptTarget.ES2022 },
+ }).outputText);
const translate = (key: string) => key;
const row = (id: string, time: number): RemoteSessionListItem => ({
session: { id, status: 'active', createdAt: new Date(time).toISOString(), updatedAt: new Date(time).toISOString() },
diff --git a/apps/mobile/src/__tests__/orcaCollab.test.ts b/apps/mobile/src/__tests__/orcaCollab.test.ts
index 1a16a4d8bc..43ae940294 100644
--- a/apps/mobile/src/__tests__/orcaCollab.test.ts
+++ b/apps/mobile/src/__tests__/orcaCollab.test.ts
@@ -310,13 +310,19 @@ describe('selectVisibleDeviceSessions', () => {
const detail = ts.createSourceFile('device.tsx', readFileSync(resolve(process.cwd(), 'app/devices/[deviceId].tsx'), 'utf8'), ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);
const names = new Set(['sessions', 'filterCounts', 'sections']);
const declarations: string[] = [];
- function visit(node: ts.Node) {
- if (ts.isVariableDeclaration(node) && ts.isIdentifier(node.name) && names.has(node.name.text) && node.initializer) {
- declarations.push('const ' + node.getText(detail) + ';');
+ // Only the component's derived rows feed its sections. A nested sync read
+ // also calls its response `sessions`; it must not enter this lexical scope.
+ const component = detail.statements.find((node): node is ts.FunctionDeclaration =>
+ ts.isFunctionDeclaration(node) && node.name?.text === 'DeviceDetailScreenContent');
+ if (!component?.body) throw new Error('Missing device detail component');
+ for (const statement of component.body.statements) {
+ if (!ts.isVariableStatement(statement)) continue;
+ for (const node of statement.declarationList.declarations) {
+ if (ts.isIdentifier(node.name) && names.has(node.name.text) && node.initializer) {
+ declarations.push('const ' + node.getText(detail) + ';');
+ }
}
- ts.forEachChild(node, visit);
}
- visit(detail);
const allSessions = [
session({ id: 'lead', orcaRole: 'lead', deviceLinkDeviceId: 'dev-a', workingDir: '/repo/cindy' }),
session({ id: 'worker', orcaRole: 'worker', deviceLinkDeviceId: 'dev-a', workingDir: '/repo/cindy' }),
diff --git a/apps/mobile/src/__tests__/sessionEmptyState.test.ts b/apps/mobile/src/__tests__/sessionEmptyState.test.ts
index dd7ef34fe8..c523b28175 100644
--- a/apps/mobile/src/__tests__/sessionEmptyState.test.ts
+++ b/apps/mobile/src/__tests__/sessionEmptyState.test.ts
@@ -3,6 +3,8 @@ import { resolve } from 'node:path';
import ts from 'typescript';
import * as React from 'react';
import { describe, expect, it, vi } from 'vitest';
+import { getMobileAuthOwner, isMobileAuthOwnerCurrent } from '@/auth/authOwnerGeneration';
+import { readTeammateTasks } from '@/session/readTeammateTasks';
import { resolveEffectiveConnectionError } from '@/components/connectionBannerVisibility';
import {
resolveSessionMessageEmptyState,
@@ -76,7 +78,10 @@ it.each(['resolve', 'reject'])('keeps a new filter pending when the old request
const listQueryScopeRef = { current: firstScope };
let finish!: (rows: unknown[]) => void;
let fail!: (error: Error) => void;
- const invoke = vi.fn(() => new Promise<unknown[]>((yes, no) => { finish = yes; fail = no; }));
+ const invoke = vi.fn((_device: string, channel: string) => channel === 'local-db:sessions:list'
+ ? new Promise<unknown[]>((yes, no) => { finish = yes; fail = no; })
+ : Promise.resolve(channel === 'local-db:history:query'
+ ? { ok: true, sessions: [] } : { collectionId: 'teammates', items: [] }));
const published: unknown[][] = [];
let syncedScope: unknown = null;
let loading = false;
@@ -84,14 +89,20 @@ it.each(['resolve', 'reject'])('keeps a new filter pending when the old request
const compile = (listQueryScope: typeof firstScope) => {
const bindings = {
deviceId: 'mac', deviceName: 'Mac', listQueryScope, listQueryScopeRef,
+ getMobileAuthOwner, isMobileAuthOwnerCurrent, readTeammateTasks,
requestedListFilter: listQueryScope.filter, automationScopeKey: null, statusFilter: listQueryScope.filter,
remoteListStatusFilter: (filter: string) => filter,
LIST_LIMIT: 200, invoke, subscribe: async () => undefined,
withTransientRemoteRetry: (read: () => Promise<unknown>) => read(),
remoteSessionStore: {
+ getHomeSessions: () => [],
captureDeviceSessionListMutationEpoch: () => 0,
isDeviceSessionListMutationEpochCurrent: () => true,
- setDeviceSessions: (_id: string, _name: string, rows: unknown[]) => published.push(rows),
+ // The real store coalesces identical preliminary/final snapshots.
+ // Any stale first publication still reaches the assertion below.
+ setDeviceSessions: (_id: string, _name: string, rows: unknown[]) => {
+ if (JSON.stringify(published.at(-1)) !== JSON.stringify(rows)) published.push(rows);
+ },
},
remoteScheduleEventStore: { clearDeviceMirrorInvalidation: () => undefined },
invalidateOfflineScheduleIndexFailureFor: () => undefined,