-
-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: added first query-generation test using jest's snapshot functio…
…nality
- Loading branch information
Showing
3 changed files
with
70 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`generate fullDesktopQuery 1`] = ` | ||
"events = flood(query_bucket(\\"\\")); | ||
not_afk = flood(query_bucket(\\"\\")); | ||
not_afk = filter_keyvals(not_afk, \\"status\\", [\\"not-afk\\"]); | ||
browser_events = []; | ||
audible_events = filter_keyvals(browser_events, \\"audible\\", [true]); | ||
not_afk = period_union(not_afk, audible_events); | ||
events = filter_period_intersect(events, not_afk); | ||
events = categorize(events, []); | ||
events = filter_keyvals(events, \\"$category\\", true); | ||
title_events = sort_by_duration(merge_events_by_keys(events, [\\"app\\", \\"title\\"])); | ||
app_events = sort_by_duration(merge_events_by_keys(title_events, [\\"app\\"])); | ||
cat_events = sort_by_duration(merge_events_by_keys(events, [\\"$category\\"])); | ||
app_events = limit_events(app_events, 100); | ||
title_events = limit_events(title_events, 100); | ||
duration = sum_durations(events); | ||
browser_events = split_url_events(browser_events); | ||
browser_urls = merge_events_by_keys(browser_events, [\\"url\\"]); | ||
browser_urls = sort_by_duration(browser_urls); | ||
browser_urls = limit_events(browser_urls, 100); | ||
browser_domains = merge_events_by_keys(browser_events, [\\"$domain\\"]); | ||
browser_domains = sort_by_duration(browser_domains); | ||
browser_domains = limit_events(browser_domains, 100); | ||
browser_duration = sum_durations(browser_events); | ||
RETURN = { | ||
\\"window\\": { | ||
\\"app_events\\": app_events, | ||
\\"title_events\\": title_events, | ||
\\"cat_events\\": cat_events, | ||
\\"active_events\\": not_afk, | ||
\\"duration\\": duration | ||
}, | ||
\\"browser\\": { | ||
\\"domains\\": browser_domains, | ||
\\"urls\\": browser_urls, | ||
\\"duration\\": browser_duration | ||
} | ||
};" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const queries = require('~/queries'); | ||
|
||
test('generate fullDesktopQuery', () => { | ||
const browserbuckets = []; | ||
const windowbucket = ''; | ||
const afkbucket = ''; | ||
const filterAFK = true; | ||
const classes = []; | ||
const filterCategories = true; | ||
const include_audible = true; | ||
const query_lines = queries.fullDesktopQuery( | ||
browserbuckets, | ||
windowbucket, | ||
afkbucket, | ||
filterAFK, | ||
classes, | ||
filterCategories, | ||
include_audible | ||
); | ||
|
||
// join query lines into a single string | ||
const query = query_lines.join('\n'); | ||
|
||
// check that query_str is well formatted | ||
expect(query).toMatchSnapshot(); | ||
}); |
3db99c7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are screenshots of this commit:
Screenshots using aw-server v0.11.0 (click to expand)
Screenshots using aw-server-rust master (click to expand)
Screenshots using aw-server-rust v0.11.0 (click to expand)