Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F7892284
tst_AddStickerPopup.qml
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
tst_AddStickerPopup.qml
View Options
/*
* This file is part of kazv.
* SPDX-FileCopyrightText: 2024 tusooa <tusooa@kazv.moe>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import
QtQuick
2.15
import
QtQuick
.
Layouts
1.15
import
QtTest
1.0
import
org
.
kde
.
kirigami
2.20
as
Kirigami
import
'../../contents/ui'
as
Kazv
import
'test-helpers.js'
as
Helpers
import
'test-helpers'
as
TestHelpers
Item
{
id: item
width:
800
height:
600
property
var
l10n:
Helpers
.
fluentMock
property
var
mockHelper:
TestHelpers
.
MockHelper
{}
property
var
promiseComp:
Component
{
TestHelpers
.
MatrixPromiseMock
{}
}
property
var
matrixSdk:
TestHelpers
.
MatrixSdkMock
{
id: matrixSdk
property
var
updateStickerPack:
mockHelper
.
promise
()
}
Kazv
.
AddStickerPopup
{
id: addStickerPopup
event:
({
content:
{
url:
'mxc://example.org/something'
,
},
})
stickerPackList:
({
at
()
{
return
{
addSticker
(
shortCode
,
event
)
{
return
{
[
shortCode
]
:
event
.
content
};
},
hasShortCode
(
shortCode
)
{
return
shortCode
===
'foo'
;
},
};
},
})
property
var
close:
mockHelper
.
noop
()
}
TestCase
{
id: eventViewTest
name:
'EventViewTest'
when:
windowShown
function
init
()
{
addStickerPopup
.
contentItem
.
parent
=
item
;
}
function
cleanup
()
{
item
.
mockHelper
.
clearAll
();
}
function
test_addSticker
()
{
findChild
(
addStickerPopup
,
'shortCodeInput'
).
text
=
'bar'
;
verify
(
!
findChild
(
addStickerPopup
,
'shortCodeExistsWarning'
).
visible
);
const
button
=
findChild
(
addStickerPopup
,
'addStickerButton'
);
verify
(
button
.
enabled
);
// tryVerify(() => false, 50000);
mouseClick
(
button
);
tryVerify
(()
=>
matrixSdk
.
updateStickerPack
.
calledTimes
()
===
1
);
verify
(
Helpers
.
deepEqual
(
matrixSdk
.
updateStickerPack
.
lastArgs
(),
[{
'bar'
:
{
url:
'mxc://example.org/something'
,
}
}]));
tryVerify
(()
=>
!
button
.
enabled
);
tryVerify
(()
=>
findChild
(
addStickerPopup
,
'shortCodeInput'
).
readOnly
);
verify
(
addStickerPopup
.
close
.
calledTimes
()
===
0
);
matrixSdk
.
updateStickerPack
.
lastRetVal
().
resolve
(
true
,
{});
tryVerify
(()
=>
addStickerPopup
.
close
.
calledTimes
()
===
1
);
}
function
test_addStickerFailed
()
{
findChild
(
addStickerPopup
,
'shortCodeInput'
).
text
=
'bar'
;
verify
(
!
findChild
(
addStickerPopup
,
'shortCodeExistsWarning'
).
visible
);
const
button
=
findChild
(
addStickerPopup
,
'addStickerButton'
);
verify
(
button
.
enabled
);
// tryVerify(() => false, 50000);
mouseClick
(
button
);
tryVerify
(()
=>
matrixSdk
.
updateStickerPack
.
calledTimes
()
===
1
);
verify
(
Helpers
.
deepEqual
(
matrixSdk
.
updateStickerPack
.
lastArgs
(),
[{
'bar'
:
{
url:
'mxc://example.org/something'
,
}
}]));
matrixSdk
.
updateStickerPack
.
lastRetVal
().
resolve
(
false
,
{});
tryVerify
(()
=>
button
.
enabled
);
verify
(
addStickerPopup
.
close
.
calledTimes
()
===
0
);
}
function
test_addStickerOverride
()
{
findChild
(
addStickerPopup
,
'shortCodeInput'
).
text
=
'foo'
;
tryVerify
(()
=>
findChild
(
addStickerPopup
,
'shortCodeExistsWarning'
).
visible
);
const
button
=
findChild
(
addStickerPopup
,
'addStickerButton'
);
verify
(
button
.
enabled
);
// tryVerify(() => false, 50000);
mouseClick
(
button
);
tryVerify
(()
=>
matrixSdk
.
updateStickerPack
.
calledTimes
()
===
1
);
verify
(
Helpers
.
deepEqual
(
matrixSdk
.
updateStickerPack
.
lastArgs
(),
[{
'foo'
:
{
url:
'mxc://example.org/something'
,
}
}]));
tryVerify
(()
=>
!
button
.
enabled
);
tryVerify
(()
=>
findChild
(
addStickerPopup
,
'shortCodeInput'
).
readOnly
);
verify
(
addStickerPopup
.
close
.
calledTimes
()
===
0
);
matrixSdk
.
updateStickerPack
.
lastRetVal
().
resolve
(
true
,
{});
tryVerify
(()
=>
addStickerPopup
.
close
.
calledTimes
()
===
1
);
}
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Oct 2, 4:19 AM (14 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
472382
Default Alt Text
tst_AddStickerPopup.qml (3 KB)
Attached To
Mode
rK kazv
Attached
Detach File
Event Timeline
Log In to Comment