Dalek.js not setting element values - dalekjs

Trying to use the .type action fails. This is on a web app using angular, not sure if this is related to it.
I can get assert attributes and existence of elements, but trying to use .type or .setValue fails
Here is the test
module.exports = {
'Smoke test app.ablio': function (test) {
test
.open('http://app.ablio.com')
.assert.title().is('ablio :: Communication Without Barriers', 'Title OK')
.open('https://app.ablio.com/signin')
.assert.attr('#sign-in', 'type', 'submit', "submit signin form exists")
.assert.exists('#username', "username form field exists")
.assert.attr('#username', 'type', 'text', "username form field is type text")
.assert.exists('#password', "password form field exists")
.assert.attr('#password', 'type', 'password',"password form field is type password")
.type('#username', 'testuser')
.assert.val('#username', 'testuser', 'Username was entered')
.screenshot ('shots/final.png')
.done();
}
};
the assert.val() fails:
Output:
dalek smoketest.js
Running tests
Running Browser: PhantomJS
OS: mac 10.10 (Yosemite) 32bit
Browser Version: 1.9.8
RUNNING TEST - "Smoke test app.ablio"
▶ OPEN http://app.ablio.com
✔ TITLE Title OK
▶ OPEN https://app.ablio.com/signin
✔ ATTRIBUTE submit signin form exists
✔ EXISTS username form field exists
✔ ATTRIBUTE username form field is type text
✔ EXISTS password form field exists
✔ ATTRIBUTE password form field is type password
▶ TYPE #username
✘ VAL
0 EXPECTED: testuser
0 FOUND:
0 MESSAGE: Username was entered
▶ SCREENSHOT shots/final.png
✘ TEST - "Smoke test app.ablio" FAILED
6/7 assertions passed. Elapsed Time: 8.55 sec
DalekJS CLI Tools Version: 0.0.5
DalekJS local install: 0.0.9

This resolves the issue and provides support for angular: http://gist.github.com/ryanzec/7546175

Scanned the DOM of the page & there you´ll see that you have 2 inputs with the id of username. That for one thing is invalid, and second, the username you´re are trying to fill is the 2nd in the DOM hierarchy. If it would be the first, it would even work, regardless of the invalid DOM.
I don't think that this is an Angular specific thing, as I have a hard time to believe that Angular itself would generate invalid DOM.

Related

How to setup Airflow custom email template

In the airflow.cfg, I have set how I need my email to look like but when an email is sent, the settings/layout I have specified is not being applied.
subject_template = 'Airflow alert: {{ti}}'
# File that will be used as the template for Email content (which will be rendered using Jinja2).
# If not set, Airflow uses a base template.
# Example: html_content_template = /path/to/my_html_content_template_file
html_content_template = (
'Try {{try_number}} out of {{max_tries + 1}}<br>'
'Job Name: {{ti.dag_id}}<br>'
'Task Id: {{ti.task_id}}<br>'
'Exception: {{exception_html}}<br>'
'Log: Link<br>'
'Host: {{ti.hostname}}<br>'
'Log file: {{ti.log_filename}}<br>')
What I'm I missing?
From the docs of html_content_template:
File that will be used as the template for Email content (which will be rendered using Jinja2). If not set, Airflow uses a base template.
I guess the expected value would be something like:
html_content_template = /path/to/my_html_content_template_file
Try creating a file with the template and providing the path to that file in the settings.

Lighthouse auto model detection doesn't work with unit tests

I seem to be facing the general problem that directive driven mutations won't properly work when unit testing them. Using GraphQL Playground everything works as expected and the User model is auto detected. But if unit testing the same functionality it fails.
All config values are properly set (as I can see from regular requests not failing):
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => ClientName\PackageName\Models\User::class,
],
...
]
And lighthouse config values also set to the namespace above!
So for example this mutation would trigger the UserPolicy class and after that automatically call the create method of the User class:
type Mutation #protect(guards: ["api"]) {
"Create user"
createUser(data: NewUserInput! #spread): User
#can(ability: "create")
#create
}
But calling the same request via phpunit would result in errors:
for #can it returns a not authorized error and if I remove #can it only updates the email field of the user model as if mass assignment is not properly set.
When I now change the above schema definition to:
type Mutation #protect(guards: ["api"]) {
"Create user"
createUser(data: NewUserInput! #spread): User
#can(ability: "create" model: "ClientName\\PackageName\\Models\\User")
#create(model: "ClientName\\PackageName\\Models\\User")
}
And it works as expected within phpunit tests!
Now I suspect that within tests there is not User model found or not the appropriate but I cannot understand why this is.
Does anyone have any idea?

Dynamic error style password field accounts-core in Meteor

I am using accounts-core package in meteor to make my registration form in my application.
I configure own custom validation field in password. i.e.
var password = AccountsTemplates.removeField('password');
AccountsTemplates.addField({
_id: 'password',
type: 'password',
required: true,
displayName: 'Password',
re: /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9]).{8,}$/,
errStr: 'At least 8 characters, 1 uppercase, 1 lowercase and 1 number'
});
Now i want to show error message with different style according to what character user missed to type. Something like:
As per Documentation : Field Configuration we need give errStr when field is configured.
And we can write func for custom validation:
AccountsTemplates.addField({
...
func : function(pwd){
... // check your password
}
...
});
But How can i pass dynamic markup to show error message?

Logstash additional JARs

I'm trying to add a custom filter to Logstash 1.4.2, which is installed as a Debian package. The contrib plugins (http://logstash.net/docs/1.4.2/contrib-plugins) are also installed. This filter establishes a connection to an sqlite database, and for that it makes use of the JDBC sqlite driver:
require "logstash/filters/base"
require "logstash/namespace"
require "jdbc/sqlite3"
require "java"
class LogStash::Filters::MyFilter < LogStash::Filters::Base
(...)
public
def register
if #database.nil?
raise "You must specify 'database => ...' in your filter"
elsif not File.exists?(#database)
raise "The database does not exist"
end
url = "jdbc:sqlite:" + #database
Java::OrgSqlite::JDBC #initialize the driver
#connection = java.sql.DriverManager.getConnection(url)
#logger.info("Using database", :path => #database)
end # def register
(...)
end # class LogStash::Filters::MyFilter
However, when I try to start logstash I get the following error in the logs :
"cannot load Java class org.sqlite.JDBC"
I've tried to place the sqlite-jdbc-3.7.2.jar file provided by the contrib plugins into several locations, but so far I couldn't figure out what's the right one for JARs required by custom plugins, or whether it is a configuration issue.
Any ideas?
While I couldn't find the way of using external jars with Logstash 1.4, I could get it to work by replacing SQlite JDBC with Sequel, which is already included.
require "logstash/filters/base"
require "logstash/namespace"
require "sequel"
class LogStash::Filters::MyFilter < LogStash::Filters::Base
(...)
public
def register
if #database.nil?
raise "You must specify 'database => ...' in your filter"
elsif not File.exists?(#database)
raise "The database does not exist"
end
#db = Sequel.connect("jdbc:sqlite:#{#database}")
#logger.info("Using database", :path => #database)
end # def register
(...)
end # class LogStash::Filters::MyFilter

How can I create users server side in Meteor?

In the new Meteor auth branch how can I create users server side?
I see how to create them client side with the call to
[Client] Meteor.createUser(options, extra, callback)
But suppose I want to create a Meteor user collection record on startup?
For example, the Administrator account during startup/bootstrapping for an application?
Thanks
Steeve
On newer versions of meteor use
Accounts.createUser({
username: username,
email : email,
password : password,
profile : {
//publicly visible fields like firstname goes here
}
});
note: the password hash is generated automatically
On older versions of meteor use:
1 - NB: DO YOU HAVE THE REQUIRED PACKAGES INSTALLED ?
mrt add accounts-base
mrt add accounts-password
On some versions of meteor you cannot call SRP password salt generator as Steeve suggested, so try this:
2 - do Meteor.users.insert( )
e.g.
var newUserId =
Meteor.users.insert({
emails: ['peter#jones.com'],
profile : { fullname : 'peter' }
});
note: a user must have EITHER a username or an email address. I used email in this example.
3 - Finally set the password for the newly created account.
Accounts.setPassword(newUserId, 'newPassword');
Probably it's a well known fact now, but for the sake of completing this - there's a new server API for doing this on the auth branch. From the docs on auth:
" [Server] Meteor.createUser(options, extra) - Creates a user and
sends that user an email with a link to choose their initial password
and complete their account enrollment
options a hash containing: email (mandatory), username (optional)
extra: extra fields for the user object (eg name, etc). "
Please note the API is subject to change as it's not on the master branch yet.
For now this has been suggested in the meteor-core google group.
Meteor.users.insert({username: 'foo', emails: ['bar#example.com'], name: 'baz', services: {password: {srp: Meteor._srp.generateVerifier('password')}}});
It works. I tested it in during startup/boot strap.
I would not consider this the permanent or long term answer because I believe the auth branch is still in a great degree of change and I imagine the team behind Meteor will provide some kind of functionality for it.
So, do not depend on this as a long term answer.
Steeve
At the moment, I believe you cannot. Running
Meteor.call('createUser', {username: "foo", password: "bar"});
comes close, but the implementation of createUser in passwords_server.js calls this.setUserId on success, and setUserId cannot be called on the server unless we're in a client-initiated method invocation (search for "Can't call setUserId on a server initiated method call" in livedata_server.js.
This does seem like something worth supporting. Perhaps the last three lines of createUser, which log the user in, should be controlled by a new boolean login option to the method? Then you could use
Meteor.call('createUser', {username: "foo", password: "bar", login: false});
in server bootstrap code.
I've confirmed that the following code in my server/seeds.js file works with the most recent version of Meteor (Release 0.8.1.1)
if (Meteor.users.find().count() === 0) {
seedUserId = Accounts.createUser({
email: 'f#oo.com',
password: '123456'
});
}
Directory (or folder) of server means I'm running the code on the server. The filename seeds.js is completely arbitrary.
The official documentation now describes both the behavior for Accounts.createUser() when run on the client and when run on the server.
Working coffeescript example for Meteor version 1.1.0.2 (server side):
userId = Accounts.createUser
username: 'user'
email: 'user#company.com'
password: 'password'
profile:
name: 'user name'
user = Meteor.users.findOne userId
I struggled for some time with this API getting 'User already exists' exception in working code before adding profiles.name to the options and exception disappeared.
reference: Accounts.createUser(options,[callback])
Create user from server side
// Server method
Meteor.methods({
register: function(data) {
try {
console.log("Register User");
console.log(data);
user = Accounts.createUser({
username: data.email,
email: data.email,
password: data.password,
profile: {
name: data.email,
createdOn: new Date(),
IsInternal: 0
}
});
return {
"userId": user
};
} catch (e) {
// IF ALREADY EXSIST THROW EXPECTION 403
throw e;
}
}
});
// Client call method
Meteor.call('register',{email: "vxxxxx#xxxx.com",password: "123456"}, function(error, result){
if(result){
console.log(result)
}
if(error){
console.log(result)
}
});

Resources