how helpers.translate('SOME_KEY') works? - selenium

I am wondering that how helpers.translate('SOME_KEY'); works in protractor?
i am using it like:
expect(element(by.css('.contact_tag')).getText()).toEqual('CONTACT');
here 'CONTACT' string translated in English as 'contact details'. i am getting the following output
output:
Expected 'contact details' to equal Object({ $$state: Object({ status: 0 }), catch: Object({ }), finally: Object({ }), then: Object({ }) }).
somebody please explain me that how this helpers.translate works? from where it takes this CONTACT translate string?

Related

GROQ: Query one-to-many relationship with parameter as query input

I have a blog built in NextJS, backed by Sanity. I want to start tagging posts with tags/categories.
Each post may have many categories.
Category is a reference on post:
defineField({
name: 'category',
title: 'Category',
type: 'array',
of: [
{
type: 'reference',
to: [
{
type: 'category',
},
],
},
],
}),
This is my GROQ query:
*[_type == "post" && count((category[]->slug.current)[# in ['dogs']]) > 0] {
_id,
title,
date,
excerpt,
coverImage,
"slug": slug.current,
"author": author->{name, picture},
"categories": category[]-> {name, slug}
}
The above works, when it is hardcoded, but swapping out 'dogs' with $slug for example will cause the query to fail. (Where $slug is a param provided)
*[_type == "post" && count((category[]->slug.current)[# in [$slug]]) > 0]
{
$slug: 'travel'
}
How do I make the above dynamic?
Returns all documents that are storefronts // within 10 miles of the user-provided currentLocation parameter ; // For a given $currentLocation geopoint
I can't believe it. Rookie mistake. I needed to pay more attention in the Sanity IDE. (To be fair there was a UI bug that hid the actual issue)
The param should not contain the $. E.g the following works in the GROQ IDE.
{
slug: 'travel'
}

Read value from search request Datatable?

I am trying to read value from search box of Datatable.
This is request payload:
[Object: null prototype] {
draw: '8',
'columns[0][data]': '_id',
'columns[0][name]': '',
'columns[0][searchable]': 'true',
'columns[0][orderable]': 'true',
...
start: '0',
length: '50',
'search[value]': 'id3dsd3dsdddsddsd',
'search[regex]': 'false'
}
I want to get value from search[value]. I get this error after using this code:
req.body.search.value
TypeError: Cannot read properties of undefined (reading 'value')
Anyone can help me!
Hope this would solve your problem.
let search_str = req.body['search[value]'];

React native how to update multiple state values

Here is the user details which I want to update values when user enters data in Textinput
const [details, setDetails] = React.useState({
isValidName: true,
isValidMobile: true,
isValidEmail: true,
isValidGSTIN: true,
isValidPAN: true,
name: '',
mobile: '',
email: '',
company: '',
baddr1: '',
baddr12: '',
bcity: '',
bpincode: '',
bstate: ' TAMIL NADU',
bcountry: 'INDIA',
saddr1: '',
saddr2: '',
sbranch: '',
sgstin: '',
scity: '',
spincode: '',
sstate: '',
scountry: '',
pan: '',
gstin: '',
userlevel: '',
});
//In this method i am updating values each time when user enters data
const submitBillAddress = (data, type) => {
console.log('bill', type);
switch(type){
case 'addr1':
setDetails((prevState)=>{
return({
...prevState,
baddr1: data
});
});
break;
}
console.log('billdetails', details);
};
return (
<View>
<TextInput
style={styles.TextInputStyleClass}
placeholder="Address Line 1"
value={sameAddress?null:details.baddr1}
onChangeText={val => submitBillAddress(val, 'addr1')}
/>
</View>
)
I am new to React Native application development and I know this question is basic but I am not getting exact output. Here I have one Textinput in which I am entering data that I wanted to store in details.
The issue is if I enter data in textinput it's not updating value in details. Let's say I am entering 'C' in Textinput if I try to check the value in console the value of details.baddr1='' it's empty, Second time if I enter value 'H' on that time in console the value of details.baddr1='C'. Instead of showing the value details.baddr1='CH' it's showing previously entered value.
How can I fix this issue?
I'm guessing this is for a form of some sort. In that case, a package is your best bet I believe. While what you're trying to achieve is possible without a package, using a package is far less painful in the long run for your app.
Please check out formik or react-hook-form.
They're both decent.

vue-i18n this.$tc is not a function

My lang file:
AccountNotifications: {
createdWithName: 'Account «{account}» created',
created: 'Account created | Accounts created',
}
my submit method
submit()
this.$notifications.add({
type: 'success',
html: accounts.length === 1
? this.$tc('AccountNotifications.created', 1)
: this.$tc('AccountNotifications.created', 2),
});
My output
app.js:290949 TypeError: this.$tc is not a function
Whats wrong?
$tc() is not actually needed. The $t() function supports pluralization now.

Pagination with Sequelize using limit takes 4 times longer to load. How can I optimize?

I am currently using Sequelize with Node.js and I wanted to incorporate pagination. The code works, however, Sequelize takes 4 times more time to load than what it used to. 13 seconds is not acceptable as a loading time for each page. I tried both findAll and findAndCountAll, but as soon as I add the limit to the options, it becomes really slow. Here is the query used in node.js:
return req.models.BookingGroup.findAndCountAll({
attributes: group_attrs,
where: group_where,
include: [
{
model: req.models.Booking,
attributes: book_attrs,
where: booking_where,
include: [
{
model: req.models.Guest,
attributes: [
'id',
'firstname',
'lastname',
'email',
],
},
],
}
],
offset,
limit
})
.then(({count, rows}) => {
res.send(200, {count, groups: rows})
return {count, groups: rows}
})
.catch(err => console.log("##error ", err))
Am I doing something wrong? It only returns 70 entries, I don't think it should take this long. I haven't found anything online, and I don't know if it is a problem with Sequelize but any help is appreciated !
I came across a performance issue when using findandcountall.
In my case, Sequelize formed a lengthy JOIN statement in findandcountall (You can check this with passing the option logging: console.log).
However, instead of using findAndCountAll, I used .count() to get the number and .findAll() to get the results. This actually turned out to be much faster than using the findAndCountAll().
const count = await req.models.BookingGroup.count({
where, include, distinct: true, ...
});
const bookingGroup = await req.models.BookingGroup.findAll({
where, include, attributes, limit, offset, ...
});
res.send({ bookingGroup: [], count });