Skip to content

Commit 03c9baa

Browse files
committed
SYN-4606: Add WaitForNavTimeoutDefault and MaxWaitTimeDefault
1 parent 2852754 commit 03c9baa

File tree

2 files changed

+120
-36
lines changed

2 files changed

+120
-36
lines changed

syntheticsclientv2/common_models.go

+39-35
Original file line numberDiff line numberDiff line change
@@ -82,21 +82,23 @@ type BusinessTransactions struct {
8282
}
8383

8484
type StepsV2 struct {
85-
Name string `json:"name"`
86-
Type string `json:"type"`
87-
URL string `json:"url,omitempty"`
88-
Action string `json:"action,omitempty"`
89-
WaitForNav bool `json:"waitForNav"`
90-
WaitForNavTimeout int `json:"waitForNavTimeout,omitempty"`
91-
MaxWaitTime int `json:"maxWaitTime,omitempty"`
92-
SelectorType string `json:"selectorType,omitempty"`
93-
Selector string `json:"selector,omitempty"`
94-
OptionSelectorType string `json:"optionSelectorType,omitempty"`
95-
OptionSelector string `json:"optionSelector,omitempty"`
96-
VariableName string `json:"variableName,omitempty"`
97-
Value string `json:"value,omitempty"`
98-
Options Options `json:"options,omitempty"`
99-
Duration int `json:"duration,omitempty"`
85+
Name string `json:"name"`
86+
Type string `json:"type"`
87+
URL string `json:"url,omitempty"`
88+
Action string `json:"action,omitempty"`
89+
WaitForNav bool `json:"waitForNav"`
90+
WaitForNavTimeout int `json:"waitForNavTimeout,omitempty"`
91+
WaitForNavTimeoutDefault bool `json:"waitForNavTimeoutDefault,omitempty"`
92+
MaxWaitTime int `json:"maxWaitTime,omitempty"`
93+
MaxWaitTimeDefault bool `json:"maxWaitTimeDefault,omitempty"`
94+
SelectorType string `json:"selectorType,omitempty"`
95+
Selector string `json:"selector,omitempty"`
96+
OptionSelectorType string `json:"optionSelectorType,omitempty"`
97+
OptionSelector string `json:"optionSelector,omitempty"`
98+
VariableName string `json:"variableName,omitempty"`
99+
Value string `json:"value,omitempty"`
100+
Options Options `json:"options,omitempty"`
101+
Duration int `json:"duration,omitempty"`
100102
}
101103

102104
type Options struct {
@@ -444,26 +446,28 @@ type BrowserCheckV2Input struct {
444446
}
445447

446448
type BrowserCheckV2Response struct {
447-
Test struct {
448-
Active bool `json:"active"`
449-
Advancedsettings `json:"advancedSettings"`
450-
Createdat time.Time `json:"createdAt"`
451-
Device `json:"device"`
452-
Frequency int `json:"frequency"`
453-
ID int `json:"id"`
454-
Locationids []string `json:"locationIds"`
455-
Name string `json:"name"`
456-
Schedulingstrategy string `json:"schedulingStrategy"`
457-
Transactions []Transactions `json:"transactions"`
458-
Type string `json:"type"`
459-
Updatedat time.Time `json:"updatedAt"`
460-
Customproperties []CustomProperties `json:"customProperties"`
461-
Lastrunstatus string `json:"lastRunStatus"`
462-
Lastrunat time.Time `json:"lastRunAt"`
463-
Automaticretries int `json:"automaticRetries"`
464-
Createdby string `json:"createdBy"`
465-
Updatedby string `json:"updatedBy"`
466-
} `json:"test"`
449+
Test BrowserCheckV2ResponseTest `json:"test"`
450+
}
451+
452+
type BrowserCheckV2ResponseTest struct {
453+
Active bool `json:"active"`
454+
Advancedsettings `json:"advancedSettings"`
455+
Createdat time.Time `json:"createdAt"`
456+
Device `json:"device"`
457+
Frequency int `json:"frequency"`
458+
ID int `json:"id"`
459+
Locationids []string `json:"locationIds"`
460+
Name string `json:"name"`
461+
Schedulingstrategy string `json:"schedulingStrategy"`
462+
Transactions []Transactions `json:"transactions"`
463+
Type string `json:"type"`
464+
Updatedat time.Time `json:"updatedAt"`
465+
Customproperties []CustomProperties `json:"customProperties"`
466+
Lastrunstatus string `json:"lastRunStatus"`
467+
Lastrunat time.Time `json:"lastRunAt"`
468+
Automaticretries int `json:"automaticRetries"`
469+
Createdby string `json:"createdBy"`
470+
Updatedby string `json:"updatedBy"`
467471
}
468472

469473
type CustomProperties struct {

syntheticsclientv2/get_browsercheckv2_test.go

+81-1
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,77 @@ import (
2222
"net/http"
2323
"reflect"
2424
"testing"
25+
"time"
2526
)
2627

2728
var (
28-
getBrowserCheckV2Body = `{"test":{"automaticRetries": 1, "customProperties": [{"key": "Test_Key", "value": "Test Custom Properties"}], "active":true,"advancedSettings":{"authentication":{"password":"password123","username":"myuser"},"cookies":[{"key":"qux","value":"qux","domain":"splunk.com","path":"/qux"}],"headers":[{"name":"Accept","value":"application/json","domain":"splunk.com"}],"verifyCertificates":true},"createdAt":"2022-09-14T14:35:37.801Z","device":{"id":1,"label":"iPhone","networkConnection":{"description":"Mobile LTE","downloadBandwidth":12000,"latency":70,"packetLoss":0,"uploadBandwidth":12000},"viewportHeight":844,"viewportWidth":375},"frequency":5,"id":1,"locationIds":["na-us-virginia"],"name":"My Test","schedulingStrategy":"round_robin","transactions":[{"name":"Example transaction","steps":[{"name":"element step","selector":".main","selectorType":"css","type":"click_element","waitForNav":true,"waitForNavTimeout":2000}]}],"type":"browser","updatedAt":"2022-09-14T14:35:38.099Z","lastRunAt":"2024-03-07T00:47:43.741Z","lastRunStatus":"success","createdBy":"abc1234","updatedBy":"abc1234"}}`
29+
getBrowserCheckV2Body = `{"test":{"automaticRetries": 1, "customProperties": [{"key": "Test_Key", "value": "Test Custom Properties"}], "active":true,"advancedSettings":{"authentication":{"password":"password123","username":"myuser"},"cookies":[{"key":"qux","value":"qux","domain":"splunk.com","path":"/qux"}],"headers":[{"name":"Accept","value":"application/json","domain":"splunk.com"}],"verifyCertificates":true},"createdAt":"2022-09-14T14:35:37.801Z","device":{"id":1,"label":"iPhone","networkConnection":{"description":"Mobile LTE","downloadBandwidth":12000,"latency":70,"packetLoss":0,"uploadBandwidth":12000},"viewportHeight":844,"viewportWidth":375},"frequency":5,"id":1,"locationIds":["na-us-virginia"],"name":"My Test","schedulingStrategy":"round_robin","transactions":[{"name":"Example transaction","steps":[{"name":"element step","selector":".main","selectorType":"css","type":"click_element","waitForNav":true,"waitForNavTimeout":2000,"waitForNavTimeoutDefault":true,"maxWaitTime":10000,"maxWaitTimeDefault":true}]}],"type":"browser","updatedAt":"2022-09-14T14:35:38.099Z","lastRunAt":"2024-03-07T00:47:43.741Z","lastRunStatus":"success","createdBy":"abc1234","updatedBy":"abc1234"}}`
2930
inputGetBrowserCheckV2 = verifyBrowserCheckV2Input(string(getBrowserCheckV2Body))
31+
expectedBrowserCheckV2 = BrowserCheckV2Response{
32+
Test: BrowserCheckV2ResponseTest{
33+
Automaticretries: 1,
34+
Customproperties: []CustomProperties{
35+
{Key: "Test_Key", Value: "Test Custom Properties"},
36+
},
37+
Active: true,
38+
Advancedsettings: Advancedsettings{
39+
Authentication: &Authentication{
40+
Password: "password123",
41+
Username: "myuser",
42+
},
43+
Cookiesv2: []Cookiesv2{
44+
{Key: "qux", Value: "qux", Domain: "splunk.com", Path: "/qux"},
45+
},
46+
BrowserHeaders: []BrowserHeaders{
47+
{Name: "Accept", Value: "application/json", Domain: "splunk.com"},
48+
},
49+
Verifycertificates: true,
50+
},
51+
Createdat: time.Date(2022, 9, 14, 14, 35, 37, 801000000, time.UTC),
52+
Device: Device{
53+
ID: 1,
54+
Label: "iPhone",
55+
Networkconnection: Networkconnection{
56+
Description: "Mobile LTE",
57+
Downloadbandwidth: 12000,
58+
Latency: 70,
59+
Packetloss: 0,
60+
Uploadbandwidth: 12000,
61+
},
62+
Viewportheight: 844,
63+
Viewportwidth: 375,
64+
},
65+
Frequency: 5,
66+
ID: 1,
67+
Locationids: []string{"na-us-virginia"},
68+
Name: "My Test",
69+
Schedulingstrategy: "round_robin",
70+
Transactions: []Transactions{
71+
{
72+
Name: "Example transaction",
73+
StepsV2: []StepsV2{
74+
{
75+
Name: "element step",
76+
Selector: ".main",
77+
SelectorType: "css",
78+
Type: "click_element",
79+
WaitForNav: true,
80+
WaitForNavTimeout: 2000,
81+
WaitForNavTimeoutDefault: true,
82+
MaxWaitTime: 10000,
83+
MaxWaitTimeDefault: true,
84+
},
85+
},
86+
},
87+
},
88+
Type: "browser",
89+
Updatedat: time.Date(2022, 9, 14, 14, 35, 38, 99000000, time.UTC),
90+
Lastrunat: time.Date(2024, 3, 7, 0, 47, 43, 741000000, time.UTC),
91+
Lastrunstatus: "success",
92+
Createdby: "abc1234",
93+
Updatedby: "abc1234",
94+
},
95+
}
3096
)
3197

3298
func TestGetBrowserCheckV2(t *testing.T) {
@@ -46,6 +112,11 @@ func TestGetBrowserCheckV2(t *testing.T) {
46112
if err != nil {
47113
t.Fatal(err)
48114
}
115+
// verify the json is unmarshalled correctly
116+
if !reflect.DeepEqual(*inputGetBrowserCheckV2, expectedBrowserCheckV2) {
117+
t.Errorf("returned \n\n%#v want \n\n%#v", *inputGetBrowserCheckV2, expectedBrowserCheckV2)
118+
}
119+
49120
if !reflect.DeepEqual(resp.Test.ID, inputGetBrowserCheckV2.Test.ID) {
50121
t.Errorf("returned \n\n%#v want \n\n%#v", resp.Test.ID, inputGetBrowserCheckV2.Test.ID)
51122
}
@@ -89,6 +160,11 @@ func TestGetBrowserCheckV2(t *testing.T) {
89160
if !reflect.DeepEqual(resp.Test.Customproperties, inputGetBrowserCheckV2.Test.Customproperties) {
90161
t.Errorf("returned \n\n%#v want \n\n%#v", resp.Test.Customproperties, inputGetBrowserCheckV2.Test.Customproperties)
91162
}
163+
164+
// verify the whole response
165+
if !reflect.DeepEqual(*resp, expectedBrowserCheckV2) {
166+
t.Errorf("returned \n\n%#v want \n\n%#v", *resp, expectedBrowserCheckV2)
167+
}
92168
}
93169

94170
func verifyBrowserCheckV2Input(stringInput string) *BrowserCheckV2Response {
@@ -97,5 +173,9 @@ func verifyBrowserCheckV2Input(stringInput string) *BrowserCheckV2Response {
97173
if err != nil {
98174
panic(err)
99175
}
176+
empty := BrowserCheckV2Response{}
177+
if reflect.DeepEqual(empty, *check) {
178+
panic("Unmarshal failed, empty struct returned")
179+
}
100180
return check
101181
}

0 commit comments

Comments
 (0)