Skip to content

Commit 79a464d

Browse files
authored
chore: Remove support for legacy postInteractionWait type
2 parents c4c7e36 + 206ba37 commit 79a464d

6 files changed

Lines changed: 35 additions & 51 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.14.0] - 2025-12-15
9+
10+
### Removed
11+
- Support for legacy postInteractionWait type
12+
813
## [0.13.0] - 2025-12-15
914

1015
### Removed
@@ -95,6 +100,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
95100
### Added
96101
- Initial release
97102

103+
[0.14.0]: https://github.com/gooddata/gooddata-neobackstop/compare/v0.13.0...v0.14.0
98104
[0.13.0]: https://github.com/gooddata/gooddata-neobackstop/compare/v0.12.0...v0.13.0
99105
[0.12.0]: https://github.com/gooddata/gooddata-neobackstop/compare/v0.11.1...v0.12.0
100106
[0.11.1]: https://github.com/gooddata/gooddata-neobackstop/compare/v0.11.0...v0.11.1

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.13.0
1+
0.14.0

converters/converters.go

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,14 @@
11
package converters
22

33
import (
4-
"fmt"
54
"sort"
6-
"time"
75

86
"github.com/gooddata/gooddata-neobackstop/browser"
97
"github.com/gooddata/gooddata-neobackstop/internals"
108
"github.com/gooddata/gooddata-neobackstop/scenario"
119
"github.com/gooddata/gooddata-neobackstop/viewport"
1210
)
1311

14-
func convertSelectorOrDelay(value interface{}) *internals.SelectorThenDelay {
15-
if value == nil {
16-
return nil
17-
}
18-
19-
var sod internals.SelectorThenDelay
20-
// check type
21-
switch piw := value.(type) {
22-
case string:
23-
// legacy format: selector
24-
sod = internals.SelectorThenDelay{
25-
Selector: &piw,
26-
}
27-
case float64:
28-
// legacy format: timeout
29-
d := time.Duration(piw) * time.Millisecond
30-
sod = internals.SelectorThenDelay{
31-
Delay: &d,
32-
}
33-
case map[string]interface{}:
34-
// new format: object with selector, delay
35-
if v, ok := piw["selector"].(string); ok {
36-
sod.Selector = &v
37-
}
38-
if v, ok := piw["delay"].(float64); ok {
39-
d := time.Duration(v) * time.Millisecond
40-
sod.Delay = &d
41-
}
42-
default:
43-
fmt.Println(piw)
44-
panic("Unknown PostInteractionWait type")
45-
}
46-
47-
return &sod
48-
}
49-
5012
func scenarioToInternal(b browser.Browser, v viewport.Viewport, s scenario.Scenario) internals.Scenario {
5113
return internals.Scenario{
5214
Browser: b,
@@ -62,7 +24,7 @@ func scenarioToInternal(b browser.Browser, v viewport.Viewport, s scenario.Scena
6224
HoverSelectors: s.HoverSelectors,
6325
ClickSelector: s.ClickSelector,
6426
ClickSelectors: s.ClickSelectors,
65-
PostInteractionWait: convertSelectorOrDelay(s.PostInteractionWait),
27+
PostInteractionWait: s.PostInteractionWait,
6628
ScrollToSelector: s.ScrollToSelector,
6729
MisMatchThreshold: s.MisMatchThreshold,
6830
}

internals/types.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
package internals
22

33
import (
4-
"time"
5-
64
"github.com/gooddata/gooddata-neobackstop/browser"
75
"github.com/gooddata/gooddata-neobackstop/scenario"
86
"github.com/gooddata/gooddata-neobackstop/viewport"
97
)
108

11-
type SelectorThenDelay struct {
12-
Selector *string `json:"selector"`
13-
Delay *time.Duration `json:"delay"`
14-
}
15-
169
// Scenario - An internal scenario type, properties in order of processing, constructed from scenario.Scenario and config.Config
1710
// this type is exposed in ci-report so needs json keys
1811
type Scenario struct {
@@ -29,7 +22,7 @@ type Scenario struct {
2922
HoverSelectors []scenario.SelectorWithBeforeAfterDelay `json:"hoverSelectors"`
3023
ClickSelector *string `json:"clickSelector"`
3124
ClickSelectors []scenario.SelectorWithBeforeAfterDelay `json:"clickSelectors"`
32-
PostInteractionWait *SelectorThenDelay `json:"postInteractionWait"`
25+
PostInteractionWait *scenario.SelectorThenDelay `json:"postInteractionWait"`
3326
ScrollToSelector *string `json:"scrollToSelector"`
3427
MisMatchThreshold *float64 `json:"misMatchThreshold"`
3528
}

scenario/types.go

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,29 @@ func (d *SelectorWithBeforeAfterDelay) UnmarshalJSON(data []byte) error {
6262
return nil
6363
}
6464

65+
type SelectorThenDelay struct {
66+
Selector *string `json:"selector"`
67+
Delay *time.Duration `json:"delay"`
68+
}
69+
70+
func (d *SelectorThenDelay) UnmarshalJSON(data []byte) error {
71+
var raw struct {
72+
Selector *string `json:"selector"`
73+
Delay *float64 `json:"delay"`
74+
}
75+
76+
if err := json.Unmarshal(data, &raw); err != nil {
77+
return err
78+
}
79+
80+
d.Selector = raw.Selector
81+
if raw.Delay != nil {
82+
t := time.Duration(*raw.Delay) * time.Millisecond
83+
d.Delay = &t
84+
}
85+
return nil
86+
}
87+
6588
// Scenario - properties in order of processing, scenarios.json must be an array of Scenario
6689
type Scenario struct {
6790
Browsers []browser.Browser `json:"browsers"`
@@ -77,7 +100,7 @@ type Scenario struct {
77100
HoverSelectors []SelectorWithBeforeAfterDelay `json:"hoverSelectors"`
78101
ClickSelector *string `json:"clickSelector"`
79102
ClickSelectors []SelectorWithBeforeAfterDelay `json:"clickSelectors"`
80-
PostInteractionWait interface{} `json:"postInteractionWait"`
103+
PostInteractionWait *SelectorThenDelay `json:"postInteractionWait"`
81104
ScrollToSelector *string `json:"scrollToSelector"`
82105
MisMatchThreshold *float64 `json:"misMatchThreshold"`
83106
}

screenshotter/operations/postInteractionWait.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ package operations
33
import (
44
"time"
55

6-
"github.com/gooddata/gooddata-neobackstop/internals"
6+
"github.com/gooddata/gooddata-neobackstop/scenario"
77
"github.com/playwright-community/playwright-go"
88
)
99

10-
func postInteractionWait(page playwright.Page, piw *internals.SelectorThenDelay) *string {
10+
func postInteractionWait(page playwright.Page, piw *scenario.SelectorThenDelay) *string {
1111
if piw != nil {
1212
if piw.Selector != nil {
1313
// selector, wait for it

0 commit comments

Comments
 (0)