Add shell plugin model tests

This commit is contained in:
David Heinemeier Hansson
2026-05-25 14:18:39 +02:00
parent 4277f5346b
commit 829c1fa4f7
61 changed files with 3236 additions and 1168 deletions
+8 -9
View File
@@ -2,10 +2,12 @@ import Quickshell
import Quickshell.Wayland
import QtQuick
import qs.Commons
import "ReminderFlowModel.js" as ReminderFlowModel
Item {
id: root
property string omarchyPath: Quickshell.env("OMARCHY_PATH")
property var shell: null
property var manifest: null
@@ -62,15 +64,15 @@ Item {
var selection = root.filterText
if (root.step === "minutes") {
var nextMinutes = selection.trim()
var nextMinutes = ReminderFlowModel.validMinutes(selection)
if (!nextMinutes) {
if (!selection.trim()) {
root.dismiss()
return
}
if (!/^[0-9]+$/.test(nextMinutes) || Number(nextMinutes) <= 0) {
Quickshell.execDetached(["bash", "-lc", "omarchy-notification-send 'Invalid reminder' 'Enter the number of minutes'"])
if (!nextMinutes) {
Quickshell.execDetached([root.omarchyPath + "/bin/omarchy-notification-send", "Invalid reminder", "Enter the number of minutes"])
return
}
@@ -82,12 +84,9 @@ Item {
}
if (root.step === "message") {
var command = "omarchy-reminder " + Util.shellQuote(root.minutes)
if (selection.length > 0)
command += " " + Util.shellQuote(selection)
var args = [root.omarchyPath + "/bin/omarchy-reminder"].concat(ReminderFlowModel.reminderArgs(root.minutes, selection))
root.dismiss()
Quickshell.execDetached(["bash", "-lc", command])
Quickshell.execDetached(args)
}
}
@@ -0,0 +1,21 @@
function validMinutes(value) {
var minutes = String(value || "").trim()
return /^[0-9]+$/.test(minutes) && Number(minutes) > 0 ? minutes : ""
}
function reminderArgs(minutes, message) {
var valid = validMinutes(minutes)
if (!valid) return []
var args = [valid]
var text = String(message || "")
if (text.length > 0) args.push(text)
return args
}
if (typeof module !== "undefined") {
module.exports = {
validMinutes: validMinutes,
reminderArgs: reminderArgs
}
}