status-desktop/storybook/pages/CountdownPillPage.qml
Alex Jbanca fd99b96cb5 feat(WalletConnect): Handle sign request expiration
Implementing the user-story for sign request expiry and add qml tests
+ other minor fixes

## Acceptance Criteria

```
//Always show the expiration
Given the sign/transaction request dialog is shown
When request has an expiration date
Then the user sees a 1 minute countdown in the dialog
```

```
// Show 1 minute timer
Given the sign/transaction request dialog is shown
When the request has 1 minute or less before expiring
Then the user sees a 1 second countdown in the dialog
```

```
Given the sign/transaction dialog is open
When the request expires
Then the Accept button is removed
And the only option for the user is to close the dialog
```

```
Given the sign/transaction request dialog is open
When the request expired
Then the `Sign` and `Reject` buttons are removed
And the `Close` button is visible
```

```
Given the sign/transaction request expired
Then a toast message is showing
And it contains the "<dapp domain> sign request timed out" message
```

```
Given the sign/transaction request dialog is open
When the request expired
Then the sign/transaction request dialog is still visible
```

```
Given the sign/transaction request expires
Then a console message is shown
And it contains 'WC WalletConnectSDK.onSessionRequestExpire; id: ${id}`'
```
2024-10-10 12:49:15 +03:00

107 lines
2.8 KiB
QML

import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15
import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1
import shared.controls 1.0
import Storybook 1.0
SplitView {
orientation: Qt.Horizontal
Logs { id: logs }
Pane {
SplitView.fillWidth: true
SplitView.fillHeight: true
background: Rectangle {
color: Theme.palette.baseColor4
}
CountdownPill {
id: pill
anchors.centerIn: parent
timestamp: new Date()
expirationSeconds: 300 // 5 minutes
}
}
LogsAndControlsPanel {
SplitView.fillHeight: true
SplitView.preferredWidth: 300
logsView.logText: logs.logText
ColumnLayout {
anchors.fill: parent
Button {
text: "Set 2 days, 2 hours, 10 minutes"
onClicked: {
pill.timestamp = new Date()
pill.expirationSeconds = 180600
}
}
Button {
text: "Set 1.5 hrs"
onClicked: {
pill.timestamp = new Date()
pill.expirationSeconds = 5400
}
}
Button {
text: "Set 3 mins"
onClicked: {
pill.timestamp = new Date()
pill.expirationSeconds = 180
}
}
Button {
text: "Set 1 min"
onClicked: {
pill.timestamp = new Date()
pill.expirationSeconds = 60
}
}
Button {
text: "Set 6 secs"
onClicked: {
pill.timestamp = new Date()
pill.expirationSeconds = 6
}
}
Button {
text: "Set expired now"
onClicked: {
pill.expirationSeconds = 0
}
}
Button {
text: "Set 5 minutes (10 minutes ago) -> expired"
onClicked: {
const tenMinsAgo = new Date()
tenMinsAgo.setMinutes(tenMinsAgo.getMinutes() - 10)
pill.timestamp = tenMinsAgo
pill.expirationSeconds = 5*60
}
}
Label {
text: "Remaining secs: %1".arg(pill.remainingSeconds)
}
Label {
text: "Expired: %1".arg(pill.isExpired ? "true" : "false")
}
Item { Layout.fillHeight: true }
}
}
}
// category: Controls
// https://www.figma.com/design/HrmZp1y4S77QJezRFRl6ku/dApp-Interactions---Milestone-1?node-id=3967-288229&node-type=frame&t=lHLlTZ0aJE0Uo3l9-0