diff --git a/src/sql/workbench/contrib/notebook/test/browser/notebookLinkHandler.test.ts b/src/sql/workbench/contrib/notebook/test/browser/notebookLinkHandler.test.ts index bb2fcb5ea8..69d37d1de0 100644 --- a/src/sql/workbench/contrib/notebook/test/browser/notebookLinkHandler.test.ts +++ b/src/sql/workbench/contrib/notebook/test/browser/notebookLinkHandler.test.ts @@ -61,6 +61,9 @@ suite('Noteboook Link Handler', function (): void { result = new NotebookLinkHandler(notebookUri, Object.assign(document.createElement('a'), { href: '/tmp/inner/stuff.png' }), configurationService); assert.strictEqual(result.getLinkUrl(), `.${path.sep}inner${path.sep}stuff.png`, 'Basic link test below folder failed'); + + result = new NotebookLinkHandler(notebookUri, Object.assign(document.createElement('a'), { href: '/other/stuff.png' }), configurationService); + assert.strictEqual(result.getLinkUrl(), `..${path.sep}other${path.sep}stuff.png`, 'Basic link test in different above folder failed'); }); test('Should return anchor links', () => { diff --git a/src/sql/workbench/contrib/notebook/test/calloutDialog/linkCalloutDialog.test.ts b/src/sql/workbench/contrib/notebook/test/calloutDialog/linkCalloutDialog.test.ts index 94b8e24a96..44c20c4ea9 100644 --- a/src/sql/workbench/contrib/notebook/test/calloutDialog/linkCalloutDialog.test.ts +++ b/src/sql/workbench/contrib/notebook/test/calloutDialog/linkCalloutDialog.test.ts @@ -124,7 +124,7 @@ suite('Link Callout Dialog', function (): void { assert.strictEqual(unquoteText(undefined), undefined); }); - test('Should return file link properly', async function (): Promise { + test('Should return absolute file link properly', async function (): Promise { const defaultLabel = 'defaultLabel'; const sampleUrl = 'C:/Test/Test.ipynb'; let linkCalloutDialog = new LinkCalloutDialog('Title', 'below', defaultDialogProperties, defaultLabel, sampleUrl, @@ -146,6 +146,28 @@ suite('Link Callout Dialog', function (): void { assert.strictEqual(result.insertEscapedMarkdown, `[${defaultLabel}](${sampleUrl})`, 'Markdown not returned correctly'); }); + test('Should return relative file link properly', async function (): Promise { + const defaultLabel = 'defaultLabel'; + const sampleUrl = '../../Test.ipynb'; + let linkCalloutDialog = new LinkCalloutDialog('Title', 'below', defaultDialogProperties, defaultLabel, sampleUrl, + undefined, themeService, layoutService, telemetryService, contextKeyService, undefined, undefined, undefined); + linkCalloutDialog.render(); + + let deferred = new Deferred(); + // When I first open the callout dialog + linkCalloutDialog.open().then(value => { + deferred.resolve(value); + }); + linkCalloutDialog.url = sampleUrl; + + // And insert the dialog + linkCalloutDialog.insert(); + let result = await deferred.promise; + assert.strictEqual(result.insertUnescapedLinkLabel, defaultLabel, 'Label not returned correctly'); + assert.strictEqual(result.insertUnescapedLinkUrl, sampleUrl, 'URL not returned correctly'); + assert.strictEqual(result.insertEscapedMarkdown, `[${defaultLabel}](${sampleUrl})`, 'Markdown not returned correctly'); + }); + test('Should handle quoted URLs properly', async function (): Promise { const defaultLabel = 'defaultLabel'; const unquotedUrl = 'C:/Test/Test.ipynb';