|
| 1 | +import { createElement } from 'react'; |
| 2 | +import { renderToStaticMarkup } from 'react-dom/server'; |
| 3 | +import { describe, expect, it } from 'vitest'; |
| 4 | +import Home from '../app/page'; |
| 5 | +import { |
| 6 | + documentdbVsCodeExtensionMarketplaceUrl, |
| 7 | + documentdbVsCodeLocalQuickStartDeepLink, |
| 8 | +} from '../app/services/externalLinks'; |
| 9 | + |
| 10 | +const html = renderToStaticMarkup(createElement(Home)); |
| 11 | + |
| 12 | +describe('homepage local quick start', () => { |
| 13 | + it('preserves the public anchor and Docker as the default tab', () => { |
| 14 | + expect(html).toContain('id="run-with-docker"'); |
| 15 | + expect(html).toMatch( |
| 16 | + /id="quickstart-tab-docker" aria-selected="true" aria-controls="quickstart-panel-docker" tabindex="0"/, |
| 17 | + ); |
| 18 | + expect(html).toMatch( |
| 19 | + /id="quickstart-tab-vscode" aria-selected="false" aria-controls="quickstart-panel-vscode" tabindex="-1"/, |
| 20 | + ); |
| 21 | + expect(html).toMatch( |
| 22 | + /id="quickstart-panel-docker" aria-labelledby="quickstart-tab-docker">/, |
| 23 | + ); |
| 24 | + expect(html).toMatch( |
| 25 | + /id="quickstart-panel-vscode" aria-labelledby="quickstart-tab-vscode" hidden=""/, |
| 26 | + ); |
| 27 | + expect(html).toContain('docker run -dt --name documentdb'); |
| 28 | + expect(html).toContain('-p 10260:10260'); |
| 29 | + expect(html).toContain( |
| 30 | + 'ghcr.io/documentdb/documentdb/documentdb-local:latest', |
| 31 | + ); |
| 32 | + }); |
| 33 | + |
| 34 | + it('offers the marketplace before the supported local setup deep link', () => { |
| 35 | + expect(documentdbVsCodeExtensionMarketplaceUrl).toBe( |
| 36 | + 'https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-documentdb', |
| 37 | + ); |
| 38 | + expect(documentdbVsCodeLocalQuickStartDeepLink).toBe( |
| 39 | + 'vscode://ms-azuretools.vscode-documentdb/local', |
| 40 | + ); |
| 41 | + const marketplace = html.indexOf( |
| 42 | + `href="${documentdbVsCodeExtensionMarketplaceUrl}"`, |
| 43 | + ); |
| 44 | + const setup = html.indexOf( |
| 45 | + `href="${documentdbVsCodeLocalQuickStartDeepLink}"`, |
| 46 | + ); |
| 47 | + expect(marketplace).toBeGreaterThan(-1); |
| 48 | + expect(setup).toBeGreaterThan(marketplace); |
| 49 | + }); |
| 50 | + |
| 51 | + it('states the shipped minimum version and Docker prerequisite', () => { |
| 52 | + expect(html).toContain('version 0.10.1 or later'); |
| 53 | + expect(html).toContain( |
| 54 | + 'Requires Docker Engine or Docker Desktop running Linux containers in your VS Code environment.', |
| 55 | + ); |
| 56 | + }); |
| 57 | + |
| 58 | + it('describes the setup actions and provides a Command Palette fallback', () => { |
| 59 | + expect(html).toContain( |
| 60 | + 'Open setup, confirm if prompted, select Continue, then review the defaults and select Start DocumentDB Local.', |
| 61 | + ); |
| 62 | + expect(html).toContain( |
| 63 | + 'When setup finishes, select Open Connection to browse data and run queries.', |
| 64 | + ); |
| 65 | + expect(html).toContain('If the link does not open setup, run '); |
| 66 | + expect(html).toContain('DocumentDB: Set up DocumentDB Local'); |
| 67 | + expect(html).toContain('from the VS Code Command Palette.'); |
| 68 | + }); |
| 69 | +}); |
0 commit comments