Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

test: connectors pagination test follows the #8906 resume contract

garrytan901816bda94d
diff --git a/test/persistence-connectors.test.ts b/test/persistence-connectors.test.ts
index feb8014c16..fa18d15ee6 100644
--- a/test/persistence-connectors.test.ts
+++ b/test/persistence-connectors.test.ts
@@ -77,14 +77,16 @@ test('public GitHub sync imports real pages without a Git cursor or filesystem p
}
}), 120_000);
-test('Google pagination failure never advances a checkpoint; tombstones delete only the selected source', async () => withEnv(env, async () => {
+test('Google pagination failure keeps the landed page and resumes at the failed one, never advancing the sync cursor; tombstones delete only the selected source', async () => withEnv(env, async () => {
for (const engine of engines) {
const f = await source(engine, googleConfig);
let fail = true;
let deleted = false;
+ const listed: (string | null)[] = [];
const fetcher = async (url: string) => {
if (url.includes('/settings/sendAs')) return json({ sendAs: [] });
const u = new URL(url);
+ if (!u.searchParams.has('syncToken') && u.pathname.endsWith('/connections')) listed.push(u.searchParams.get('pageToken'));
if (u.searchParams.has('syncToken')) return json({ connections: deleted ? [{ resourceName: 'people/first', metadata: { deleted: true } }] : [], nextSyncToken: 'contacts-next' });
if (!u.searchParams.has('pageToken')) return json({ connections: [contact('first', 'First Example')], nextPageToken: 'second' });
if (fail) return json({ error: { message: 'fixture pagination failure' } }, 400);
@@ -92,10 +94,13 @@ test('Google pagination failure never advances a checkpoint; tombstones delete o
};
const cfg = parseGoogleSourceConfig(googleConfig, f.dir);
expect((await runGoogleSync(engine, f.id, cfg, options, withGoogleAccount(fetcher))).status).toBe('partial');
- expect(await sourceCheckpoint(engine, f.id)).toHaveLength(0);
- expect(await engine.executeRaw('SELECT slug FROM pages WHERE source_id=$1', [f.id])).toHaveLength(0);
+ // #8906: the page that landed stays, and the re-list resumes at the page that failed.
+ expect(await engine.executeRaw('SELECT slug FROM pages WHERE source_id=$1', [f.id])).toEqual([{ slug: 'people/first-example' }]);
fail = false;
- expect((await runGoogleSync(engine, f.id, cfg, options, withGoogleAccount(fetcher))).added).toBe(2);
+ listed.length = 0;
+ expect((await runGoogleSync(engine, f.id, cfg, options, withGoogleAccount(fetcher))).added).toBe(1);
+ expect(listed).toEqual(['second']);
+ expect((await engine.executeRaw('SELECT slug FROM pages WHERE source_id=$1 ORDER BY slug', [f.id])).map((r: { slug: string }) => r.slug)).toEqual(['people/first-example', 'people/second-example']);
const other = await source(engine, googleConfig);
expect((await runGoogleSync(engine, other.id, parseGoogleSourceConfig(googleConfig, other.dir), options, withGoogleAccount(fetcher))).added).toBe(2);
deleted = true;