Skip to content

Commit

Permalink
Merge pull request YahooArchive#42 from SOASTA/test-e2e-04-03-query-p…
Browse files Browse the repository at this point in the history
…aram

E2E test 04-page-params/03-custom-dimensions-js.js validates URLQueryParam type

Reviewed By: @cvazac
  • Loading branch information
nicjansma committed Apr 23, 2015
2 parents b6fccc2 + 108bcd6 commit 5434b15
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@
"label": "cdim.CD7",
"dataType": "Boolean",
"varName": "custom_dimension_missing"
},
{
"name": "CD8",
"index": 8,
"type": "URLQueryParam",
"label": "cdim.CD8",
"dataType": "Boolean",
"parameter2": "query"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ describe("e2e/04-page-params/03-custom-dimensions-js", function() {

it("Should have the custom dimension 3 - JavaScript var Numeric", function() {
var b = tf.lastBeacon();
assert.equal(b["cdim.CD3"], 111);
assert.equal(b["cdim.CD3"], "111");
});

it("Should have the custom dimension 4 - JavaScript function Numeric", function() {
var b = tf.lastBeacon();
assert.equal(b["cdim.CD4"], 222);
assert.equal(b["cdim.CD4"], "222");
});

it("Should have the custom dimension 5 - JavaScript Var Text", function() {
Expand All @@ -43,4 +43,9 @@ describe("e2e/04-page-params/03-custom-dimensions-js", function() {
var b = tf.lastBeacon();
assert.equal(b["cdim.CD7"], undefined);
});

it("Should be missing custom dimension 8 - QueryParam", function() {
var b = tf.lastBeacon();
assert.equal(b["cdim.CD8"], undefined);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,9 @@
<%= boomerangSnippet %>
<script src="04-custom-dimensions-cookies.js" type="text/javascript"></script>
<script>
custom_dimension_1 = true;
custom_dimension_2 = function() {
return false;
}
custom_dimension_3 = 111;
custom_dimension_4 = function() {
return 222;
}
custom_dimension_5 = "abc";
custom_dimension_6 = function() {
return "def";
}

// Set a cookie. Note this won't work on localhost or IP tests
document.cookie = ["cookie_set=true", "path=/", "domain=" + location.hostname].join("; ");

BOOMR_test.init({
testAfterOnBeacon: true,
Expand All @@ -28,6 +19,16 @@
"regex": "^(.*)$",
"replacement": "$1",
"cookieName": "cookie_undefined"
},
{
"name": "CD2",
"index": 2,
"type": "CookieRegex",
"label": "cdim.CD2",
"dataType": "Boolean",
"regex": "^(.*)$",
"replacement": "$1",
"cookieName": "cookie_set"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ describe("e2e/04-page-params/04-custom-dimensions-cookies", function() {
var tf = BOOMR.plugins.TestFramework;
var t = BOOMR_test;

var dom = location.hostname;
var onDomain = !(!dom || dom === "localhost" || dom.match(/\.\d+$/) || dom.match(/^mhtml/) || dom.match(/^file:\//));

it("Should pass basic beacon validation", function(done) {
t.validateBeaconWasSent(done);
});
Expand All @@ -13,4 +16,18 @@ describe("e2e/04-page-params/04-custom-dimensions-cookies", function() {
var b = tf.lastBeacon();
assert.equal(b["cdim.CD1"], undefined);
});

it("Should be have custom dimension 2 - Cookie - If running on a domain", function() {
if (onDomain) {
var b = tf.lastBeacon();
assert.equal(b["cdim.CD2"], "true");
}
});

it("Should be missing custom dimension 2 - Cookie - If running on localhost or an IP", function() {
if (!onDomain) {
var b = tf.lastBeacon();
assert.equal(b["cdim.CD2"], undefined);
}
});
});

0 comments on commit 5434b15

Please sign in to comment.