Luigit
repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by admin

quickshell/nuguland/features/notifications/fixtures/load.qml

Raw
import QtQuick
import QtQuick.Window
import Quickshell
import "../../.." as N
import "../../../features/notifications" as NotificationsFeature

// `just load-test notifications`: the registry entry's own panel, bound to the
// notifications double the load harness overlays. The double's notification
// renders and lights the bar chip, a reply edit reaches the service, and
// clearing all empties the panel and the chip. No D-Bus, compositor, input, or pixels.
ShellRoot {
    id: root

    readonly property N.FeatureEntry feature: registry.popup("notifications")
    readonly property NotificationsFeature.NotificationGroup panel: loader.item as NotificationsFeature.NotificationGroup
    property int step: 0
    // The overlaid double's fixture surface; production Notifications has no fixtureState.
    readonly property var notificationsDouble: registry.notifications

    function finish(): void {
        const panel = root.panel;
        if (!panel)
            return;
        if (root.step === 0 && panel.groups.length === 1 && root.feature.barLabel === "alerts" && root.feature.barActive) {
            root.step = 1;
            panel.editReply("notification-fixture", "draft");
        } else if (root.step === 1 && root.notificationsDouble.fixtureState().edits === 1 && root.notificationsDouble.fixtureState().hasDraft) {
            root.step = 2;
            panel.clearAll();
        } else if (root.step === 2 && panel.groups.length === 0 && !root.feature.barActive) {
            console.log("load notifications: PASS");
            Qt.quit();
        }
    }

    N.Theme {
        id: nuguTheme
    }

    N.Registry {
        id: registry

        theme: nuguTheme
    }

    // Plain Window: Quickshell windows set input masks the offscreen platform rejects.
    Window {
        width: 528
        height: 428
        visible: true
        color: "transparent"

        Loader {
            id: loader

            anchors.fill: parent
            sourceComponent: root.feature ? root.feature.panel : null
        }
    }

    Timer {
        interval: 25
        running: true
        repeat: true
        onTriggered: root.finish()
    }

    Timer {
        interval: 5000
        running: true
        onTriggered: {
            console.error("ERROR load notifications: registry panel never followed the double");
            Qt.quit();
        }
    }
}