-
-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: added multidevice support to
query_active_history
(#451)
- Loading branch information
Showing
4 changed files
with
92 additions
and
41 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
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 |
---|---|---|
@@ -1,28 +1,49 @@ | ||
const queries = require('~/queries'); | ||
|
||
test('generate fullDesktopQuery', () => { | ||
const bid_window = ''; | ||
const bid_afk = ''; | ||
const bid_browsers = []; | ||
const filter_afk = true; | ||
const categories = []; | ||
const filter_categories = true; | ||
const include_audible = true; | ||
const always_active_pattern = /meow|nyaan|specials: \w(\\)/.toString().substring(1).slice(0, -1); | ||
const query_lines = queries.fullDesktopQuery({ | ||
bid_window, | ||
bid_afk, | ||
bid_browsers, | ||
filter_afk, | ||
categories, | ||
filter_categories, | ||
include_audible, | ||
always_active_pattern, | ||
}); | ||
// test data | ||
const hostname = 'testhost'; | ||
const bid_window = 'aw-watcher-window_' + hostname; | ||
const bid_afk = 'aw-watcher-afk_' + hostname; | ||
const bid_browsers = []; | ||
const filter_afk = true; | ||
const always_active_pattern = /meow|nyaan|specials: \w(\\)/.toString().substring(1).slice(0, -1); | ||
const queryParams = { | ||
bid_window, | ||
bid_afk, | ||
bid_browsers, | ||
filter_afk, | ||
categories: [], | ||
filter_categories: true, | ||
include_audible: true, | ||
always_active_pattern, | ||
}; | ||
|
||
function expectBracketsClosed(query) { | ||
// Checks that there are matching parens, brackets, braces, etc | ||
// Doesn't actually check placement, just matching open/closed count. | ||
|
||
// parens | ||
const openParens = query.match(/\(/g); | ||
const closeParens = query.match(/\)/g); | ||
expect(openParens && openParens.length).toEqual(closeParens && closeParens.length); | ||
|
||
// brackets | ||
const openBrackets = query.match(/\[/g); | ||
const closeBrackets = query.match(/\]/g); | ||
expect(openBrackets && openBrackets.length).toEqual(closeBrackets && closeBrackets.length); | ||
|
||
// join query lines into a single string | ||
const query = query_lines.join('\n'); | ||
// braces | ||
const openBraces = query.match(/\{/g); | ||
const closeBraces = query.match(/\}/g); | ||
expect(openBraces && openBraces.length).toEqual(closeBraces && closeBraces.length); | ||
} | ||
|
||
test('generate fullDesktopQuery', () => { | ||
let query = queries.fullDesktopQuery(queryParams).join('\n'); | ||
expect(query).toMatchSnapshot(); | ||
expectBracketsClosed(query); | ||
|
||
// check that query_str is well formatted | ||
query = queries.activityQuery([bid_afk]).join('\n'); | ||
expect(query).toMatchSnapshot(); | ||
expectBracketsClosed(query); | ||
}); |
9b387d2
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.12.1 (click to expand)
Screenshots using aw-server-rust master (click to expand)
Screenshots using aw-server-rust v0.12.1 (click to expand)