From 1bc9cc3e3d734a51120d3d0558948fd32d2ea3ec Mon Sep 17 00:00:00 2001 From: Garrett Michael Flynn Date: Thu, 2 May 2024 12:06:51 -0700 Subject: [PATCH 1/9] Run on first page load and ensure conversion review has proper behavior --- src/renderer/src/pages.js | 1 + src/renderer/src/stories/pages/Page.js | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/renderer/src/pages.js b/src/renderer/src/pages.js index 3f15cb90c..8a172bfe2 100644 --- a/src/renderer/src/pages.js +++ b/src/renderer/src/pages.js @@ -144,6 +144,7 @@ const pages = { title: "Conversion Review", label: "Review conversion", section: sections[2], + sync: ["conversion"], }), upload: new GuidedUploadPage({ diff --git a/src/renderer/src/stories/pages/Page.js b/src/renderer/src/stories/pages/Page.js index a8a0767d1..d07c83d8c 100644 --- a/src/renderer/src/stories/pages/Page.js +++ b/src/renderer/src/stories/pages/Page.js @@ -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); } } @@ -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 = () => { From a4fe2776686825cfe27df40d5aa6638656a6b99f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 2 May 2024 19:09:56 +0000 Subject: [PATCH 2/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/renderer/src/stories/pages/Page.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/src/stories/pages/Page.js b/src/renderer/src/stories/pages/Page.js index d07c83d8c..e7c00eff4 100644 --- a/src/renderer/src/stories/pages/Page.js +++ b/src/renderer/src/stories/pages/Page.js @@ -134,7 +134,7 @@ export class Page extends LitElement { // Indicate conversion has run successfully const { desyncedData } = this.info.globalState; - if (!desyncedData) this.info.globalState.desyncedData = { }; + if (!desyncedData) this.info.globalState.desyncedData = {}; if (desyncedData) { desyncedData[key] = false; From 7e419734874fdda56fb617da03df2f5d77323884 Mon Sep 17 00:00:00 2001 From: Garrett Michael Flynn Date: Thu, 2 May 2024 13:27:21 -0700 Subject: [PATCH 3/9] Fix tests --- src/renderer/src/progress/index.js | 4 ++-- src/renderer/src/stories/Dashboard.js | 16 +++++++++------- src/renderer/src/stories/pages/FormPage.js | 2 +- tests/e2e/e2e.test.ts | 11 +---------- tests/e2e/workflow.ts | 7 +++---- 5 files changed, 16 insertions(+), 24 deletions(-) diff --git a/src/renderer/src/progress/index.js b/src/renderer/src/progress/index.js index 56a180f52..84fc87553 100644 --- a/src/renderer/src/progress/index.js +++ b/src/renderer/src/progress/index.js @@ -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; } diff --git a/src/renderer/src/stories/Dashboard.js b/src/renderer/src/stories/Dashboard.js index bf7727d8d..8f0cc5acb 100644 --- a/src/renderer/src/stories/Dashboard.js +++ b/src/renderer/src/stories/Dashboard.js @@ -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 @@ -256,6 +256,7 @@ export class Dashboard extends LitElement { const { skipped } = this.subSidebar.sections[info.section]?.pages?.[info.id] ?? {}; if (skipped) { + if (isStorybook) return; // Do not skip on storybook // Run skip functions @@ -264,9 +265,10 @@ 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); } + }); } @@ -328,13 +330,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 = () => { diff --git a/src/renderer/src/stories/pages/FormPage.js b/src/renderer/src/stories/pages/FormPage.js index 76b9068e0..8930e8d17 100644 --- a/src/renderer/src/stories/pages/FormPage.js +++ b/src/renderer/src/stories/pages/FormPage.js @@ -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); }, }; diff --git a/tests/e2e/e2e.test.ts b/tests/e2e/e2e.test.ts index f7b0f2343..44ba41161 100644 --- a/tests/e2e/e2e.test.ts +++ b/tests/e2e/e2e.test.ts @@ -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') }) diff --git a/tests/e2e/workflow.ts b/tests/e2e/workflow.ts index fd097e01a..88fadc88d 100644 --- a/tests/e2e/workflow.ts +++ b/tests/e2e/workflow.ts @@ -429,19 +429,18 @@ 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'), 300) + await takeScreenshot(join(identifier, 'conversion-results-page'), 1000) if (workflow.upload_to_dandi) await toNextPage('upload') else await toNextPage('') }) From cdad7edf75b6d9f985f224b3f4e900250821deba Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 2 May 2024 20:28:29 +0000 Subject: [PATCH 4/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/renderer/src/stories/Dashboard.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/renderer/src/stories/Dashboard.js b/src/renderer/src/stories/Dashboard.js index 8f0cc5acb..e56b50273 100644 --- a/src/renderer/src/stories/Dashboard.js +++ b/src/renderer/src/stories/Dashboard.js @@ -256,7 +256,6 @@ export class Dashboard extends LitElement { const { skipped } = this.subSidebar.sections[info.section]?.pages?.[info.id] ?? {}; if (skipped) { - if (isStorybook) return; // Do not skip on storybook // Run skip functions @@ -268,7 +267,6 @@ export class Dashboard extends LitElement { if (previous && previous.info.previous === this.page) await this.page.onTransition(-1); else await this.page.onTransition(1); } - }); } @@ -330,10 +328,10 @@ export class Dashboard extends LitElement { if (typeof transition === "number") { const info = this.page.info; const sign = Math.sign(transition); - if (sign === 1) transition = info.next.info.id + 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 promise; From 46be5424982230e2300131cce0b22ca7cbf829d9 Mon Sep 17 00:00:00 2001 From: Garrett Michael Flynn Date: Thu, 2 May 2024 13:36:09 -0700 Subject: [PATCH 5/9] Update tests to fail without this PR --- tests/e2e/workflow.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/e2e/workflow.ts b/tests/e2e/workflow.ts index 88fadc88d..6fadea192 100644 --- a/tests/e2e/workflow.ts +++ b/tests/e2e/workflow.ts @@ -1,4 +1,4 @@ -import { describe, test } from "vitest" +import { describe, expect, test } from "vitest" import { sleep } from '../puppeteer' @@ -441,8 +441,18 @@ export default async function runWorkflow(name, workflow, identifier) { 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 + }) + if (workflow.upload_to_dandi) await toNextPage('upload') else await toNextPage('') + + expect(conversionCompleted).toBe(true) + }) From 3e3a82a4223bd66ead49da494ee275cf00a1e802 Mon Sep 17 00:00:00 2001 From: Garrett Michael Flynn Date: Thu, 2 May 2024 14:42:17 -0700 Subject: [PATCH 6/9] Fix storybook --- src/renderer/src/stories/pages/Page.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/renderer/src/stories/pages/Page.js b/src/renderer/src/stories/pages/Page.js index e7c00eff4..b06d3fd34 100644 --- a/src/renderer/src/stories/pages/Page.js +++ b/src/renderer/src/stories/pages/Page.js @@ -1,7 +1,7 @@ import { LitElement, html } from "lit"; import { openProgressSwal, runConversion } from "./guided-mode/options/utils.js"; import { get, save } from "../../progress/index.js"; -import { dismissNotification, notify } from "../../dependencies/globals.js"; +import { dismissNotification, isStorybook, notify } from "../../dependencies/globals.js"; import { randomizeElements, mapSessions, merge } from "./utils.js"; import { ProgressBar } from "../ProgressBar"; @@ -254,9 +254,11 @@ export class Page extends LitElement { checkSyncState = async (info = this.info, sync = info.sync) => { if (!sync) return; + if (isStorybook) return; const { desyncedData } = info.globalState; + f return Promise.all( sync.map((k) => { if (desyncedData?.[k] !== false) { From f1693ffcfb36706fe883f2b054317721ce702249 Mon Sep 17 00:00:00 2001 From: Garrett Michael Flynn Date: Thu, 2 May 2024 14:42:43 -0700 Subject: [PATCH 7/9] Delete GuidedStart.stories.js --- .../pages/guided-mode/GuidedStart.stories.js | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 src/renderer/src/stories/pages/guided-mode/GuidedStart.stories.js diff --git a/src/renderer/src/stories/pages/guided-mode/GuidedStart.stories.js b/src/renderer/src/stories/pages/guided-mode/GuidedStart.stories.js deleted file mode 100644 index 1a812dcb2..000000000 --- a/src/renderer/src/stories/pages/guided-mode/GuidedStart.stories.js +++ /dev/null @@ -1,14 +0,0 @@ -import { globalState, PageTemplate } from "./storyStates"; - -export default { - title: "Pages/Guided Mode/Start", - parameters: { - chromatic: { disableSnapshot: false }, - }, -}; - -export const Default = PageTemplate.bind({}); -Default.args = { - activePage: "//start", - globalState, -}; From 476c489c61c6bf21803eb23ee600686a7b3e45c0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 2 May 2024 21:42:59 +0000 Subject: [PATCH 8/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/renderer/src/stories/pages/Page.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/src/stories/pages/Page.js b/src/renderer/src/stories/pages/Page.js index b06d3fd34..5c08b5a9f 100644 --- a/src/renderer/src/stories/pages/Page.js +++ b/src/renderer/src/stories/pages/Page.js @@ -258,7 +258,7 @@ export class Page extends LitElement { const { desyncedData } = info.globalState; - f + f; return Promise.all( sync.map((k) => { if (desyncedData?.[k] !== false) { From 764846a9aa63ba933c48725046713e74fd61b57c Mon Sep 17 00:00:00 2001 From: Garrett Michael Flynn Date: Fri, 3 May 2024 09:36:00 -0700 Subject: [PATCH 9/9] Remove stray character --- src/renderer/src/stories/pages/Page.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/renderer/src/stories/pages/Page.js b/src/renderer/src/stories/pages/Page.js index 5c08b5a9f..c077662eb 100644 --- a/src/renderer/src/stories/pages/Page.js +++ b/src/renderer/src/stories/pages/Page.js @@ -258,7 +258,6 @@ export class Page extends LitElement { const { desyncedData } = info.globalState; - f; return Promise.all( sync.map((k) => { if (desyncedData?.[k] !== false) {