Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions test/surface/concurrency.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,12 @@ describe("Concurrency", () => {
const promise = authFetcher.fetch(resourceUrl, {
method: "PATCH",
headers: {
// "Content-Type": "application/sparql-update",
"Content-Type": "application/sparql-update",
"Content-Type": "text/n3",
},
body: `INSERT DATA { ${triple} }`,
body:
"@prefix solid: <http://www.w3.org/ns/solid/terms#>." +
"#patch a solid:InsertDeletePatch;" +
` solid:inserts { ${triple} .}.`,
});
expectedRdf += `${triple}\n`;
promises.push(promise);
Expand Down
18 changes: 12 additions & 6 deletions test/surface/create-non-container.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,15 @@ describe("Create non-container", () => {
authFetcher
);
await websocketsPubsubClientResource.getReady();
const result = await authFetcher.fetch(resourceUrl, {
await authFetcher.fetch(resourceUrl, {
method: "PATCH",
body: "INSERT DATA { <#hello> <#linked> <#world> . }",
headers: {
"Content-Type": "application/sparql-update",
"Content-Type": "text/n3",
},
body:
"@prefix solid: <http://www.w3.org/ns/solid/terms#>." +
"#patch a solid:InsertDeletePatch;" +
" solid:inserts { <#hello> <#linked> <#world> .}.",
});
// console.log(result);
await new Promise((resolve) => setTimeout(resolve, waittime));
Expand Down Expand Up @@ -348,12 +351,15 @@ describe("Create non-container", () => {
authFetcher
);
await websocketsPubsubClientResource.getReady();
const result = await authFetcher.fetch(resourceUrl, {
await authFetcher.fetch(resourceUrl, {
method: "PATCH",
body: "INSERT DATA { <#hello> <#linked> <#world> . }",
headers: {
"Content-Type": "application/sparql-update",
"Content-Type": "text/n3",
},
body:
"@prefix solid: <http://www.w3.org/ns/solid/terms#>." +
"#patch a solid:InsertDeletePatch;" +
" solid:inserts { <#hello> <#linked> <#world> .}.",
});
await new Promise((resolve) => setTimeout(resolve, 2000));
});
Expand Down
85 changes: 59 additions & 26 deletions test/surface/update.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe("Update", () => {
websocketsPubsubClientResource = new WPSClient(resourceUrl, authFetcher);
await websocketsPubsubClientResource.getReady();
const headers = {
"Content-Type": "text/plain"
"Content-Type": "text/plain",
};
if (resourceETagInQuotes) {
headers["If-Match"] = resourceETagInQuotes;
Expand Down Expand Up @@ -184,7 +184,8 @@ describe("Update", () => {
};
if (resourceETagInQuotes) {
headers["If-Match"] = resourceETagInQuotes;
} const result = await authFetcher.fetch(resourceUrl, {
}
const result = await authFetcher.fetch(resourceUrl, {
method: "PUT",
headers,
body: "<#hello> <#linked> <#world> .",
Expand Down Expand Up @@ -212,7 +213,9 @@ describe("Update", () => {
);
rdflib.parse(await result.text(), store2, resourceUrl, "text/turtle");

expect(store2.statements).toEqual(expect.arrayContaining(store1.statements));
expect(store2.statements).toEqual(
expect.arrayContaining(store1.statements)
);
expect(result.headers.get("Content-Type")).toContain("text/turtle");
});
ifWps("emits websockets-pubsub on the resource", () => {
Expand Down Expand Up @@ -242,12 +245,15 @@ describe("Update", () => {

websocketsPubsubClientResource = new WPSClient(resourceUrl, authFetcher);
await websocketsPubsubClientResource.getReady();
const result = await authFetcher.fetch(resourceUrl, {
await authFetcher.fetch(resourceUrl, {
method: "PATCH",
headers: {
"Content-Type": "application/sparql-update",
"Content-Type": "text/n3",
},
body: "INSERT DATA { <#that> a <#fact> . }",
body:
"@prefix solid: <http://www.w3.org/ns/solid/terms#>." +
"#patch a solid:InsertDeletePatch;" +
" solid:inserts { <#that> a <#fact> . }.",
});
await new Promise((resolve) => setTimeout(resolve, waittime));
});
Expand All @@ -272,7 +278,9 @@ describe("Update", () => {
);
rdflib.parse(await result.text(), store2, resourceUrl, "text/turtle");

expect(store2.statements).toEqual(expect.arrayContaining(store1.statements));
expect(store2.statements).toEqual(
expect.arrayContaining(store1.statements)
);
expect(result.headers.get("Content-Type")).toContain("text/turtle");
});
ifWps("emits websockets-pubsub on the resource", () => {
Expand Down Expand Up @@ -305,10 +313,13 @@ describe("Update", () => {
const result = await authFetcher.fetch(resourceUrl, {
method: "PATCH",
headers: {
"Content-Type": "application/sparql-update",
"Content-Type": "text/n3",
},
body:
"DELETE DATA { <#hello> <#linked> <#world> . };\nINSERT DATA { <#hello> <#linked> <#world> . }",
"@prefix solid: <http://www.w3.org/ns/solid/terms#>." +
"#patch a solid:InsertDeletePatch;" +
" solid:deletes { <#hello> <#linked> <#world> .}." +
" solid:inserts { <#hello> <#linked> <#world> .}.",
});
await new Promise((resolve) => setTimeout(resolve, waittime));
});
Expand All @@ -333,7 +344,9 @@ describe("Update", () => {
);
rdflib.parse(await result.text(), store2, resourceUrl, "text/turtle");

expect(store2.statements).toEqual(expect.arrayContaining(store1.statements));
expect(store2.statements).toEqual(
expect.arrayContaining(store1.statements)
);
expect(result.headers.get("Content-Type")).toContain("text/turtle");
});
ifWps("emits websockets-pubsub on the resource", () => {
Expand Down Expand Up @@ -363,13 +376,16 @@ describe("Update", () => {

websocketsPubsubClientResource = new WPSClient(resourceUrl, authFetcher);
await websocketsPubsubClientResource.getReady();
const result = await authFetcher.fetch(resourceUrl, {
await authFetcher.fetch(resourceUrl, {
method: "PATCH",
headers: {
"Content-Type": "application/sparql-update",
"Content-Type": "text/n3",
},
body:
"DELETE DATA { <#hello> <#linked> <#world> . };\nINSERT DATA { <#that> a <#fact> . }",
"@prefix solid: <http://www.w3.org/ns/solid/terms#>." +
"#patch a solid:InsertDeletePatch;" +
" solid:deletes { <#hello> <#linked> <#world> .}." +
" solid:inserts { <#that> a <#fact> .}.",
});
await new Promise((resolve) => setTimeout(resolve, waittime));
});
Expand All @@ -394,7 +410,9 @@ describe("Update", () => {
);
rdflib.parse(await result.text(), store2, resourceUrl, "text/turtle");

expect(store2.statements).toEqual(expect.arrayContaining(store1.statements));
expect(store2.statements).toEqual(
expect.arrayContaining(store1.statements)
);
expect(result.headers.get("Content-Type")).toContain("text/turtle");
});
ifWps("emits websockets-pubsub on the resource", () => {
Expand Down Expand Up @@ -424,13 +442,16 @@ describe("Update", () => {

websocketsPubsubClientResource = new WPSClient(resourceUrl, authFetcher);
await websocketsPubsubClientResource.getReady();
const result = await authFetcher.fetch(resourceUrl, {
await authFetcher.fetch(resourceUrl, {
method: "PATCH",
headers: {
"Content-Type": "application/sparql-update",
"Content-Type": "text/n3",
},
body:
"DELETE DATA { <#something> <#completely> <#different> . };\nINSERT DATA { <#that> a <#fact> . }",
"@prefix solid: <http://www.w3.org/ns/solid/terms#>." +
"#patch a solid:InsertDeletePatch;" +
" solid:deletes { <#something> <#completely> <#different> .}." +
" solid:inserts { <#that> a <#fact> .}.",
});
});

Expand All @@ -455,7 +476,9 @@ describe("Update", () => {
rdflib.parse(await result.text(), store2, resourceUrl, "text/turtle");

// console.log(resourceUrl);
expect(store2.statements).toEqual(expect.arrayContaining(store1.statements));
expect(store2.statements).toEqual(
expect.arrayContaining(store1.statements)
);
expect(result.headers.get("Content-Type")).toContain("text/turtle");
});
ifWps("does not emit websockets-pubsub on the resource", () => {
Expand Down Expand Up @@ -487,12 +510,15 @@ describe("Update", () => {

websocketsPubsubClientResource = new WPSClient(resourceUrl, authFetcher);
await websocketsPubsubClientResource.getReady();
const result = await authFetcher.fetch(resourceUrl, {
await authFetcher.fetch(resourceUrl, {
method: "PATCH",
headers: {
"Content-Type": "application/sparql-update",
"Content-Type": "text/n3",
},
body: "DELETE DATA { <#hello> <#linked> <#world> . }",
body:
"@prefix solid: <http://www.w3.org/ns/solid/terms#>." +
"#patch a solid:InsertDeletePatch;" +
" solid:deletes { <#hello> <#linked> <#world> .}.",
});
});

Expand All @@ -510,7 +536,9 @@ describe("Update", () => {
rdflib.parse("@prefix : <#>.", store1, resourceUrl, "text/turtle");
rdflib.parse(await result.text(), store2, resourceUrl, "text/turtle");

expect(store2.statements).toEqual(expect.arrayContaining(store1.statements));
expect(store2.statements).toEqual(
expect.arrayContaining(store1.statements)
);
expect(result.headers.get("Content-Type")).toContain("text/turtle");
});
ifWps("emits websockets-pubsub on the resource", () => {
Expand Down Expand Up @@ -539,12 +567,15 @@ describe("Update", () => {

websocketsPubsubClientResource = new WPSClient(resourceUrl, authFetcher);
await websocketsPubsubClientResource.getReady();
const result = await authFetcher.fetch(resourceUrl, {
await authFetcher.fetch(resourceUrl, {
method: "PATCH",
headers: {
"Content-Type": "application/sparql-update",
"Content-Type": "text/n3",
},
body: "DELETE DATA { <#something> <#completely> <#different> . }",
body:
"@prefix solid: <http://www.w3.org/ns/solid/terms#>." +
"#patch a solid:InsertDeletePatch;" +
" solid:deletes { <#something> <#completely> <#different> .}.",
});
});

Expand All @@ -567,7 +598,9 @@ describe("Update", () => {
);
rdflib.parse(await result.text(), store2, resourceUrl, "text/turtle");

expect(store2.statements).toEqual(expect.arrayContaining(store1.statements));
expect(store2.statements).toEqual(
expect.arrayContaining(store1.statements)
);
expect(result.headers.get("Content-Type")).toContain("text/turtle");
});
ifWps("does not emit websockets-pubsub on the resource", () => {
Expand Down