Skip to content

Commit a44832a

Browse files
[Agent: Claude] test(lws): pin variant ETags under --lws without --conneg (task-4 review)
- the connegEnabled-gate half of review JavaScriptSolidServer#5 now has red-provable coverage Co-Authored-By: Claude Opus 4.8 <[email protected]>
1 parent 1296e8d commit a44832a

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

‎test/lws-etag-variant.test.js‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import assert from 'node:assert/strict';
1111
import {
1212
startTestServer, stopTestServer, request, createTestPod, getBaseUrl, assertStatus,
1313
} from './helpers.js';
14+
import * as storage from '../src/storage/filesystem.js';
1415
import { generatePrivateAcl, serializeAcl } from '../src/wac/parser.js';
1516

1617
const BARE_ETAG_RE = /^"[0-9a-f]{32}"$/;
@@ -236,3 +237,49 @@ describe('lws: JSON-LD conversion arm ETag (review #5)', () => {
236237
assert.equal(h.headers.get('etag'), g.headers.get('etag'));
237238
});
238239
});
240+
241+
describe('lws: representation-variant ETags under --lws without --conneg (review #5, task 4)', () => {
242+
// Task 4 fixed predictFileEtag so variant ETags are keyed even when --lws
243+
// is true and --conneg is false (previously the connegEnabled gate collapsed
244+
// every variant onto the bare ETag in that config). This describe block
245+
// exercises the --lws-without---conneg half of the fix: seeded .ttl source
246+
// yields distinct ETags for own-format (bare) vs JSON-LD conversion (-json).
247+
// PUT of RDF is rejected without conneg, so we use storage.write to seed the resource.
248+
let base;
249+
const TTL = '/etaglws/public/r.ttl';
250+
251+
before(async () => {
252+
await startTestServer({ lws: true }); // conneg omitted/false
253+
base = getBaseUrl();
254+
await createTestPod('etaglws');
255+
// Seed via storage.write since PUT text/turtle is rejected without conneg
256+
await storage.write(TTL, Buffer.from('<#s> <http://ex/p> "v".'));
257+
});
258+
after(stopTestServer);
259+
260+
it('JSON-LD conversion of a .ttl source carries a -json variant ETag under --lws alone', async () => {
261+
const r = await request(TTL, { headers: { Accept: 'application/ld+json' } });
262+
assertStatus(r, 200);
263+
assert.match(r.headers.get('etag'), /-json"$/);
264+
});
265+
266+
it('own-format .ttl GET keeps the bare ETag; the two variants differ', async () => {
267+
const ttl = await request(TTL, { headers: { Accept: 'text/turtle' } });
268+
const json = await request(TTL, { headers: { Accept: 'application/ld+json' } });
269+
assert.match(ttl.headers.get('etag'), BARE_ETAG_RE);
270+
assert.notEqual(ttl.headers.get('etag'), json.headers.get('etag'));
271+
});
272+
273+
it('a Turtle-variant If-None-Match never 304s the JSON-LD variant (cross-variant)', async () => {
274+
const ttl = await request(TTL, { headers: { Accept: 'text/turtle' } });
275+
const r = await request(TTL, { headers: { Accept: 'application/ld+json', 'If-None-Match': ttl.headers.get('etag') } });
276+
assertStatus(r, 200);
277+
});
278+
279+
it('same-variant If-None-Match still 304s', async () => {
280+
const json = await request(TTL, { headers: { Accept: 'application/ld+json' } });
281+
const r = await request(TTL, { headers: { Accept: 'application/ld+json', 'If-None-Match': json.headers.get('etag') } });
282+
assertStatus(r, 304);
283+
assert.match(r.headers.get('etag'), /-json"$/);
284+
});
285+
});

0 commit comments

Comments
 (0)