summaryrefslogtreecommitdiffstats
path: root/tests/tst_logview.qml
blob: 86668d724482733af649c8cfb2a0471845b04191 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
 *   Copyright 2017 Christian Mollekopf <mollekopf@kolabsys.com>
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Library General Public License as
 *   published by the Free Software Foundation; either version 2, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Library General Public License for more details
 *
 *   You should have received a copy of the GNU Library General Public
 *   License along with this program; if not, write to the
 *   Free Software Foundation, Inc.,
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Window 2.1
import QtTest 1.0
import org.kube.framework 1.0 as Kube
import "../components/kube/contents/ui/" as Components


TestCase {
    id: logviewTestcase
    width: 400
    height: 400
    name: "LogView"

    Components.LogView {
        id: logView
    }

    function test_logview() {
        var listModel = findChild(logView, "logModel");
        verify(listModel)
        compare(listModel.count, 0)
        //ignore progress
        Kube.Fabric.postMessage(Kube.Messages.progressNotification, {})
        compare(listModel.count, 0)

        Kube.Fabric.postMessage(Kube.Messages.notification, {type: Kube.Notifications.info, message: "foobar", resource: "resource"})
        compare(listModel.count, 1)
        compare(logView.pendingError, false)

        Kube.Fabric.postMessage(Kube.Messages.notification, {"type": Kube.Notifications.error, message: "foobar", resource: "resource"})
        compare(listModel.count, 2)
        compare(logView.pendingError, true)
        compare(listModel.get(0).type, Kube.Notifications.error)
        compare(listModel.get(0).errors.count, 1)
        compare(listModel.get(0).errors.get(0).message, "foobar")
        compare(listModel.get(0).errors.get(0).resource, "resource")

        Kube.Fabric.postMessage(Kube.Messages.notification, {"type": Kube.Notifications.error, "subtype": "merge", message: "merge1", resource: "resource1"})
        compare(listModel.count, 3)
        Kube.Fabric.postMessage(Kube.Messages.notification, {"type": Kube.Notifications.error, "subtype": "merge", message: "merge2", resource: "resource2"})
        compare(listModel.count, 3)
        compare(listModel.get(0).errors.count, 2)
        compare(listModel.get(0).errors.get(0).message, "merge2")
        compare(listModel.get(0).errors.get(0).resource, "resource2")
    }
}