Skip to content

Commit 016aab2

Browse files
committed
Fix e2e test
1 parent 495351a commit 016aab2

File tree

1 file changed

+38
-32
lines changed

1 file changed

+38
-32
lines changed

tests/e2e/workflow.ts

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -439,25 +439,28 @@ export default async function runWorkflow(name, workflow, identifier) {
439439

440440
expect(hasReport).toBe(true)
441441

442-
const hasCorrectSubjects = await evaluate(() => {
443-
const instance_manager = document.querySelector('nwb-instance-manager')
444-
const instances = instance_manager?.instances
445-
const expected = ['All Files', 'sub-mouse1', 'sub-mouse2']
446-
const keys = Object.keys(instances || {})
447-
return expected.length === keys.length && expected.every((k, i) => k === keys[i])
448-
})
442+
// If there are multiple subjects, est subject and session order in instance manager
443+
if (willProvideSubjectInfo) {
444+
const hasCorrectSubjects = await evaluate(() => {
445+
const instance_manager = document.querySelector('nwb-instance-manager')
446+
const instances = instance_manager?.instances
447+
const expected = ['All Files', 'sub-mouse1', 'sub-mouse2']
448+
const keys = Object.keys(instances || {})
449+
return expected.length === keys.length && expected.every((k, i) => k === keys[i])
450+
})
449451

450-
expect(hasCorrectSubjects).toBe(true)
452+
expect(hasCorrectSubjects).toBe(true)
451453

452-
const hasCorrectSessions = await evaluate(() => {
453-
const instance_manager = document.querySelector('nwb-instance-manager')
454-
const instance = instance_manager?.instances['sub-mouse1']
455-
const expected = ['All Files', 'ses-Session1', 'ses-Session2']
456-
const keys = Object.keys(instance || {})
457-
return expected.length === keys.length && expected.every((k, i) => k === keys[i])
458-
})
454+
const hasCorrectSessions = await evaluate(() => {
455+
const instance_manager = document.querySelector('nwb-instance-manager')
456+
const instance = instance_manager?.instances['sub-mouse1']
457+
const expected = ['All Files', 'ses-Session1', 'ses-Session2']
458+
const keys = Object.keys(instance || {})
459+
return expected.length === keys.length && expected.every((k, i) => k === keys[i])
460+
})
459461

460-
expect(hasCorrectSessions).toBe(true)
462+
expect(hasCorrectSessions).toBe(true)
463+
}
461464

462465
await toNextPage('preview')
463466

@@ -466,25 +469,28 @@ export default async function runWorkflow(name, workflow, identifier) {
466469
test('Review Neurosift visualization', async () => {
467470
await takeScreenshot(join(identifier, 'preview-page'), 1000) // Allow full load of Neurosift page
468471

469-
const hasCorrectSubjects = await evaluate(() => {
470-
const instance_manager = document.querySelector('nwb-file-preview')?.shadowRoot?.querySelector('nwb-instance-manager')
471-
const instances = instance_manager?.instances
472-
const expected = ['sub-mouse1', 'sub-mouse2']
473-
const keys = Object.keys(instances || {})
474-
return expected.length === keys.length && expected.every((k, i) => k === keys[i])
475-
})
472+
// If there are multiple subjects, est subject and session order in instance manager
473+
if (willProvideSubjectInfo) {
474+
const hasCorrectSubjects = await evaluate(() => {
475+
const instance_manager = document.querySelector('nwb-file-preview')?.shadowRoot?.querySelector('nwb-instance-manager')
476+
const instances = instance_manager?.instances
477+
const expected = ['sub-mouse1', 'sub-mouse2']
478+
const keys = Object.keys(instances || {})
479+
return expected.length === keys.length && expected.every((k, i) => k === keys[i])
480+
})
476481

477-
expect(hasCorrectSubjects).toBe(true)
482+
expect(hasCorrectSubjects).toBe(true)
478483

479-
const hasCorrectSessions = await evaluate(() => {
480-
const instance_manager = document.querySelector('nwb-file-preview')?.shadowRoot?.querySelector('nwb-instance-manager')
481-
const instance = instance_manager?.instances['sub-mouse1']
482-
const expected = ['ses-Session1', 'ses-Session2']
483-
const keys = Object.keys(instance || {})
484-
return expected.length === keys.length && expected.every((k, i) => k === keys[i])
485-
})
484+
const hasCorrectSessions = await evaluate(() => {
485+
const instance_manager = document.querySelector('nwb-file-preview')?.shadowRoot?.querySelector('nwb-instance-manager')
486+
const instance = instance_manager?.instances['sub-mouse1']
487+
const expected = ['ses-Session1', 'ses-Session2']
488+
const keys = Object.keys(instance || {})
489+
return expected.length === keys.length && expected.every((k, i) => k === keys[i])
490+
})
486491

487-
expect(hasCorrectSessions).toBe(true)
492+
expect(hasCorrectSessions).toBe(true)
493+
}
488494

489495
await toNextPage('conversion')
490496
})

0 commit comments

Comments
 (0)