Skip to content

Commit

Permalink
fix(runPipeline): Support URL pipelineBaseUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
thewtex committed Jan 14, 2023
1 parent f632414 commit af20cd9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
16 changes: 13 additions & 3 deletions cypress/e2e/pipeline/runPipeline.cy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { pipeline } from "stream"

describe('runPipeline', () => {
beforeEach(() => {
cy.visit('/')
Expand Down Expand Up @@ -37,7 +35,7 @@ describe('runPipeline', () => {
it('fetches WASM files from a custom pipelineBaseUrl URL', () => {
cy.window().then(async (win) => {
const itk = win.itk
const pipelineBaseUrl = '/pipelines'
const pipelineBaseUrl = new URL('/pipelines', document.location.origin)

const args = []
const outputs = null
Expand All @@ -47,6 +45,18 @@ describe('runPipeline', () => {
})
})

it('fetches WASM files from a custom pipelineBaseUrl string', () => {
cy.window().then(async (win) => {
const itk = win.itk
const pipelineBaseUrl = '/pipelines'

const args = []
const outputs = null
const inputs = null
const stdoutStderrPath = 'stdout-stderr-test'
const { webWorker, returnValue, stdout, stderr } = await itk.runPipeline(null, stdoutStderrPath, args, outputs, inputs, pipelineBaseUrl)
})
})

it('re-uses a WebWorker', () => {
cy.window().then(async (win) => {
Expand Down
3 changes: 2 additions & 1 deletion src/pipeline/runPipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,13 @@ async function runPipeline (webWorker: Worker | null | boolean, pipelinePath: st
stderr: string
outputs: PipelineOutput[]
}
const pipelineBaseUrlString = typeof pipelineBaseUrl !== 'string' && typeof pipelineBaseUrl?.href !== 'undefined' ? pipelineBaseUrl.href : pipelineBaseUrl
const result: RunPipelineWorkerResult = await webworkerPromise.postMessage(
{
operation: 'runPipeline',
config: config,
pipelinePath: pipelinePath.toString(),
pipelineBaseUrl,
pipelineBaseUrl: pipelineBaseUrlString,
args,
outputs,
inputs
Expand Down

0 comments on commit af20cd9

Please sign in to comment.