Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions e2e/design-v2-editor-targets.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { test, expect } from '@playwright/test';

test.use({
storageState: {
cookies: [],
origins: [
{
origin: 'http://localhost:5173',
localStorage: [
{ name: 'hasVisited', value: 'true' },
{ name: 'isDesignV2Enabled', value: 'true' },
],
},
],
},
});

test.describe('Design v2 editor targets', () => {
test('Deploy card provides all three editor options', async ({ page }) => {
await page.goto('/');

await expect(page.locator('.nd-rail')).toBeVisible({
timeout: 30000,
});

// Enter the Design V2 workflow.
await page.locator('.nd-hero-actions button').first().click();

// Navigate directly to Deploy using the stepper.
const stepper = page.locator('.nd-stepper-cards');
await expect(stepper).toBeVisible();

await stepper.getByRole('button', { name: /Deploy/ }).click();

// Verify the editor card and its three external links.
const card = page.getByRole('article', {
name: 'Open in an editor',
});

await expect(card).toBeVisible();

const targets = [
{
label: 'VS Code for the Web',
href: 'https://vscode.dev/',
},
{
label: 'Desktop VS Code',
href: 'https://code.visualstudio.com/download',
},
{
label: 'Claude Code',
href: 'https://code.claude.com/docs/en/quickstart',
},
];

for (const target of targets) {
const link = card.getByRole('link', {
name: new RegExp(`^${target.label}`),
});

await expect(link).toBeVisible();
await expect(link).toHaveAttribute('href', target.href);
await expect(link).toHaveAttribute('target', '_blank');
}
});
});
11 changes: 6 additions & 5 deletions src/components/designV2/DeployView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -219,18 +219,19 @@ export const DeployView = () => {
{card.button}
</Button>
)}
{card.secondary && (
{card.editorTargets?.map((target) => (
<Button
key={target.href}
block
style={{ marginTop: 8 }}
href={card.secondary.href}
href={target.href}
target="_blank"
rel="noopener noreferrer"
aria-label={`${card.secondary.label} ↗ (opens in a new tab)`}
aria-label={`${target.label} (opens in a new tab)`}
>
{card.secondary.label} ↗
{target.label}
</Button>
)}
))}
</div>
</article>
);
Expand Down
26 changes: 16 additions & 10 deletions src/components/designV2/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export const URLS = {
vscodeTutorial: "https://docs.accordproject.org/docs/tutorial-vscode/",
apapDeploy: "https://docs.accordproject.org/docs/ref-apap/#deploy-a-template",
vscodeDev: "https://vscode.dev/",
vscodeDownload: "https://code.visualstudio.com/download",
claudeCodeDocs: "https://code.claude.com/docs/en/quickstart",
apapMcp: "https://docs.accordproject.org/docs/ref-apap/#mcp-support-experimental",
templateLibrary: "https://templates.accordproject.org/",
/** Where the "new design" banner sends people to report problems: the design v2 bug bash. */
Expand Down Expand Up @@ -502,7 +504,7 @@ export interface DeployCard {
/** Which in-app action the button runs when there is no `href`. */
action?: "pdf" | "markdown" | "share" | "copy" | "archive" | "vscode";
/** A second, link-only button under the main one. */
secondary?: { label: string; href: string };
editorTargets?: readonly { label: string; href: string }[];
/** Toast shown when the action succeeds. */
done?: string;
}
Expand Down Expand Up @@ -579,18 +581,22 @@ export const DEPLOY = {
done: "Template archive downloaded",
},
{
title: "Open in vscode.dev",
title: "Open in an editor",
icon: "vscode",
description:
"Save the template as a folder on your computer and open it in VS Code for the Web to keep editing it there.",
"Save the template as a folder, then continue working with the editor or coding agent you prefer.",
details: [
"First save the folder, then open vscode.dev",
"There, choose File › Open Folder and pick the saved folder",
"Chrome or Edge — they can save folders",
"Save the folder, then choose one of the three editor options below",
"VS Code Web and desktop VS Code can open the saved folder",
"For Claude Code, install the CLI and run claude from the folder in a terminal",
],
button: "1. Save as folder",
action: "vscode",
secondary: { label: "2. Open vscode.dev", href: URLS.vscodeDev },
editorTargets: [
{ label: "VS Code for the Web", href: URLS.vscodeDev },
{ label: "Desktop VS Code", href: URLS.vscodeDownload },
{ label: "Claude Code", href: URLS.claudeCodeDocs },
],
},
{
title: "Deploy to an APAP server",
Expand Down Expand Up @@ -622,11 +628,11 @@ export const DEPLOY = {
},
] satisfies readonly DeployGroup[],
failed: (title: string) => `${title} failed`,
/** Toasts for the vscode.dev card. */
/** Toasts for the editor card. */
folderSaved: (folder: string) =>
`Saved the template to “${folder}”. Now open vscode.dev, choose File › Open Folder and pick it.`,
`Saved the template to “${folder}”. Choose an editor below to continue.`,
noFolderSupport:
"This browser can’t save folders, so the template was downloaded as a .cta (a zip). Unzip it, then open the folder in vscode.dev from Chrome or Edge, or in desktop VS Code.",
"This browser can’t save folders, so the template was downloaded as a .cta archive. Unzip it, then open the folder in VS Code Web or desktop VS Code, or open a terminal in it and run claude after installing Claude Code.",
renderError: "The agreement doesn’t render with the current text, model and data — fix the error and try again.",
} as const;

Expand Down
22 changes: 16 additions & 6 deletions src/tests/components/designV2/DeployView.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ describe('DeployView', () => {
expect(writeText).not.toHaveBeenCalled();
}, 30_000);

describe('Open in vscode.dev', () => {
describe('Open in an editor', () => {
const files: string[] = [];
const dir = (name: string): DirectoryHandle => ({
name,
Expand Down Expand Up @@ -331,13 +331,15 @@ describe('DeployView', () => {
// Synchronously from the click, before the archive is built (user activation).
expect(picker).toHaveBeenCalledTimes(1);
await waitFor(() => expect(success).toHaveBeenCalled(), SLOW);
// vscode.dev is the card's own link, not a pop-up after the save.
// Editor targets are links, not pop-ups after the save.
expect(open).not.toHaveBeenCalled();
success.mockRestore();
expect(files).toEqual(expect.arrayContaining([
'Documents/my-template/package.json',
'Documents/my-template/text/grammar.tem.md',
'Documents/my-template/model/model.cto',
'Documents/my-template/AGENTS.md',
'Documents/my-template/.vscode/extensions.json',
]));
}, 30_000);

Expand Down Expand Up @@ -410,11 +412,19 @@ describe('DeployView', () => {
error.mockRestore();
}, 30_000);

it('also links straight to vscode.dev', () => {
it('provides links to all three editor targets', () => {
render(<DeployView />);
const link = within(screen.getByRole('article', { name: 'Open in vscode.dev' })).getByRole('link', { name: /^2\. Open vscode\.dev/ });
expect(link).toHaveAttribute('href', URLS.vscodeDev);
expect(link).toHaveAttribute('target', '_blank');
const card = within(screen.getByRole('article', { name: 'Open in an editor' }));
const targets = [
{ label: 'VS Code for the Web', href: URLS.vscodeDev },
{ label: 'Desktop VS Code', href: URLS.vscodeDownload },
{ label: 'Claude Code', href: URLS.claudeCodeDocs },
];
for (const target of targets) {
const link = card.getByRole('link', { name: new RegExp(`^${target.label}`) });
expect(link).toHaveAttribute('href', target.href);
expect(link).toHaveAttribute('target', '_blank');
}
});
});

Expand Down