Chai-sorted throws assertion error for array of numbers - chai

I am trying to validate the values in a column to be in descending order.
All the values in the column are integers for percentage change.
It works all the times except when there is 100 for the first row.
cy.get(grid)
.find(column)
.each(child => {
cellVals.push(child.text());
})
.then(() => {
chai.expect(cellVals).to.be.sorted({ descending: true });
});
ScreenShot with the values and the Error report
Not sure whats not working. Seems pretty straight forward and don't see a reason why it's failing. Appreciate any help.
Also, is there any other way to compare in Cypress without using chait-sorted ?

Related

Pentaho cuts double values from Table Input

I have a Problem that I could not fix up to now. When I do a "Select" at a Table-Input the double values are not returned completely and are always cut. Here are some examples:
15.0420 => 15 // 12.6000 => 12,6 // 4.1176 => 4,1 // 0.1123 => 0,1 // 0.0012 => 0
I seems like, that minimum two numbers are shown and max one number after the comma. However it is very important to get the right figures.
I use pentaho 6.1, and mariaDB 5.5.49.
Thanks for every help.
Best regards,
Dave
Finally I adjusted the configuration of the Default Number Format. Under "Edit->Edit the kettle.properties file", I set the "KETTLE_DEFAULT_NUMBER_FORMAT" with the format '#.####'. Now it is working!

Error using metrics listed in Google's Metrics and dimensions

I am using this code to query the api
function getResults(&$analytics, $profileId) {
// Calls the Core Reporting API and queries for the number of sessions
// for the last 30 days.
return $analytics->data_ga->get(
'ga:' . $profileId,
'30daysAgo',
'today',
'ga:sessionCount,ga:sessionDurationBucket,ga:users,ga:percentNewSessions,ga:bounceRate,ga:pageviews');
}
i get this error upon executing the code
Fatal error: Uncaught exception 'Google_Service_Exception' with
message 'Error calling GET
https://www.googleapis.com/analytics/v3/data/ga?ids=ga%3A114460017&start-date=30daysAgo&end-date=today&metrics=ga%3AsessionCount%2Cga%3AsessionDurationBucket%2Cga%3Ausers%2Cga%3ApercentNewSessions%2Cga%3AbounceRate%2Cga%3Apageviews:
(400) Unknown metric(s): ga:sessionCount, ga:sessionDurationBucket
anyone ever experience? I do not understand why it does not recognize those metrics when it is listed
https://developers.google.com/analytics/devguides/reporting/core/dimsmets#view=detail&group=user&jump=ga_sessioncount
If you look more closely into that documentation you will see that session count is not a metric, it's a dimension. The reason is that you want to be able to do breakdowns of metrics by session count (e.g. "show avg. duration of sessions for users with 3 sessions") and for that you need categorical data.
Even if you overlook the (not particularly distinctive) column heading in the table of contents (ga:sessionCount is in the "dimensions"-column) the fact that the datatype is a string would be a dead giveaway. Metrics are always numbers. Dimensions are always strings, even if they sometimes look like numbers.
Same goes for ga:sessionDurationBucket.
Look at this example from the documentation to see how dimensions are passed into the query via an array that holds optional parameters:
private function queryCoreReportingApi() {
$optParams = array(
'dimensions' => 'ga:source,ga:keyword',
'sort' => '-ga:sessions,ga:source',
'filters' => 'ga:medium==organic',
'max-results' => '25');
return $service->data_ga->get(
TABLE_ID,
'2010-01-01',
'2010-01-15',
'ga:sessions',
$optParams);
}
You'd need to construct a similar $optParams array:
$optParams = array(
'dimensions' => 'ga:sessionCount,ga:sessionDurationBucket'
');
and pass it to your query:
return $analytics->data_ga->get(
'ga:' . $profileId,
'30daysAgo',
'today',
$optParams,
'ga:users,ga:percentNewSessions,ga:bounceRate,ga:pageviews');
}
and remove the dimensions from the list of metrics.
Btw. Google has a wonderful documentation page on the difference between dimensions and metrics and how they are used in the reports.

How do I assert to accept one of multiple possible values in JUnit

I have a test that returns some value after completion. The returned value is a String and can have one of several possible values based on some if condition in the test.
But in the assert statement I can check only one of the Expected values not both.
How can I do this? Thank you.
I will use AssertJ for this
assertThat(value).isIn(expected1, expected2, expected3);
The code is much simpler than with Hamcrest.
My solution was to save the result and then run a Jtest that the result was in an array of accepted solutions.
E.g:
`it("Test Message", () => {
const result = testFunction(inputValue);
assert.equal((result in [possibeResult1, possibleResult2, ...]), true);
});`

dijit filteringSelect with min length

I can't seem to find a way to require the filtering select input to be of a certain length. I've tried like this:
new dijit.form.FilteringSelect({
'name': 'bla',
'store': jsonRestStore,
'searchAttr': "name",
'pattern': '.{3,}',
'regExp': '.{3,}'
});
but it doesn't change a thing. I want the filtering select to only query the store, if at least 3 characters have been entered. Can't be that exotic a requirement, can it? There are thousands of items behind that store, so querying that with just 1 or 2 characters is slow.
I did a bit more searching and found this post on the dojo mailing list. To summarize, there is no way to native support in the FilteringSelect for it, but it is extremely easy to implement.
// custom min input character count to trigger search
minKeyCount: 3,
// override search method, count the input length
_startSearch: function (/*String*/key) {
if (!key || key.length < this.minKeyCount) {
this.closeDropDown();
return;
}
this.inherited(arguments);
}
Also in the API Docs, there is a searchDelay attribute, which could be helpful in minimizes the number of queries.
searchDelay
Delay in milliseconds between when user types something and we start searching based on that value

Best way of getting the row just added. Heroku + Node + Postgres

What is the best way of getting the row that was just added, I am working with Heroku, Node and Postgres, and Expressjs. I want to be able to do something like this.
app.post( '/', function( req, res ){
client.query("INSERT into ..", function( err, result ){
res.send( result.id );
});
});
Ideally the callback would have information about the row that it just entered in but the content of it just an object that looks like
{ rows:[] }
Is there a good way of getting that row that I just added, thanks.
You probably want to use INSERT ... RETURNING:
The optional RETURNING clause causes INSERT to compute and return value(s) based on each row actually inserted. This is primarily useful for obtaining values that were supplied by defaults, such as a serial sequence number. However, any expression using the table's columns is allowed. The syntax of the RETURNING list is identical to that of the output list of SELECT.
So something like this:
client.query('insert into your_table (...) values (...) returning *', function(err, result) {
// ...
});
should get you the newly inserted row in your callback function.