Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
9f54bb78
Commit
9f54bb78
authored
Jun 29, 2021
by
Peter Hegman
Committed by
jejacks0n
Jun 29, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for ready state
parent
9855f4fd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
0 deletions
+36
-0
spec/frontend/tracking_spec.js
spec/frontend/tracking_spec.js
+36
-0
No files found.
spec/frontend/tracking_spec.js
View file @
9f54bb78
...
...
@@ -207,6 +207,42 @@ describe('Tracking', () => {
[],
);
});
describe
(
'
when `document.readyState` does not equal `complete`
'
,
()
=>
{
const
originalReadyState
=
document
.
readyState
;
const
setReadyState
=
(
value
)
=>
{
Object
.
defineProperty
(
document
,
'
readyState
'
,
{
value
,
configurable
:
true
,
});
};
const
fireReadyStateChangeEvent
=
()
=>
{
document
.
dispatchEvent
(
new
Event
(
'
readystatechange
'
));
};
beforeEach
(()
=>
{
setReadyState
(
'
interactive
'
);
});
afterEach
(()
=>
{
setReadyState
(
originalReadyState
);
});
it
(
'
does not call `window.snowplow` until `readystatechange` is fired and `document.readyState` equals `complete`
'
,
()
=>
{
Tracking
.
enableFormTracking
({
fields
:
{
allow
:
[
'
input-class1
'
]
}
});
expect
(
snowplowSpy
).
not
.
toHaveBeenCalled
();
fireReadyStateChangeEvent
();
expect
(
snowplowSpy
).
not
.
toHaveBeenCalled
();
setReadyState
(
'
complete
'
);
fireReadyStateChangeEvent
();
expect
(
snowplowSpy
).
toHaveBeenCalled
();
});
});
});
describe
(
'
.flushPendingEvents
'
,
()
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment