A3: derive the pinned command and catalog key lists in tests
Each command module keeps its own COMMAND_IDS next to its commands; the engine listing test checks their union against the registry, so a missing or extra command still fails without one shared list. The menu and palette tests derive their expectation from the listing and check grouping and ordering rules; the catalog's runtime keys are scanned from the sources. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
da58c83158
commit
95fd9b926f
28 changed files with 329 additions and 262 deletions
|
|
@ -53,3 +53,8 @@ impl Command for Quit {
|
|||
Ok(Outcome::effect(Effect::Quit))
|
||||
}
|
||||
}
|
||||
|
||||
/// The ids of the commands this module registers, checked against the
|
||||
/// registry by the engine's listing test. Add a new command's id here.
|
||||
#[cfg(test)]
|
||||
pub(crate) const COMMAND_IDS: &[&str] = &["app.about", "app.quit"];
|
||||
|
|
|
|||
|
|
@ -258,3 +258,9 @@ impl Command for List {
|
|||
Ok(Outcome::value(Value::Array(list)))
|
||||
}
|
||||
}
|
||||
|
||||
/// The ids of the commands this module registers, checked against the
|
||||
/// registry by the engine's listing test. Add a new command's id here.
|
||||
#[cfg(test)]
|
||||
pub(crate) const COMMAND_IDS: &[&str] =
|
||||
&["buffer.close", "buffer.edit", "buffer.get", "buffer.list"];
|
||||
|
|
|
|||
|
|
@ -201,3 +201,8 @@ impl Command for SaveAll {
|
|||
))
|
||||
}
|
||||
}
|
||||
|
||||
/// The ids of the commands this module registers, checked against the
|
||||
/// registry by the engine's listing test. Add a new command's id here.
|
||||
#[cfg(test)]
|
||||
pub(crate) const COMMAND_IDS: &[&str] = &["file.open", "file.save", "file.saveAll"];
|
||||
|
|
|
|||
|
|
@ -955,6 +955,21 @@ impl Command for CreateBranch {
|
|||
}
|
||||
}
|
||||
|
||||
/// The ids of the commands this module registers, checked against the
|
||||
/// registry by the engine's listing test. Add a new command's id here.
|
||||
#[cfg(test)]
|
||||
pub(crate) const COMMAND_IDS: &[&str] = &[
|
||||
"git.branches",
|
||||
"git.checkout",
|
||||
"git.commit",
|
||||
"git.createBranch",
|
||||
"git.lastMessage",
|
||||
"git.show",
|
||||
"git.stage",
|
||||
"git.status",
|
||||
"git.unstage",
|
||||
];
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
|
|||
|
|
@ -114,3 +114,8 @@ impl Command for Blame {
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// The ids of the commands this module registers, checked against the
|
||||
/// registry by the engine's listing test. Add a new command's id here.
|
||||
#[cfg(test)]
|
||||
pub(crate) const COMMAND_IDS: &[&str] = &["git.blame"];
|
||||
|
|
|
|||
|
|
@ -449,6 +449,11 @@ impl Command for LineChanges {
|
|||
}
|
||||
}
|
||||
|
||||
/// The ids of the commands this module registers, checked against the
|
||||
/// registry by the engine's listing test. Add a new command's id here.
|
||||
#[cfg(test)]
|
||||
pub(crate) const COMMAND_IDS: &[&str] = &["git.lineChanges"];
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
|
|||
|
|
@ -221,3 +221,8 @@ impl Command for ShowAt {
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// The ids of the commands this module registers, checked against the
|
||||
/// registry by the engine's listing test. Add a new command's id here.
|
||||
#[cfg(test)]
|
||||
pub(crate) const COMMAND_IDS: &[&str] = &["git.log", "git.showAt", "git.showCommit"];
|
||||
|
|
|
|||
|
|
@ -208,3 +208,13 @@ impl Command for MarkResolved {
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// The ids of the commands this module registers, checked against the
|
||||
/// registry by the engine's listing test. Add a new command's id here.
|
||||
#[cfg(test)]
|
||||
pub(crate) const COMMAND_IDS: &[&str] = &[
|
||||
"git.conflictVersions",
|
||||
"git.markResolved",
|
||||
"git.merge",
|
||||
"git.mergeAbort",
|
||||
];
|
||||
|
|
|
|||
|
|
@ -699,3 +699,18 @@ impl Command for RemoteRemove {
|
|||
start(state, command, Op::Remove(p.name))
|
||||
}
|
||||
}
|
||||
|
||||
/// The ids of the commands this module registers, checked against the
|
||||
/// registry by the engine's listing test. Add a new command's id here.
|
||||
#[cfg(test)]
|
||||
pub(crate) const COMMAND_IDS: &[&str] = &[
|
||||
"git.cancel",
|
||||
"git.clone",
|
||||
"git.fetch",
|
||||
"git.pull",
|
||||
"git.push",
|
||||
"git.remoteAdd",
|
||||
"git.remoteRemove",
|
||||
"git.remoteSetUrl",
|
||||
"git.remotes",
|
||||
];
|
||||
|
|
|
|||
|
|
@ -219,3 +219,13 @@ impl Command for StashDrop {
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// The ids of the commands this module registers, checked against the
|
||||
/// registry by the engine's listing test. Add a new command's id here.
|
||||
#[cfg(test)]
|
||||
pub(crate) const COMMAND_IDS: &[&str] = &[
|
||||
"git.stash",
|
||||
"git.stashApply",
|
||||
"git.stashDrop",
|
||||
"git.stashList",
|
||||
];
|
||||
|
|
|
|||
|
|
@ -516,3 +516,8 @@ fn symbol_item(hit: &SymbolHit<'_>, container: bool) -> Value {
|
|||
}
|
||||
item
|
||||
}
|
||||
|
||||
/// The ids of the commands this module registers, checked against the
|
||||
/// registry by the engine's listing test. Add a new command's id here.
|
||||
#[cfg(test)]
|
||||
pub(crate) const COMMAND_IDS: &[&str] = &["goto.class", "goto.file", "goto.symbol", "index.status"];
|
||||
|
|
|
|||
|
|
@ -841,6 +841,11 @@ fn cap(text: &str, max: usize) -> String {
|
|||
text.get(..end).unwrap_or("").to_string()
|
||||
}
|
||||
|
||||
/// The ids of the commands this module registers, checked against the
|
||||
/// registry by the engine's listing test. Add a new command's id here.
|
||||
#[cfg(test)]
|
||||
pub(crate) const COMMAND_IDS: &[&str] = &["lsp.completion", "lsp.hover", "lsp.signatureHelp"];
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use serde_json::json;
|
||||
|
|
|
|||
|
|
@ -135,3 +135,9 @@ impl Command for Log {
|
|||
Ok(Outcome::value(json!({ "lines": state.lsp.log() })))
|
||||
}
|
||||
}
|
||||
|
||||
/// The ids of the commands this module registers, checked against the
|
||||
/// registry by the engine's listing test. Add a new command's id here.
|
||||
#[cfg(test)]
|
||||
pub(crate) const COMMAND_IDS: &[&str] =
|
||||
&["diagnostics.list", "lsp.log", "lsp.restart", "lsp.status"];
|
||||
|
|
|
|||
|
|
@ -780,6 +780,16 @@ fn notify_summary(state: &mut State, new_name: &str, applied: &edit::Applied) {
|
|||
);
|
||||
}
|
||||
|
||||
/// The ids of the commands this module registers, checked against the
|
||||
/// registry by the engine's listing test. Add a new command's id here.
|
||||
#[cfg(test)]
|
||||
pub(crate) const COMMAND_IDS: &[&str] = &[
|
||||
"lsp.definition",
|
||||
"lsp.prepareRename",
|
||||
"lsp.references",
|
||||
"lsp.rename",
|
||||
];
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
|
|||
|
|
@ -80,3 +80,33 @@ pub fn register_builtins(registry: &mut Registry) -> Result<(), EngineError> {
|
|||
git_stash::register(registry)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The id lists of every module that registers built-in commands, one entry
|
||||
/// per module. Each module keeps its own list next to its commands, so new
|
||||
/// commands in different modules never touch the same lines.
|
||||
#[cfg(test)]
|
||||
pub(crate) const BUILTIN_COMMAND_IDS: &[&[&str]] = &[
|
||||
app::COMMAND_IDS,
|
||||
buffer::COMMAND_IDS,
|
||||
file::COMMAND_IDS,
|
||||
git::COMMAND_IDS,
|
||||
git_blame::COMMAND_IDS,
|
||||
git_lines::COMMAND_IDS,
|
||||
git_log::COMMAND_IDS,
|
||||
git_merge::COMMAND_IDS,
|
||||
git_remote::COMMAND_IDS,
|
||||
git_stash::COMMAND_IDS,
|
||||
goto::COMMAND_IDS,
|
||||
lsp_assist::COMMAND_IDS,
|
||||
lsp_diagnostics::COMMAND_IDS,
|
||||
lsp_nav::COMMAND_IDS,
|
||||
project::COMMAND_IDS,
|
||||
recovery::COMMAND_IDS,
|
||||
search::COMMAND_IDS,
|
||||
settings::COMMAND_IDS,
|
||||
syntax::COMMAND_IDS,
|
||||
terminal::COMMAND_IDS,
|
||||
theme::COMMAND_IDS,
|
||||
toolchain::COMMAND_IDS,
|
||||
ui::COMMAND_IDS,
|
||||
];
|
||||
|
|
|
|||
|
|
@ -230,3 +230,13 @@ impl Command for Children {
|
|||
})))
|
||||
}
|
||||
}
|
||||
|
||||
/// The ids of the commands this module registers, checked against the
|
||||
/// registry by the engine's listing test. Add a new command's id here.
|
||||
#[cfg(test)]
|
||||
pub(crate) const COMMAND_IDS: &[&str] = &[
|
||||
"project.children",
|
||||
"project.close",
|
||||
"project.open",
|
||||
"project.openDialog",
|
||||
];
|
||||
|
|
|
|||
|
|
@ -204,3 +204,8 @@ impl Command for Discard {
|
|||
Ok(Outcome::value(json!({ "discarded": discarded })))
|
||||
}
|
||||
}
|
||||
|
||||
/// The ids of the commands this module registers, checked against the
|
||||
/// registry by the engine's listing test. Add a new command's id here.
|
||||
#[cfg(test)]
|
||||
pub(crate) const COMMAND_IDS: &[&str] = &["recovery.discard", "recovery.list", "recovery.restore"];
|
||||
|
|
|
|||
|
|
@ -302,3 +302,8 @@ impl From<lutra_search::Match> for SearchMatch {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The ids of the commands this module registers, checked against the
|
||||
/// registry by the engine's listing test. Add a new command's id here.
|
||||
#[cfg(test)]
|
||||
pub(crate) const COMMAND_IDS: &[&str] = &["search.cancel", "search.find"];
|
||||
|
|
|
|||
|
|
@ -167,3 +167,13 @@ fn finish(
|
|||
.ok_or_else(|| EngineError::Internal(format!("setting vanished: {key}")))?;
|
||||
Ok(Outcome::value(json!({ "value": value })))
|
||||
}
|
||||
|
||||
/// The ids of the commands this module registers, checked against the
|
||||
/// registry by the engine's listing test. Add a new command's id here.
|
||||
#[cfg(test)]
|
||||
pub(crate) const COMMAND_IDS: &[&str] = &[
|
||||
"settings.get",
|
||||
"settings.list",
|
||||
"settings.reset",
|
||||
"settings.set",
|
||||
];
|
||||
|
|
|
|||
|
|
@ -581,6 +581,11 @@ impl Command for OutlineCommand {
|
|||
}
|
||||
}
|
||||
|
||||
/// The ids of the commands this module registers, checked against the
|
||||
/// registry by the engine's listing test. Add a new command's id here.
|
||||
#[cfg(test)]
|
||||
pub(crate) const COMMAND_IDS: &[&str] = &["syntax.outline"];
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
|
|||
|
|
@ -400,6 +400,16 @@ pub fn pump(state: &mut State) {
|
|||
}
|
||||
}
|
||||
|
||||
/// The ids of the commands this module registers, checked against the
|
||||
/// registry by the engine's listing test. Add a new command's id here.
|
||||
#[cfg(test)]
|
||||
pub(crate) const COMMAND_IDS: &[&str] = &[
|
||||
"terminal.close",
|
||||
"terminal.create",
|
||||
"terminal.input",
|
||||
"terminal.resize",
|
||||
];
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use serde_json::json;
|
||||
|
|
|
|||
|
|
@ -100,3 +100,8 @@ impl Command for SystemPreference {
|
|||
Ok(Outcome::value(Value::Object(fields)))
|
||||
}
|
||||
}
|
||||
|
||||
/// The ids of the commands this module registers, checked against the
|
||||
/// registry by the engine's listing test. Add a new command's id here.
|
||||
#[cfg(test)]
|
||||
pub(crate) const COMMAND_IDS: &[&str] = &["theme.list", "theme.systemPreference"];
|
||||
|
|
|
|||
|
|
@ -639,6 +639,11 @@ impl Command for DownloadPhpactor {
|
|||
}
|
||||
}
|
||||
|
||||
/// The ids of the commands this module registers, checked against the
|
||||
/// registry by the engine's listing test. Add a new command's id here.
|
||||
#[cfg(test)]
|
||||
pub(crate) const COMMAND_IDS: &[&str] = &["toolchain.downloadPhpactor", "toolchain.status"];
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::io::{Read, Write};
|
||||
|
|
|
|||
|
|
@ -182,6 +182,11 @@ pub fn dispatch(state: &mut State, id: &str, params: Value) -> Option<Outcome> {
|
|||
Some(Outcome::value(Value::Null))
|
||||
}
|
||||
|
||||
/// The ids of the commands this module registers, checked against the
|
||||
/// registry by the engine's listing test. Add a new command's id here.
|
||||
#[cfg(test)]
|
||||
pub(crate) const COMMAND_IDS: &[&str] = &["ui.registerCommands"];
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::valid_id;
|
||||
|
|
|
|||
|
|
@ -467,91 +467,23 @@ mod tests {
|
|||
let mut engine = Engine::new().unwrap();
|
||||
engine.register(Box::new(Disabled)).unwrap();
|
||||
let list = engine.list_commands();
|
||||
let ids: Vec<_> = list.iter().map(|c| c.id.as_str()).collect();
|
||||
assert_eq!(
|
||||
ids,
|
||||
vec![
|
||||
"app.about",
|
||||
"app.quit",
|
||||
"buffer.close",
|
||||
"buffer.edit",
|
||||
"buffer.get",
|
||||
"buffer.list",
|
||||
"diagnostics.list",
|
||||
"file.open",
|
||||
"file.save",
|
||||
"file.saveAll",
|
||||
"git.blame",
|
||||
"git.branches",
|
||||
"git.cancel",
|
||||
"git.checkout",
|
||||
"git.clone",
|
||||
"git.commit",
|
||||
"git.conflictVersions",
|
||||
"git.createBranch",
|
||||
"git.fetch",
|
||||
"git.lastMessage",
|
||||
"git.lineChanges",
|
||||
"git.log",
|
||||
"git.markResolved",
|
||||
"git.merge",
|
||||
"git.mergeAbort",
|
||||
"git.pull",
|
||||
"git.push",
|
||||
"git.remoteAdd",
|
||||
"git.remoteRemove",
|
||||
"git.remoteSetUrl",
|
||||
"git.remotes",
|
||||
"git.show",
|
||||
"git.showAt",
|
||||
"git.showCommit",
|
||||
"git.stage",
|
||||
"git.stash",
|
||||
"git.stashApply",
|
||||
"git.stashDrop",
|
||||
"git.stashList",
|
||||
"git.status",
|
||||
"git.unstage",
|
||||
"goto.class",
|
||||
"goto.file",
|
||||
"goto.symbol",
|
||||
"index.status",
|
||||
"lsp.completion",
|
||||
"lsp.definition",
|
||||
"lsp.hover",
|
||||
"lsp.log",
|
||||
"lsp.prepareRename",
|
||||
"lsp.references",
|
||||
"lsp.rename",
|
||||
"lsp.restart",
|
||||
"lsp.signatureHelp",
|
||||
"lsp.status",
|
||||
"project.children",
|
||||
"project.close",
|
||||
"project.open",
|
||||
"project.openDialog",
|
||||
"recovery.discard",
|
||||
"recovery.list",
|
||||
"recovery.restore",
|
||||
"search.cancel",
|
||||
"search.find",
|
||||
"settings.get",
|
||||
"settings.list",
|
||||
"settings.reset",
|
||||
"settings.set",
|
||||
"syntax.outline",
|
||||
"terminal.close",
|
||||
"terminal.create",
|
||||
"terminal.input",
|
||||
"terminal.resize",
|
||||
"test.disabled",
|
||||
"theme.list",
|
||||
"theme.systemPreference",
|
||||
"toolchain.downloadPhpactor",
|
||||
"toolchain.status",
|
||||
"ui.registerCommands",
|
||||
]
|
||||
let ids: Vec<&str> = list.iter().map(|c| c.id.as_str()).collect();
|
||||
let mut sorted = ids.clone();
|
||||
sorted.sort_unstable();
|
||||
assert_eq!(ids, sorted, "the listing is sorted by id");
|
||||
let mut expected: Vec<&str> = cmd::BUILTIN_COMMAND_IDS
|
||||
.iter()
|
||||
.flat_map(|ids| ids.iter().copied())
|
||||
.chain(["test.disabled"])
|
||||
.collect();
|
||||
expected.sort_unstable();
|
||||
let missing: Vec<_> = expected.iter().filter(|id| !ids.contains(id)).collect();
|
||||
let extra: Vec<_> = ids.iter().filter(|id| !expected.contains(id)).collect();
|
||||
assert!(
|
||||
missing.is_empty() && extra.is_empty(),
|
||||
"registered but not in a module's COMMAND_IDS: {extra:?}; listed in COMMAND_IDS but not registered: {missing:?}"
|
||||
);
|
||||
assert_eq!(ids, expected, "no id is listed twice");
|
||||
let by_id = |id: &str| list.iter().find(|c| c.id == id).unwrap();
|
||||
let quit = by_id("app.quit");
|
||||
assert_eq!(quit.default_shortcut.as_deref(), Some("Mod+Q"));
|
||||
|
|
|
|||
|
|
@ -38,108 +38,85 @@ const usedKeys = sourceFiles(SRC).flatMap((file) =>
|
|||
})),
|
||||
);
|
||||
|
||||
/** Root of the repository. */
|
||||
const REPO = join(SRC, "..", "..");
|
||||
|
||||
/**
|
||||
* Lists the Rust files below a directory, leaving out `tests` directories
|
||||
* and build output.
|
||||
*
|
||||
* @param dir - the directory.
|
||||
*/
|
||||
function rustFiles(dir: string): string[] {
|
||||
return readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {
|
||||
const path = join(dir, entry.name);
|
||||
if (entry.isDirectory()) {
|
||||
return ["tests", "target", "node_modules"].includes(entry.name) ? [] : rustFiles(path);
|
||||
}
|
||||
return entry.name.endsWith(".rs") ? [path] : [];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* The shipped part of a Rust file: everything before its unit test module.
|
||||
*
|
||||
* @param file - the path.
|
||||
*/
|
||||
function shippedRust(file: string): string {
|
||||
return readFileSync(file, "utf8").replace(/\r\n/g, "\n").split("\n#[cfg(test)]\nmod tests")[0] ?? "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns a settings enum value into its key segment (`lutra-dark` →
|
||||
* `lutraDark`).
|
||||
*
|
||||
* @param value - the value as the engine stores it.
|
||||
*/
|
||||
function camel(value: string): string {
|
||||
return value.replace(/-([a-z0-9])/g, (_, c: string) => c.toUpperCase());
|
||||
}
|
||||
|
||||
/**
|
||||
* Keys the source never passes to `t` literally because they arrive at
|
||||
* runtime: theme labels from `theme.list`, the settings' `labelKey`,
|
||||
* `descriptionKey`, section names and enum value names from
|
||||
* `settings.list`, the `messageKey` of
|
||||
* `notification` events (engine and desktop host), the keys the
|
||||
* notifications store passes through a constant, and the Changes
|
||||
* window's commit toasts (M4.2), the branch toasts (M4.5), the merge
|
||||
* toasts (M4.8) and the remote toasts (M4.10), passed as
|
||||
* `messageKey`.
|
||||
* runtime, derived from the source so new ones need no list here:
|
||||
*
|
||||
* - any `notification.*` literal: the `messageKey` of `notification`
|
||||
* events (engine and desktop host) and of the toasts the frontend raises;
|
||||
* - Rust `*_key: "…"` fields: theme labels and the settings' `labelKey`
|
||||
* and `descriptionKey`;
|
||||
* - per settings definition, its section name (`settings.section.<s>`) and
|
||||
* each enum value (`settings.<key>.value.<value>`).
|
||||
*/
|
||||
const RUNTIME_KEYS = new Set([
|
||||
"notification.command.failed",
|
||||
"notification.lsp.failed",
|
||||
"notification.lsp.message",
|
||||
"notification.lsp.renamed",
|
||||
"notification.project.notLocal",
|
||||
"notification.project.openFailed",
|
||||
"notification.project.unsavedChanges",
|
||||
"notification.recovery.corrupt",
|
||||
"notification.recovery.unavailable",
|
||||
"notification.recovery.writeFailed",
|
||||
"notification.save.failed",
|
||||
"notification.vcs.branchCreated",
|
||||
"notification.vcs.checkedOut",
|
||||
"notification.vcs.checkoutFailed",
|
||||
"notification.vcs.checkoutNotSaved",
|
||||
"notification.vcs.historyNoFile",
|
||||
"notification.vcs.commitNotSaved",
|
||||
"notification.vcs.committed",
|
||||
"notification.vcs.mergeAborted",
|
||||
"notification.vcs.mergeConflicts",
|
||||
"notification.vcs.mergeFailed",
|
||||
"notification.vcs.mergeNotSaved",
|
||||
"notification.vcs.mergeUpToDate",
|
||||
"notification.vcs.merged",
|
||||
"notification.vcs.newBranchFailed",
|
||||
"notification.vcs.cloned",
|
||||
"notification.vcs.fetchFailed",
|
||||
"notification.vcs.fetched",
|
||||
"notification.vcs.pullFailed",
|
||||
"notification.vcs.pullNotSaved",
|
||||
"notification.vcs.pulled",
|
||||
"notification.vcs.pushFailed",
|
||||
"notification.vcs.pushed",
|
||||
"notification.vcs.pushedUpstream",
|
||||
"notification.vcs.remoteCancelled",
|
||||
"notification.vcs.resolved",
|
||||
"notification.vcs.stashApplied",
|
||||
"notification.vcs.stashDropped",
|
||||
"notification.vcs.stashPopped",
|
||||
"notification.vcs.stashed",
|
||||
"notification.settings.corrupt",
|
||||
"notification.settings.corruptNotMoved",
|
||||
"notification.settings.unavailable",
|
||||
"notification.toolchain.downloadDone",
|
||||
"notification.toolchain.downloadFailed",
|
||||
"notification.toolchain.downloadStarted",
|
||||
"notification.toolchain.phpMissing",
|
||||
"notification.vfs.pumpFailed",
|
||||
"notification.watch.failed",
|
||||
"settings.appearance.theme.description",
|
||||
"settings.appearance.theme.label",
|
||||
"settings.appearance.theme.value.lutraDark",
|
||||
"settings.appearance.theme.value.lutraLight",
|
||||
"settings.appearance.theme.value.system",
|
||||
"settings.editor.autosave.idleSeconds.description",
|
||||
"settings.editor.autosave.idleSeconds.label",
|
||||
"settings.editor.autosave.onBlur.description",
|
||||
"settings.editor.autosave.onBlur.label",
|
||||
"settings.editor.autosave.onTabSwitch.description",
|
||||
"settings.editor.autosave.onTabSwitch.label",
|
||||
"settings.editor.completion.autoPopup.description",
|
||||
"settings.editor.completion.autoPopup.label",
|
||||
"settings.editor.completion.delayMs.description",
|
||||
"settings.editor.completion.delayMs.label",
|
||||
"settings.editor.fontSize.description",
|
||||
"settings.editor.fontSize.label",
|
||||
"settings.editor.hover.delayMs.description",
|
||||
"settings.editor.hover.delayMs.label",
|
||||
"settings.git.executable.description",
|
||||
"settings.git.executable.label",
|
||||
"settings.git.pull.mode.description",
|
||||
"settings.git.pull.mode.label",
|
||||
"settings.git.pull.mode.value.merge",
|
||||
"settings.git.pull.mode.value.rebase",
|
||||
"settings.php.executable.description",
|
||||
"settings.php.executable.label",
|
||||
"settings.phpactor.autoDownload.description",
|
||||
"settings.phpactor.autoDownload.label",
|
||||
"settings.phpactor.path.description",
|
||||
"settings.phpactor.path.label",
|
||||
"settings.section.appearance",
|
||||
"settings.section.editor",
|
||||
"settings.section.git",
|
||||
"settings.section.php",
|
||||
"settings.ui.language.description",
|
||||
"settings.ui.language.label",
|
||||
"settings.ui.language.value.en",
|
||||
"theme.lutraDark",
|
||||
"theme.lutraLight",
|
||||
]);
|
||||
const RUNTIME_KEYS = (() => {
|
||||
const keys = new Set<string>();
|
||||
const add = (text: string, pattern: RegExp): void => {
|
||||
for (const m of text.matchAll(pattern)) {
|
||||
keys.add(m[1] ?? "");
|
||||
}
|
||||
};
|
||||
for (const file of sourceFiles(SRC)) {
|
||||
add(readFileSync(file, "utf8"), /["'`](notification\.[A-Za-z0-9.]+)["'`]/g);
|
||||
}
|
||||
for (const file of [...rustFiles(join(REPO, "crates")), ...rustFiles(join(REPO, "apps"))]) {
|
||||
const text = shippedRust(file);
|
||||
add(text, /"(notification\.[A-Za-z0-9.]+)"/g);
|
||||
add(text, /\b[a-z]+_key:\s*"([a-z][A-Za-z0-9.]*)"/g);
|
||||
for (const def of text.matchAll(/\bDef\s*\{([\s\S]*?)\n\s*\},?\n/g)) {
|
||||
const body = def[1] ?? "";
|
||||
const key = /\bkey:\s*"([^"]+)"/.exec(body)?.[1];
|
||||
const section = /\bsection:\s*"([^"]+)"/.exec(body)?.[1];
|
||||
if (section !== undefined) {
|
||||
keys.add(`settings.section.${section}`);
|
||||
}
|
||||
const values = /Kind::Enum\(&\[([^\]]*)\]\)/.exec(body)?.[1] ?? "";
|
||||
for (const value of values.matchAll(/"([^"]+)"/g)) {
|
||||
keys.add(`settings.${key ?? ""}.value.${camel(value[1] ?? "")}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
keys.delete("");
|
||||
return keys;
|
||||
})();
|
||||
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks();
|
||||
|
|
@ -206,6 +183,19 @@ describe("en.json", () => {
|
|||
expect(missing).toEqual([]);
|
||||
});
|
||||
|
||||
it("finds the runtime keys of every source", () => {
|
||||
for (const key of [
|
||||
"notification.vcs.committed",
|
||||
"notification.project.unsavedChanges",
|
||||
"settings.editor.fontSize.label",
|
||||
"settings.section.git",
|
||||
"settings.appearance.theme.value.lutraDark",
|
||||
"theme.lutraLight",
|
||||
]) {
|
||||
expect(RUNTIME_KEYS.has(key), key).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
it("has every runtime key", () => {
|
||||
expect([...RUNTIME_KEYS].filter((key) => !hasMessage(key))).toEqual([]);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -255,49 +255,32 @@ describe("AppMenu", () => {
|
|||
expect(menu.find("[data-test=menu-button]").attributes("aria-expanded")).toBe("true");
|
||||
const headings = [...document.querySelectorAll("[data-test=menu-group]")].map((g) => g.querySelector(".app-menu__heading")?.textContent.trim());
|
||||
expect(headings).toEqual(["File", "Edit", "View", "Go", "Git", "Help"]);
|
||||
expect(itemIds()).toEqual([
|
||||
const listed = listing() as { id: string; menuPath: string | null }[];
|
||||
const withPath = listed.filter((c) => c.menuPath !== null);
|
||||
expect([...itemIds()].sort()).toEqual(withPath.map((c) => c.id).sort());
|
||||
const groups = [...document.querySelectorAll("[data-test=menu-group]")].map((g) => ({
|
||||
heading: g.querySelector(".app-menu__heading")?.textContent.trim() ?? "",
|
||||
ids: [...g.querySelectorAll<HTMLElement>("[data-test=menu-item]")].map((el) => el.dataset.command ?? ""),
|
||||
labels: [...g.querySelectorAll<HTMLElement>("[data-test=menu-item]")].map((el) => el.querySelector(".app-menu__label")?.textContent.trim() ?? ""),
|
||||
}));
|
||||
for (const group of groups) {
|
||||
for (const id of group.ids) {
|
||||
expect(withPath.find((c) => c.id === id)?.menuPath?.split("/")[0], id).toBe(group.heading);
|
||||
}
|
||||
}
|
||||
expect(groups.find((g) => g.heading === "File")?.ids).toEqual([
|
||||
"project.openDialog",
|
||||
"file.save",
|
||||
"file.saveAll",
|
||||
"buffer.close",
|
||||
"project.close",
|
||||
"app.quit",
|
||||
"editor.complete",
|
||||
"editor.parameterInfo",
|
||||
"editor.quickDocumentation",
|
||||
"palette.open",
|
||||
"view.toggleProjectTree",
|
||||
"view.toggleStructure",
|
||||
"find.open",
|
||||
"terminal.open",
|
||||
"problems.open",
|
||||
"settings.open",
|
||||
"goto.fileOpen",
|
||||
"goto.classOpen",
|
||||
"goto.symbolOpen",
|
||||
"vcs.abortMerge",
|
||||
"vcs.toggleBlame",
|
||||
"vcs.branches",
|
||||
"vcs.openChanges",
|
||||
"vcs.clone",
|
||||
"vcs.commit",
|
||||
"vcs.fetch",
|
||||
"vcs.showLog",
|
||||
"vcs.manageRemotes",
|
||||
"vcs.merge",
|
||||
"vcs.newBranch",
|
||||
"vcs.nextChange",
|
||||
"vcs.previousChange",
|
||||
"vcs.pull",
|
||||
"vcs.push",
|
||||
"vcs.refresh",
|
||||
"vcs.resolveConflicts",
|
||||
"vcs.showDiff",
|
||||
"vcs.showHistory",
|
||||
"vcs.stash",
|
||||
"vcs.showStashes",
|
||||
"app.about",
|
||||
]);
|
||||
expect(groups.find((g) => g.heading === "Go")?.ids).toEqual(["goto.fileOpen", "goto.classOpen", "goto.symbolOpen"]);
|
||||
const git = groups.find((g) => g.heading === "Git")?.labels ?? [];
|
||||
expect(git.length).toBeGreaterThan(1);
|
||||
expect(git).toEqual([...git].sort((x, y) => x.localeCompare(y)));
|
||||
expect(itemIds().at(-1)).toBe("app.about");
|
||||
const close = document.querySelector("[data-command='buffer.close']");
|
||||
expect(close?.textContent).toContain("Close Tab");
|
||||
expect(close?.querySelector("[data-test=menu-shortcut]")?.textContent).toBe("Ctrl+W");
|
||||
|
|
|
|||
|
|
@ -257,49 +257,14 @@ describe("CommandPalette", () => {
|
|||
await press(PALETTE_KEY);
|
||||
expect(wrapper.find("[data-test=palette]").exists()).toBe(true);
|
||||
expect(document.activeElement).toBe(wrapper.find("[data-test=palette-input]").element);
|
||||
expect(rows(wrapper)).toEqual([
|
||||
"vcs.abortMerge",
|
||||
"vcs.toggleBlame",
|
||||
"vcs.branches",
|
||||
"vcs.openChanges",
|
||||
"vcs.checkout",
|
||||
"vcs.clone",
|
||||
"project.close",
|
||||
"palette.open",
|
||||
"vcs.commit",
|
||||
"editor.complete",
|
||||
"vcs.fetch",
|
||||
"find.open",
|
||||
"goto.classOpen",
|
||||
"goto.fileOpen",
|
||||
"goto.symbolOpen",
|
||||
"vcs.showLog",
|
||||
"vcs.manageRemotes",
|
||||
"vcs.merge",
|
||||
"vcs.newBranch",
|
||||
"vcs.nextChange",
|
||||
"project.openDialog",
|
||||
"menu.open",
|
||||
"editor.parameterInfo",
|
||||
"vcs.previousChange",
|
||||
"problems.open",
|
||||
"vcs.pull",
|
||||
"vcs.push",
|
||||
"editor.quickDocumentation",
|
||||
"app.quit",
|
||||
"vcs.refresh",
|
||||
"vcs.resolveConflicts",
|
||||
"editor.reveal",
|
||||
"settings.open",
|
||||
"vcs.showCommit",
|
||||
"vcs.showDiff",
|
||||
"vcs.showHistory",
|
||||
"view.toggleProjectTree",
|
||||
"view.toggleStructure",
|
||||
"vcs.stash",
|
||||
"vcs.showStashes",
|
||||
"terminal.open",
|
||||
]);
|
||||
const offered = (listing() as { id: string; menuPath: string | null; defaultShortcut: string | null; ui: boolean }[])
|
||||
.filter((c) => c.ui || c.menuPath !== null || c.defaultShortcut !== null)
|
||||
.map((c) => c.id);
|
||||
expect(offered).toContain("palette.open");
|
||||
expect(offered).not.toContain("buffer.edit");
|
||||
expect([...rows(wrapper)].sort()).toEqual([...offered].sort());
|
||||
const labels = wrapper.findAll("[data-test=palette-row] .palette__label").map((label) => label.text());
|
||||
expect(labels).toEqual([...labels].sort((x, y) => x.localeCompare(y)));
|
||||
const quit = wrapper.find("[data-command='app.quit']");
|
||||
expect(quit.find("[data-test=palette-shortcut]").text()).toBe("Ctrl+Q");
|
||||
expect(quit.text()).toContain("Quit");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue