Skip to content

Open-source agentic AI Search Execution Platform. Track AI visibility, find opportunities, and let agents turn signals into prioritized actions and drafted fixes across ChatGPT, Claude, Gemini, Google AI Overviews, Google AI Mode, Perplexity, Grok, and Microsoft Copilot.

test(server): count a compressed page's cap by what it opens to, and show an inactive workspace's catalog is kept (#1534)

Gökhan Geyik4085418d8723
diff --git a/server/src/lib/catalog/sources.test.js b/server/src/lib/catalog/sources.test.js
index edc474f1e..1270e152c 100644
--- a/server/src/lib/catalog/sources.test.js
+++ b/server/src/lib/catalog/sources.test.js
@@ -355,14 +355,27 @@ describe('sweepCatalogSources', () => {
});
it("keeps a workspace's own catalog for when its subscription is active again", async () => {
+ // The feed was read while the workspace was active.
+ await syncSource(source, {
+ db: fake.db,
+ now: NOW,
+ fetch: async () => ({ html: fixture('google-feed.xml') }),
+ });
+ const before = fake.rows('catalog_products').map((p) => ({ ...p }));
+ expect(before.length).toBeGreaterThan(0);
+
process.env.IS_CLOUD = 'true';
const [first] = fake.rows('catalog_sources');
first.brands = { organizations: { subscription_status: 'past_due' } };
+ first.last_synced_at = null;
+ fake.writes.length = 0;
const fetch = vi.fn();
await sweepCatalogSources({ db: fake.db, now: NOW, fetch });
expect(fetch).not.toHaveBeenCalled();
// Recorded as not read; its products are left as they were, not marked removed.
expect(fake.writes.filter((w) => w.table !== 'catalog_sources')).toEqual([]);
+ expect(fake.rows('catalog_products')).toEqual(before);
+ expect(fake.rows('catalog_products').every((p) => p.removed_at === null)).toBe(true);
});
it('reads stores too, and never an upload', async () => {
diff --git a/server/src/lib/safe-fetch.test.js b/server/src/lib/safe-fetch.test.js
index e537774db..1d735cb0c 100644
--- a/server/src/lib/safe-fetch.test.js
+++ b/server/src/lib/safe-fetch.test.js
@@ -139,6 +139,11 @@ describe('fetchPage against a local site', () => {
res.writeHead(200, { 'content-type': 'text/html' });
res.end('x'.repeat(5_000));
},
+ // Small on the wire, large once opened: the cap counts what's opened.
+ '/big-gzip': (res) => {
+ res.writeHead(200, { 'content-type': 'text/html', 'content-encoding': 'gzip' });
+ res.end(zlib.gzipSync('x'.repeat(50_000)));
+ },
'/slow': (res) => {
setTimeout(() => {
res.writeHead(200, { 'content-type': 'text/html' });
@@ -235,4 +240,14 @@ describe('fetchPage against a local site', () => {
html: '<h1>Pricing</h1><p>Plans ünd prices</p>',
});
});
+
+ it('counts a compressed page by what it opens to, refused or cut at the cap', async () => {
+ await expect(get('/big-gzip', { maxBytes: 1_000 })).rejects.toMatchObject({
+ code: 'too_large',
+ });
+ await expect(get('/big-gzip', { maxBytes: 1_000, truncate: true })).resolves.toMatchObject({
+ status: 200,
+ html: 'x'.repeat(1_000),
+ });
+ });
});