Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
f002ab04
Commit
f002ab04
authored
Apr 21, 2015
by
JC Brand
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #377 from gbonvehi/issue-370-reg-fails
Issue #370 registration fails
parents
d4cbb621
8934043d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
109 additions
and
4 deletions
+109
-4
converse.js
converse.js
+12
-4
spec/register.js
spec/register.js
+97
-0
No files found.
converse.js
View file @
f002ab04
...
...
@@ -5060,11 +5060,19 @@
var
$inputs
=
$
(
ev
.
target
).
find
(
'
:input:not([type=button]):not([type=submit])
'
),
iq
=
$iq
({
type
:
"
set
"
})
.
c
(
"
query
"
,
{
xmlns
:
Strophe
.
NS
.
REGISTER
})
.
c
(
"
x
"
,
{
xmlns
:
Strophe
.
NS
.
XFORM
,
type
:
'
submit
'
});
$inputs
.
each
(
function
()
{
iq
.
cnode
(
utils
.
webForm2xForm
(
this
)).
up
();
});
if
(
this
.
form_type
==
'
xform
'
)
{
iq
.
c
(
"
x
"
,
{
xmlns
:
Strophe
.
NS
.
XFORM
,
type
:
'
submit
'
});
$inputs
.
each
(
function
()
{
iq
.
cnode
(
utils
.
webForm2xForm
(
this
)).
up
();
});
}
else
{
$inputs
.
each
(
function
()
{
var
$input
=
$
(
this
);
iq
.
c
(
$input
.
attr
(
'
name
'
),
{},
$input
.
val
());
});
}
converse
.
connection
.
_addSysHandler
(
this
.
_onRegisterIQ
.
bind
(
this
),
null
,
"
iq
"
,
null
,
null
);
converse
.
connection
.
send
(
iq
);
this
.
setFields
(
iq
.
tree
());
...
...
spec/register.js
View file @
f002ab04
...
...
@@ -160,5 +160,102 @@
expect
(
registerview
.
$
(
'
input[type=button]
'
).
length
).
toBe
(
1
);
},
converse
));
it
(
"
will set form_type to legacy and submit it as legacy
"
,
$
.
proxy
(
function
()
{
var
cbview
=
this
.
chatboxviews
.
get
(
'
controlbox
'
);
cbview
.
$
(
'
#controlbox-tabs
'
).
find
(
'
li
'
).
last
().
find
(
'
a
'
).
click
();
// Click the Register tab
var
registerview
=
this
.
chatboxviews
.
get
(
'
controlbox
'
).
registerpanel
;
spyOn
(
registerview
,
'
onProviderChosen
'
).
andCallThrough
();
spyOn
(
registerview
,
'
getRegistrationFields
'
).
andCallThrough
();
spyOn
(
registerview
,
'
onRegistrationFields
'
).
andCallThrough
();
spyOn
(
registerview
,
'
renderRegistrationForm
'
).
andCallThrough
();
registerview
.
delegateEvents
();
// We need to rebind all events otherwise our spy won't be called
spyOn
(
this
.
connection
,
'
connect
'
).
andCallThrough
();
registerview
.
$
(
'
input[name=domain]
'
).
val
(
'
conversejs.org
'
);
registerview
.
$
(
'
input[type=submit]
'
).
click
();
var
stanza
=
new
Strophe
.
Builder
(
"
stream:features
"
,
{
'
xmlns:stream
'
:
"
http://etherx.jabber.org/streams
"
,
'
xmlns
'
:
"
jabber:client
"
})
.
c
(
'
register
'
,
{
xmlns
:
"
http://jabber.org/features/iq-register
"
}).
up
()
.
c
(
'
mechanisms
'
,
{
xmlns
:
"
urn:ietf:params:xml:ns:xmpp-sasl
"
});
this
.
connection
.
_connect_cb
(
test_utils
.
createRequest
(
stanza
));
stanza
=
$iq
({
'
type
'
:
'
result
'
,
'
id
'
:
'
reg1
'
}).
c
(
'
query
'
,
{
'
xmlns
'
:
'
jabber:iq:register
'
})
.
c
(
'
instructions
'
)
.
t
(
'
Please choose a username, password and provide your email address
'
).
up
()
.
c
(
'
username
'
).
up
()
.
c
(
'
password
'
).
up
()
.
c
(
'
email
'
);
this
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
expect
(
registerview
.
form_type
).
toBe
(
'
legacy
'
);
registerview
.
$
(
'
input[name=username]
'
).
val
(
'
testusername
'
);
registerview
.
$
(
'
input[name=password]
'
).
val
(
'
testpassword
'
);
registerview
.
$
(
'
input[name=email]
'
).
val
(
'
test@email.local
'
);
spyOn
(
converse
.
connection
,
'
send
'
);
registerview
.
$
(
'
input[type=submit]
'
).
click
();
expect
(
converse
.
connection
.
send
).
toHaveBeenCalled
();
var
$stanza
=
$
(
converse
.
connection
.
send
.
argsForCall
[
0
][
0
].
tree
());
expect
(
$stanza
.
children
(
'
query
'
).
children
().
length
).
toBe
(
3
);
expect
(
$stanza
.
children
(
'
query
'
).
children
()[
0
].
tagName
).
toBe
(
'
username
'
);
},
converse
));
it
(
"
will set form_type to xform and submit it as xform
"
,
$
.
proxy
(
function
()
{
var
cbview
=
this
.
chatboxviews
.
get
(
'
controlbox
'
);
cbview
.
$
(
'
#controlbox-tabs
'
).
find
(
'
li
'
).
last
().
find
(
'
a
'
).
click
();
// Click the Register tab
var
registerview
=
this
.
chatboxviews
.
get
(
'
controlbox
'
).
registerpanel
;
spyOn
(
registerview
,
'
onProviderChosen
'
).
andCallThrough
();
spyOn
(
registerview
,
'
getRegistrationFields
'
).
andCallThrough
();
spyOn
(
registerview
,
'
onRegistrationFields
'
).
andCallThrough
();
spyOn
(
registerview
,
'
renderRegistrationForm
'
).
andCallThrough
();
registerview
.
delegateEvents
();
// We need to rebind all events otherwise our spy won't be called
spyOn
(
this
.
connection
,
'
connect
'
).
andCallThrough
();
registerview
.
$
(
'
input[name=domain]
'
).
val
(
'
conversejs.org
'
);
registerview
.
$
(
'
input[type=submit]
'
).
click
();
var
stanza
=
new
Strophe
.
Builder
(
"
stream:features
"
,
{
'
xmlns:stream
'
:
"
http://etherx.jabber.org/streams
"
,
'
xmlns
'
:
"
jabber:client
"
})
.
c
(
'
register
'
,
{
xmlns
:
"
http://jabber.org/features/iq-register
"
}).
up
()
.
c
(
'
mechanisms
'
,
{
xmlns
:
"
urn:ietf:params:xml:ns:xmpp-sasl
"
});
this
.
connection
.
_connect_cb
(
test_utils
.
createRequest
(
stanza
));
stanza
=
$iq
({
'
type
'
:
'
result
'
,
'
id
'
:
'
reg1
'
}).
c
(
'
query
'
,
{
'
xmlns
'
:
'
jabber:iq:register
'
})
.
c
(
'
instructions
'
)
.
t
(
'
Using xform data
'
).
up
()
.
c
(
'
x
'
,
{
'
xmlns
'
:
'
jabber:x:data
'
,
'
type
'
:
'
form
'
})
.
c
(
'
instructions
'
).
t
(
'
xform instructions
'
).
up
()
.
c
(
'
field
'
,
{
'
type
'
:
'
text-single
'
,
'
var
'
:
'
username
'
}).
c
(
'
required
'
).
up
().
up
()
.
c
(
'
field
'
,
{
'
type
'
:
'
text-private
'
,
'
var
'
:
'
password
'
}).
c
(
'
required
'
).
up
().
up
()
.
c
(
'
field
'
,
{
'
type
'
:
'
text-single
'
,
'
var
'
:
'
email
'
}).
c
(
'
required
'
).
up
().
up
()
this
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
expect
(
registerview
.
form_type
).
toBe
(
'
xform
'
);
registerview
.
$
(
'
input[name=username]
'
).
val
(
'
testusername
'
);
registerview
.
$
(
'
input[name=password]
'
).
val
(
'
testpassword
'
);
registerview
.
$
(
'
input[name=email]
'
).
val
(
'
test@email.local
'
);
spyOn
(
converse
.
connection
,
'
send
'
);
registerview
.
$
(
'
input[type=submit]
'
).
click
();
expect
(
converse
.
connection
.
send
).
toHaveBeenCalled
();
var
$stanza
=
$
(
converse
.
connection
.
send
.
argsForCall
[
0
][
0
].
tree
());
expect
(
$stanza
.
children
(
'
query
'
).
children
().
length
).
toBe
(
1
);
expect
(
$stanza
.
children
(
'
query
'
).
children
().
children
().
length
).
toBe
(
3
);
expect
(
$stanza
.
children
(
'
query
'
).
children
().
children
()[
0
].
tagName
).
toBe
(
'
field
'
);
},
converse
));
},
converse
,
mock
,
test_utils
));
}));
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment