// The scenario table: the selectors, names, and feature switches of both modes, and the in-use action of each feature. // A value with `plugin` and `native` keys differs between the modes. Change the table when a stage changes a name. const PLUGIN_RELEASES = "D:/Users/KnottyWyvern/Documents"; export const TABLE = { /** The start time ends when this tree row is visible. */ knownRow: '[data-tree-rel="sample.pdf"]', /** The command palette. */ palette: { shortcut: "Control+Shift+P", input: "Find a command" }, /** The layout that the cleanup writes, so each start shows the file tree. */ layout: { leftOpen: true, rightOpen: true, leftWidth: 260, rightWidth: 240, leftView: "files" }, /** The settings section of the native feature switches. */ featuresSection: "features", features: { git: { plugin: { id: "runestone.git", repo: "runestone-git", tag: "v0.1.10", zip: `${PLUGIN_RELEASES}/RuneStone_Git/releases/runestone.git-0.1.10.zip` }, nativeKey: "git", navigation: "Source control", changeRow: { plugin: ".rs-git-row", native: ".source-control .row" }, changeCount: 50, changeFile: { plugin: ".rs-git-file", native: ".source-control .file" }, diffTab: "Git diff", diffText: "Changed after the last commit", graphCommand: "Show Git graph", /** Where the command is: `palette`, or `menu:`. Master lists plugin view commands only in the Plug-in views menu. */ graphCommandIn: { plugin: "menu:Plug-in views", native: "palette" }, graphTab: "Git graph", graphText: "Change fixture files, step 29", }, background: { plugin: { id: "runestone.bg-slideshow", repo: "runestone-bg-slideshow", tag: "v0.0.11", zip: `${PLUGIN_RELEASES}/RuneStone_Background_Slideshow/releases/runestone.bg-slideshow-0.0.11.zip` }, nativeKey: "background", /** * The style property of the body that holds the current background image. The action counts its changes. * Native: `backgroundHub.applyApp` (src/lib/plugins/backgrounds.ts) sets it for each new image of Background. */ imageProperty: { plugin: "--rs-background-image", native: "--rs-background-image" }, changes: 3, seconds: 10, }, terminal: { plugin: { id: "runestone.terminal", repo: "runestone-terminal", tag: "v0.1.11", zip: `${PLUGIN_RELEASES}/RuneStone_Terminal/releases/runestone.terminal-0.1.11.zip` }, nativeKey: "terminal", /** * Both modes use the same names. Native: the ribbon button comes from the feature switch, and the first click loads * the Terminal feature and xterm (src/lib/features/TerminalHost.svelte), so the action includes that load. */ ribbon: ".plugin-ribbon", button: "Terminal", surface: ".xterm", rows: ".xterm-rows", prompt: "PS [A-Za-z]:\\\\", command: '1..10000 | % { "line $_" }', readyText: "line 10000", }, pdf: { plugin: { id: "runestone.pdf-viewer", repo: "runestone-pdf-viewer", tag: "v0.0.5", zip: `${PLUGIN_RELEASES}/RuneStone_PDF_Viewer/releases/runestone.pdf-viewer-0.0.5.zip` }, nativeKey: "pdf", /** * Both modes use the same names. Native: the tree row opens a PDF tab, and the first tab loads the PDF Viewer feature * and PDF.js (src/lib/features/pdf/), so the action includes that load. Each page canvas is an image named "PDF page N", * and the page field is a spin button named "Page number". Enter in the field goes to the page. */ row: '[data-tree-rel="sample.pdf"]', firstPage: "PDF page 1", pageInput: "Page number", target: 25, targetPage: "PDF page 25", }, pm: { plugin: { id: "runestone.pm", repo: "runestone-pm", tag: "v0.2.49", zip: `${PLUGIN_RELEASES}/RuneStone_Project_Management/releases/runestone.pm-0.2.49.zip` }, nativeKey: "pm", /** * Where the view opens: `palette`, `menu:`, or `ribbon:`. Native: the static * ribbon button opens the default board or All tasks, and the first click loads the feature (src/lib/features/pm/). */ openIn: { plugin: "menu:Plug-in views", native: "ribbon:Project Management" }, title: "Project Management", card: { plugin: ".pm-card", native: ".pm-card" }, minCards: 50, }, }, }; /** The value of a table entry for `mode`. */ export const pick = (value, mode) => value && typeof value === "object" && !Array.isArray(value) && ("plugin" in value || "native" in value) ? value[mode] : value; const escape = text => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); const starts = text => new RegExp(`^${escape(text)}`); /** Wait until the page has at least `count` elements for `selector`. The predicate is synchronous on purpose. */ export function waitForCount(page, selector, count, timeout = 60000) { return page.waitForFunction(([selector, count]) => document.querySelectorAll(selector).length >= count, [selector, count], { timeout, polling: 100 }); } /** Open a command from the command palette by its exact title. */ export async function runPaletteCommand(page, title) { await page.keyboard.press(TABLE.palette.shortcut); const input = page.getByRole("textbox", { name: TABLE.palette.input, exact: true }); await input.waitFor({ timeout: 10000 }); await input.fill(title); await page.getByRole("button", { name: starts(title) }).first().waitFor({ timeout: 10000 }); await input.press("Enter"); } /** * Run a command from the palette, from a ribbon menu, or from a ribbon button. * `where` is `palette`, `menu:`, or `ribbon: