Skip to content

Commit

Permalink
fix a missing import in ui code and some e2e tests fails
Browse files Browse the repository at this point in the history
  • Loading branch information
sdumetz committed Jan 31, 2025
1 parent cd5f170 commit 31cd0a6
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion source/e2e/tests/download.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ test("downloads a scene archive", async ({page, request})=>{

await page.goto(`/ui/scenes/${encodeURIComponent(name)}`);
//Check if it _looks like_ the actual scene page
await expect(page.getByRole("heading", {name })).toBeVisible();
await expect(page.locator("h1")).toHaveText(name);
const downloadPromise = page.waitForEvent('download');
await page.getByRole("link", {name: "Download this scene"}).click();
const download = await downloadPromise;
Expand Down
4 changes: 2 additions & 2 deletions source/e2e/tests/upload_object.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ test("uploads and rename a glb", async ({page, request})=>{
const link = uploads.getByRole("link", {name: name});
await link.click();
await expect(page).toHaveURL(`/ui/scenes/${name}`);
await expect(page.getByRole("heading", {name})).toBeVisible();
await expect(page.locator("h1")).toHaveText(name);

let res = await request.get(`/scenes/${name}/scene.svx.json`);
await expect(res).toBeOK();
Expand Down Expand Up @@ -58,7 +58,7 @@ test("uploads and rename a glb (force FR)", async ({page, request})=>{
const link = uploads.getByRole("link", {name: name});
await link.click();
await expect(page).toHaveURL(`/ui/scenes/${name}`);
await expect(page.getByRole("heading", {name})).toBeVisible();
await expect(page.locator("h1")).toHaveText(name);

let res = await request.get(`/scenes/${name}/scene.svx.json`);
await expect(res).toBeOK();
Expand Down
14 changes: 7 additions & 7 deletions source/e2e/tests/upload_zip.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function reducePropfind(text:string) :ReducedWebDAVProps[]{


//Authenticated as admin
test.use({ storageState: 'playwright/.auth/admin.json' });
test.use({ storageState: 'playwright/.auth/admin.json', locale: "cimode" });

test("uploads a scene zip", async ({page, request})=>{
//Generate the zip file's scene
Expand All @@ -78,14 +78,14 @@ test("uploads a scene zip", async ({page, request})=>{

await page.goto("/ui/upload");

const f = page.getByRole("form", {name: "create a new scene"});
const f = page.getByRole("form", {name: "titles.createScene"});
await expect(f).toBeVisible();
await f.getByRole("button", {name: "select a file"}).setInputFiles({
await f.getByRole("button", {name: "labels.selectFile"}).setInputFiles({
name: "scene.zip",
mimeType: "application/zip",
buffer: body,
});
await f.getByRole("button", {name: "create a scene"}).click();
await f.getByRole("button", {name: "buttons.upload"}).click();


const uploads = page.getByRole("region", {name: "uploads"});
Expand Down Expand Up @@ -137,14 +137,14 @@ test("uploads a multi-scene zip", async ({page, request})=>{

await page.goto("/ui/upload");

const f = page.getByRole("form", {name: "create a new scene"});
const f = page.getByRole("form", {name: "titles.createScene"});
await expect(f).toBeVisible();
await f.getByRole("button", {name: "select a file"}).setInputFiles({
await f.getByRole("button", {name: "labels.selectFile"}).setInputFiles({
name: "scene.zip",
mimeType: "application/zip",
buffer: body,
});
await f.getByRole("button", {name: "create a scene"}).click();
await f.getByRole("button", {name: "buttons.upload"}).click();


const uploads = page.getByRole("region", {name: "uploads"});
Expand Down
8 changes: 4 additions & 4 deletions source/server/routes/scenes/scene/files/put/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ export default async function handlePutDocument(req :Request, res :Response){
if(!refDocString) throw new BadRequestError(`Referenced document is not valid`);
const refDoc = JSON.parse(refDocString);

console.log("Ref doc :", JSON.stringify(refDoc.setups![0].tours, null, 2));
console.log("New doc :", JSON.stringify(newDoc.setups![0].tours, null, 2));
//console.log("Ref doc :", JSON.stringify(refDoc.setups![0].tours, null, 2));
//console.log("New doc :", JSON.stringify(newDoc.setups![0].tours, null, 2));
const docDiff = merge.diffDoc(refDoc, newDoc);
if(Object.keys(docDiff).length == 0){
//Nothing to do
return res.status(204).send();
}

console.log("Diff :", JSON.stringify(docDiff, (key, value)=> value === merge.DELETE_KEY? "*DELETED*":value, 2));
//console.log("Diff :", JSON.stringify(docDiff, (key, value)=> value === merge.DELETE_KEY? "*DELETED*":value, 2));
const mergedDoc = merge.applyDoc(currentDoc, docDiff);
console.log("Merged doc :", JSON.stringify(mergedDoc.setups![0].tours, null, 2));
//console.log("Merged doc :", JSON.stringify(mergedDoc.setups![0].tours, null, 2));
let s = JSON.stringify(mergedDoc);
await tr.writeDoc(s, {scene: scene, user_id: uid, name: "scene.svx.json", mime: "application/si-dpo-3d.document+json"});
res.status(204).send();
Expand Down
1 change: 1 addition & 0 deletions source/server/templates/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ buttons:
editTags: Edit tags
showTags: Cancel edition
history: Scene History
download: Download this scene
fields:
name: name
mtime: last modification
Expand Down
3 changes: 2 additions & 1 deletion source/ui/MainView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ import "./composants/navbar/ChangeLocale";
import "./screens/Admin";
import "./screens/SceneHistory";

import "./composants/SubmitFragment";
import "./composants/SubmitFragment";
import "./composants/UploadForm";
5 changes: 3 additions & 2 deletions source/ui/composants/UploadForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,14 @@ export default class UploadForm extends LitElement{
xhr.send(file);
}

onsubmit = (ev:SubmitEvent)=>{
handleSubmit = (ev:SubmitEvent)=>{
ev.preventDefault();
ev.stopPropagation();
const data = new FormData(ev.target as HTMLFormElement);

this.upload(data);
(ev.target as HTMLFormElement).reset();
return false;
}

protected render(): unknown {
Expand Down Expand Up @@ -168,7 +169,7 @@ export default class UploadForm extends LitElement{
</div>`
})}
</section>`: null}
<slot @submit=${this.onsubmit}></slot>
<slot @submit=${this.handleSubmit}></slot>
`;
}

Expand Down

0 comments on commit 31cd0a6

Please sign in to comment.