-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(@desktop/wallet): New Error component defined for simple send
fixes #16707
- Loading branch information
1 parent
77368f4
commit eaf3ada
Showing
8 changed files
with
391 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import QtQuick 2.14 | ||
import QtQuick.Controls 2.14 | ||
import QtQuick.Layouts 1.14 | ||
|
||
import StatusQ.Core 0.1 | ||
import StatusQ.Core.Theme 0.1 | ||
|
||
import Storybook 1.0 | ||
|
||
import utils 1.0 | ||
|
||
import AppLayouts.Wallet.controls 1.0 | ||
|
||
SplitView { | ||
id: root | ||
|
||
orientation: Qt.Vertical | ||
|
||
Rectangle { | ||
SplitView.fillHeight: true | ||
SplitView.fillWidth: true | ||
color: Theme.palette.baseColor3 | ||
RouterErrorTag { | ||
anchors.centerIn: parent | ||
width: 400 | ||
|
||
errorTitle: ctrlText.text | ||
buttonText: ctrlButtonText.text | ||
errorDetails: ctrlErrorDetails.text | ||
expandable: expandableCheckBox.checked | ||
} | ||
} | ||
|
||
Pane { | ||
ColumnLayout { | ||
CheckBox { | ||
id: expandableCheckBox | ||
text: "expandable" | ||
} | ||
RowLayout { | ||
Layout.fillWidth: true | ||
Label { text: "Text:" } | ||
TextField { | ||
id: ctrlText | ||
Layout.fillWidth: true | ||
text: "Not enough ETH to pay gas fees" | ||
} | ||
} | ||
RowLayout { | ||
Layout.fillWidth: true | ||
Label { text: "Button text:" } | ||
TextField { | ||
id: ctrlButtonText | ||
Layout.fillWidth: true | ||
text: "Add ETH" | ||
} | ||
} | ||
RowLayout { | ||
Layout.fillWidth: true | ||
Label { text: "Asset name:" } | ||
TextField { | ||
id: ctrlAssetName | ||
Layout.fillWidth: true | ||
text: "warning" | ||
} | ||
} | ||
RowLayout { | ||
Layout.fillWidth: true | ||
Label { text: "Error Details:" } | ||
TextField { | ||
id: ctrlErrorDetails | ||
Layout.fillWidth: true | ||
text: "Error Details will be displayed here" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
// category: Views |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
import QtQuick 2.15 | ||
import QtTest 1.15 | ||
|
||
import AppLayouts.Wallet.controls 1.0 | ||
|
||
Item { | ||
id: root | ||
width: 600 | ||
height: 400 | ||
|
||
Component { | ||
id: componentUnderTest | ||
RouterErrorTag { | ||
anchors.centerIn: parent | ||
errorTitle: "Not enough ETH to pay gas fees" | ||
} | ||
} | ||
|
||
SignalSpy { | ||
id: signalSpy | ||
target: controlUnderTest | ||
signalName: "buttonClicked" | ||
} | ||
|
||
property RouterErrorTag controlUnderTest: null | ||
|
||
TestCase { | ||
name: "RouterErrorTag" | ||
when: windowShown | ||
|
||
function init() { | ||
controlUnderTest = createTemporaryObject(componentUnderTest, root) | ||
signalSpy.clear() | ||
} | ||
|
||
function test_basicGeometry() { | ||
verify(!!controlUnderTest) | ||
verify(controlUnderTest.width > 0) | ||
verify(controlUnderTest.height > 0) | ||
} | ||
|
||
function test_DefaultState() { | ||
verify(!!controlUnderTest) | ||
const errorTitle = findChild(controlUnderTest, "errorTitle") | ||
verify(!!errorTitle) | ||
verify(errorTitle.visible) | ||
const button = findChild(controlUnderTest, "addBalanceButton") | ||
verify(!!button) | ||
verify(!button.visible) | ||
const expandButton = findChild(controlUnderTest, "expandButton") | ||
verify(!!expandButton) | ||
verify(!expandButton.visible) | ||
const errorDetails = findChild(controlUnderTest, "errorDetails") | ||
verify(!!errorDetails) | ||
verify(!errorDetails.visible) | ||
} | ||
|
||
function test_correctWidthWithButtonOrWithout() { | ||
verify(!!controlUnderTest) | ||
waitForRendering(controlUnderTest) | ||
const origWidth = controlUnderTest.width | ||
|
||
controlUnderTest.buttonText = "Add assets" | ||
waitForRendering(controlUnderTest) | ||
const widthWithButton = controlUnderTest.width | ||
verify(widthWithButton > origWidth) | ||
|
||
controlUnderTest.buttonText = "" | ||
waitForRendering(controlUnderTest) | ||
verify(controlUnderTest.width < widthWithButton) | ||
} | ||
|
||
function test_addButtonClick() { | ||
verify(!!controlUnderTest) | ||
controlUnderTest.buttonText = "Add assets" | ||
const button = findChild(controlUnderTest, "addBalanceButton") | ||
verify(!!button) | ||
verify(button.visible) | ||
mouseClick(button) | ||
tryCompare(signalSpy, "count", 1) | ||
} | ||
|
||
function test_detailsVisibleOnceItHasValidText() { | ||
verify(!!controlUnderTest) | ||
const errorDetails = findChild(controlUnderTest, "errorDetails") | ||
verify(!!errorDetails) | ||
verify(!errorDetails.visible) | ||
|
||
controlUnderTest.errorDetails = "Added some details here" | ||
verify(errorDetails.visible) | ||
} | ||
|
||
function test_expandableOption() { | ||
verify(!!controlUnderTest) | ||
controlUnderTest.buttonText = "Add assets" | ||
controlUnderTest.errorDetails = "Added some details here" | ||
|
||
const errorTitle = findChild(controlUnderTest, "errorTitle") | ||
verify(!!errorTitle) | ||
const button = findChild(controlUnderTest, "addBalanceButton") | ||
verify(!!button) | ||
const expandButton = findChild(controlUnderTest, "expandButton") | ||
verify(!!expandButton) | ||
const errorDetails = findChild(controlUnderTest, "errorDetails") | ||
verify(!!errorDetails) | ||
|
||
controlUnderTest.expandable = true | ||
verify(errorTitle.visible) | ||
verify(!button.visible) | ||
verify(expandButton.visible) | ||
compare(expandButton.text, qsTr("+ Show details")) | ||
verify(!errorDetails.visible) | ||
|
||
mouseClick(expandButton) | ||
compare(expandButton.text, qsTr("- Hide details")) | ||
verify(errorDetails.visible) | ||
|
||
controlUnderTest.expandable = false | ||
verify(errorTitle.visible) | ||
verify(button.visible) | ||
verify(!expandButton.visible) | ||
verify(errorDetails.visible) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.