Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run on first page load and ensure conversion review has proper behavior #768

Merged
merged 10 commits into from
May 3, 2024
1 change: 1 addition & 0 deletions src/renderer/src/pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ const pages = {
title: "Conversion Review",
label: "Review conversion",
section: sections[2],
sync: ["conversion"],
}),

upload: new GuidedUploadPage({
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/src/progress/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,13 @@ export const get = (name) => {
);
};

export function resume(name) {
export async function resume(name) {
const global = this ? this.load(name) : get(name);

let commandToResume = global["page-before-exit"] || "//details";
updateURLParams({ project: name });

if (this) this.onTransition(commandToResume);
if (this) await this.onTransition(commandToResume);

return commandToResume;
}
Expand Down
12 changes: 6 additions & 6 deletions src/renderer/src/stories/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export class Dashboard extends LitElement {

this.page.set(toPass, false);

this.page.checkSyncState().then(() => {
this.page.checkSyncState().then(async () => {
const projectName = info.globalState?.project?.name;

this.subSidebar.header = projectName
Expand All @@ -264,8 +264,8 @@ export class Dashboard extends LitElement {
});

// Skip right over the page if configured as such
if (previous && previous.info.previous === this.page) this.page.onTransition(-1);
else this.page.onTransition(1);
if (previous && previous.info.previous === this.page) await this.page.onTransition(-1);
else await this.page.onTransition(1);
}
});
}
Expand Down Expand Up @@ -328,13 +328,13 @@ export class Dashboard extends LitElement {
if (typeof transition === "number") {
const info = this.page.info;
const sign = Math.sign(transition);
if (sign === 1) return this.setAttribute("activePage", info.next.info.id);
else if (sign === -1) return this.setAttribute("activePage", (info.previous ?? info.parent).info.id); // Default to back in time
if (sign === 1) transition = info.next.info.id;
else if (sign === -1) transition = (info.previous ?? info.parent).info.id; // Default to back in time
}

this.setAttribute("activePage", transition);

return await promise;
return promise;
};

this.main.updatePages = () => {
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/stories/pages/FormPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class GuidedFormPage extends Page {
onNext: async () => {
await this.save(); // Save in case validation fails
await this.form.validate(); // Validate the results of the form
this.to(1);
return this.to(1);
},
};

Expand Down
24 changes: 12 additions & 12 deletions src/renderer/src/stories/pages/Page.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,10 @@ export class Page extends LitElement {

// Indicate conversion has run successfully
const { desyncedData } = this.info.globalState;
if (!desyncedData) this.info.globalState.desyncedData = {};

if (desyncedData) {
delete desyncedData[key];
if (Object.keys(desyncedData).length === 0) delete this.info.globalState.desyncedData;
desyncedData[key] = false;
await this.save({}, false);
}
}
Expand Down Expand Up @@ -255,16 +256,15 @@ export class Page extends LitElement {
if (!sync) return;

const { desyncedData } = info.globalState;
if (desyncedData) {
return Promise.all(
sync.map((k) => {
if (desyncedData[k]) {
if (k === "conversion") return this.convert();
else if (k === "preview") return this.convert({ preview: true });
}
})
);
}

return Promise.all(
sync.map((k) => {
if (desyncedData?.[k] !== false) {
if (k === "conversion") return this.convert();
else if (k === "preview") return this.convert({ preview: true });
}
})
);
};

updateSections = () => {
Expand Down
11 changes: 1 addition & 10 deletions tests/e2e/e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,8 @@ describe('E2E Test', () => {

}, { upload_to_dandi: true })

await toNextPage('structure') // Save data without a popup
await to('//conversion')

// Do not prompt to save
await evaluate(() => {
const dashboard = document.querySelector('nwb-dashboard')
const page = dashboard.page
page.unsavedUpdates = false
})

await to('//upload') // NOTE: It would be nice to avoid having to re-run the conversion...
await to('//upload')

})

Expand Down
17 changes: 13 additions & 4 deletions tests/e2e/workflow.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, test } from "vitest"
import { describe, expect, test } from "vitest"

import { sleep } from '../puppeteer'

Expand Down Expand Up @@ -429,21 +429,30 @@ export default async function runWorkflow(name, workflow, identifier) {

test('Review NWB Inspector output', async () => {

await takeScreenshot(join(identifier, 'inspect-page'), 5000) // Finish file inspection and allow full load of Neurosift page
await takeScreenshot(join(identifier, 'inspect-page'), 5000) // Allow for the completion of file validation
await toNextPage('preview')

})

test('Review Neurosift visualization', async () => {
await takeScreenshot(join(identifier, 'preview-page'), 1000) // Finish loading Neurosift
await takeScreenshot(join(identifier, 'preview-page'), 1000) // Allow full load of Neurosift page
await toNextPage('conversion')
})

test('View the conversion results', async () => {
await takeScreenshot(join(identifier, 'conversion-results-page'), 1000)

const conversionCompleted = await evaluate(() => {
const dashboard = document.querySelector('nwb-dashboard')
const page = dashboard.page
return !!page.info.globalState.conversion
})

await takeScreenshot(join(identifier, 'conversion-results-page'), 300)
if (workflow.upload_to_dandi) await toNextPage('upload')
else await toNextPage('')

expect(conversionCompleted).toBe(true)

})


Expand Down
Loading