Skip to content

Commit

Permalink
E2E Test queryTrackedDomainList (#132)
Browse files Browse the repository at this point in the history
* e2e test for queryTrackedDomainList

* redaction case added

* update description

* added domains to list

* modified regex
  • Loading branch information
Gouri Hariharan authored and GitHub Enterprise committed Jan 13, 2025
1 parent 5c3b101 commit 3150079
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 0 deletions.
54 changes: 54 additions & 0 deletions test/e2e/00_pageLoad/pageLoad.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,62 @@ describe('pageLoad', () => {
});
});

describe('pageload url in queryTrackedDomainList', () => {
beforeEach(() => {
browser.get(getE2ETestBaseUrl('00_pageLoad/queryTrackedDomainList/www.example1.com') + '@!#$**(?account1=value');
});

it('full url with query parameters must be sent to backend', () => {
return util.retry(() => {
return getBeacons()
.then(([beacon]) => {
cexpect(beacon['u']).to.equal(getE2ETestBaseUrl('00_pageLoad/queryTrackedDomainList/www.example1.com') + '@!#$**(?account1=value');
cexpect(beacon['l']).to.equal(beacon['u']);
});
});
});

});

describe('pageload url not in queryTrackedDomainList', () => {
beforeEach(() => {
browser.get(getE2ETestBaseUrl('00_pageLoad/queryTrackedDomainList/www.example2.com') + '@!#$**(?account3=value');
});

it('url excluding query parameters must be sent to backend', () => {
return util.retry(() => {
return getBeacons()
.then(([beacon]) => {
let parsedUrl = (getE2ETestBaseUrl('00_pageLoad/queryTrackedDomainList/www.example2.com')).split('?')[0].split('#')[0];
cexpect(beacon['u']).to.equal(parsedUrl);
cexpect(beacon['l']).to.equal(beacon['u']);
});
});
});

});

describe('pageload url with redaction and in queryTrackedDomainList', () => {
beforeEach(() => {
browser.get(getE2ETestBaseUrl('00_pageLoad/queryTrackedDomainList/www.exampleWithRedactionCase.com') + '&account=myaccount&appsecret=password#fragmentstring');
});

it('full url with query parameters after redaction must be sent to backend', () => {
return util.retry(() => {
return getBeacons()
.then(([beacon]) => {
cexpect(beacon['u']).to.equal(getE2ETestBaseUrl('00_pageLoad/queryTrackedDomainList/www.exampleWithRedactionCase.com') + '&account=myaccount&appsecret=<redacted>#<redacted>');
cexpect(beacon['l']).to.equal(beacon['u']);
});
});
});

});

});



function stripTimingValues(node) {
if (node instanceof Array) {
node.forEach((entry, i) => node[i] = true);
Expand Down
19 changes: 19 additions & 0 deletions test/e2e/00_pageLoad/queryTrackedDomainList/www.example1.com.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>pageLoad test</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Tangerine">
</head>
<body>
Test url domain in queryTrackedDomainList

<script src="/e2e/initializer.js"></script>
<script crossorigin="anonymous" defer src="/target/eum.min.js"></script>

<script>
eum('queryTrackedDomainList', [/www.example1.com/i]);
</script>

</body>
</html>
19 changes: 19 additions & 0 deletions test/e2e/00_pageLoad/queryTrackedDomainList/www.example2.com.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>pageLoad test</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Tangerine">
</head>
<body>
Test url domain not in queryTrackedDomainList

<script src="/e2e/initializer.js"></script>
<script crossorigin="anonymous" defer src="/target/eum.min.js"></script>

<script>
eum('queryTrackedDomainList', [/www.example1.com/i, /www.example3.com/i]);
</script>

</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>pageLoad test</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Tangerine">
</head>
<body>
Test url in queryTrackedDomainList and with redacted secret and fragment.

<script src="/e2e/initializer.js"></script>
<script crossorigin="anonymous" defer src="/target/eum.min.js"></script>

<script>
eum('fragment', [/pageLoad/i]);
eum('secrets', [/secret/i]);
eum('queryTrackedDomainList', [/www.exampleWithRedactionCase.com/i]);
</script>

</body>
</html>

0 comments on commit 3150079

Please sign in to comment.