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
03ec659b
Commit
03ec659b
authored
Dec 01, 2014
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add another test and another template. refs #117
parent
0ae80082
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
97 additions
and
32 deletions
+97
-32
converse.js
converse.js
+14
-16
main.js
main.js
+1
-0
spec/register.js
spec/register.js
+64
-3
src/templates.js
src/templates.js
+15
-13
src/templates/registration_request.html
src/templates/registration_request.html
+3
-0
No files found.
converse.js
View file @
03ec659b
...
@@ -4498,7 +4498,7 @@
...
@@ -4498,7 +4498,7 @@
connect_cb
(
req
,
callback
,
raw
);
connect_cb
(
req
,
callback
,
raw
);
}
else
{
}
else
{
if
(
this
.
getRegistrationFields
(
req
,
callback
,
raw
))
{
if
(
this
.
getRegistrationFields
(
req
,
callback
,
raw
))
{
delete
this
.
_registering
;
this
.
_registering
=
false
;
}
}
}
}
},
this
);
},
this
);
...
@@ -4529,8 +4529,9 @@
...
@@ -4529,8 +4529,9 @@
}
}
if
(
register
.
length
===
0
)
{
if
(
register
.
length
===
0
)
{
conn
.
_changeConnectStatus
(
conn
.
_changeConnectStatus
(
Strophe
.
Status
.
REGIFAIL
,
Strophe
.
Status
.
REGIFAIL
,
'
Sorry, the given provider does not support in band account registration. Please try with a different provider.
'
);
__
(
'
Sorry, the given provider does not support in band account registration. Please try with a different provider.
'
)
);
return
true
;
return
true
;
}
}
// Send an IQ stanza to get all required data fields
// Send an IQ stanza to get all required data fields
...
@@ -4588,9 +4589,10 @@
...
@@ -4588,9 +4589,10 @@
return
;
return
;
}
}
$form
.
find
(
'
input[type=submit]
'
).
hide
()
$form
.
find
(
'
input[type=submit]
'
).
hide
()
.
after
(
'
<button class="cancel hor_centered">Cancel</button>
'
)
.
after
(
converse
.
templates
.
registration_request
({
.
after
(
'
<span class="spinner login-submit"/>
'
)
cancel
:
__
(
'
Cancel
'
),
.
after
(
'
<p class="info">Requesting a registration form from the XMPP server</p>
'
);
info_message
:
__
(
'
Requesting a registration form from the XMPP server
'
)
}));
$form
.
find
(
'
button.cancel
'
).
on
(
'
click
'
,
$
.
proxy
(
this
.
cancelRegistration
,
this
));
$form
.
find
(
'
button.cancel
'
).
on
(
'
click
'
,
$
.
proxy
(
this
.
cancelRegistration
,
this
));
this
.
reset
({
this
.
reset
({
domain
:
Strophe
.
getDomainFromJid
(
domain
),
domain
:
Strophe
.
getDomainFromJid
(
domain
),
...
@@ -4613,7 +4615,9 @@
...
@@ -4613,7 +4615,9 @@
if
(
_
.
contains
([
if
(
_
.
contains
([
Strophe
.
Status
.
DISCONNECTED
,
Strophe
.
Status
.
DISCONNECTED
,
Strophe
.
Status
.
CONNFAIL
,
Strophe
.
Status
.
CONNFAIL
,
Strophe
.
Status
.
REGIFAIL
Strophe
.
Status
.
REGIFAIL
,
Strophe
.
Status
.
NOTACCEPTABLE
,
Strophe
.
Status
.
CONFLICT
],
status
))
{
],
status
))
{
converse
.
log
(
'
Problem during registration: Strophe.Status is:
'
+
status
);
converse
.
log
(
'
Problem during registration: Strophe.Status is:
'
+
status
);
...
@@ -4622,16 +4626,10 @@
...
@@ -4622,16 +4626,10 @@
this
.
giveFeedback
(
error
,
'
error
'
);
this
.
giveFeedback
(
error
,
'
error
'
);
}
else
{
}
else
{
this
.
giveFeedback
(
__
(
this
.
giveFeedback
(
__
(
'
Something went wrong establishing a connection with "%1$s". Are you sure it exists?
'
,
'
Something went wrong
while
establishing a connection with "%1$s". Are you sure it exists?
'
,
this
.
domain
this
.
domain
),
'
error
'
);
),
'
error
'
);
}
}
}
else
if
(
status
==
Strophe
.
Status
.
CONFLICT
)
{
// TODO
converse
.
log
(
'
CONFLICT
'
);
}
else
if
(
status
==
Strophe
.
Status
.
NOTACCEPTABLE
)
{
// TODO
converse
.
log
(
'
NOTACCEPTABLE
'
);
}
else
if
(
status
==
Strophe
.
Status
.
REGISTERED
)
{
}
else
if
(
status
==
Strophe
.
Status
.
REGISTERED
)
{
converse
.
log
(
"
Registered successfully.
"
);
converse
.
log
(
"
Registered successfully.
"
);
converse
.
connection
.
reset
();
converse
.
connection
.
reset
();
...
@@ -4694,9 +4692,9 @@
...
@@ -4694,9 +4692,9 @@
},
this
));
},
this
));
}
}
if
(
this
.
fields
)
{
if
(
this
.
fields
)
{
$form
.
append
(
'
<input type="submit" class="submit" value="
'
+
__
(
'
Register
'
)
+
'
"/>
'
);
$form
.
append
(
'
<input type="submit" class="s
ave-s
ubmit" value="
'
+
__
(
'
Register
'
)
+
'
"/>
'
);
$form
.
on
(
'
submit
'
,
$
.
proxy
(
this
.
submitRegistrationForm
,
this
));
$form
.
on
(
'
submit
'
,
$
.
proxy
(
this
.
submitRegistrationForm
,
this
));
$form
.
append
(
'
<input type="button" class="submit" value="
'
+
__
(
'
Cancel
'
)
+
'
"/>
'
);
$form
.
append
(
'
<input type="button" class="
cancel-
submit" value="
'
+
__
(
'
Cancel
'
)
+
'
"/>
'
);
$form
.
find
(
'
input[type=button]
'
).
on
(
'
click
'
,
$
.
proxy
(
this
.
cancelRegistration
,
this
));
$form
.
find
(
'
input[type=button]
'
).
on
(
'
click
'
,
$
.
proxy
(
this
.
cancelRegistration
,
this
));
}
else
{
}
else
{
$form
.
append
(
'
<input type="button" class="submit" value="
'
+
__
(
'
Return
'
)
+
'
"/>
'
);
$form
.
append
(
'
<input type="button" class="submit" value="
'
+
__
(
'
Return
'
)
+
'
"/>
'
);
...
...
main.js
View file @
03ec659b
...
@@ -110,6 +110,7 @@ require.config({
...
@@ -110,6 +110,7 @@ require.config({
"
register_panel
"
:
"
src/templates/register_panel
"
,
"
register_panel
"
:
"
src/templates/register_panel
"
,
"
register_tab
"
:
"
src/templates/register_tab
"
,
"
register_tab
"
:
"
src/templates/register_tab
"
,
"
registration_form
"
:
"
src/templates/registration_form
"
,
"
registration_form
"
:
"
src/templates/registration_form
"
,
"
registration_request
"
:
"
src/templates/registration_request
"
,
"
requesting_contact
"
:
"
src/templates/requesting_contact
"
,
"
requesting_contact
"
:
"
src/templates/requesting_contact
"
,
"
requesting_contacts
"
:
"
src/templates/requesting_contacts
"
,
"
requesting_contacts
"
:
"
src/templates/requesting_contacts
"
,
"
room_description
"
:
"
src/templates/room_description
"
,
"
room_description
"
:
"
src/templates/room_description
"
,
...
...
spec/register.js
View file @
03ec659b
...
@@ -11,12 +11,27 @@
...
@@ -11,12 +11,27 @@
describe
(
"
The Registration Panel
"
,
$
.
proxy
(
function
(
mock
,
test_utils
)
{
describe
(
"
The Registration Panel
"
,
$
.
proxy
(
function
(
mock
,
test_utils
)
{
beforeEach
(
function
()
{
beforeEach
(
function
()
{
test_utils
.
closeControlBox
();
connection
=
mock
.
mock_connection
;
connection
.
connected
=
false
;
converse
.
_tearDown
();
converse
.
initialize
({
bosh_service_url
:
'
localhost
'
,
allow_registration
:
true
,
auto_subscribe
:
false
,
animate
:
false
,
connection
:
connection
,
no_trimming
:
true
,
debug
:
true
});
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
});
});
afterEach
(
function
()
{
afterEach
(
$
.
proxy
(
function
()
{
this
.
connection
.
connected
=
false
;
test_utils
.
closeControlBox
();
test_utils
.
closeControlBox
();
});
}
,
converse
)
);
it
(
"
is not available unless allow_registration=true
"
,
$
.
proxy
(
function
()
{
it
(
"
is not available unless allow_registration=true
"
,
$
.
proxy
(
function
()
{
test_utils
.
closeControlBox
();
test_utils
.
closeControlBox
();
...
@@ -61,6 +76,9 @@
...
@@ -61,6 +76,9 @@
var
$panels
=
cbview
.
$
(
'
.controlbox-panes
'
);
var
$panels
=
cbview
.
$
(
'
.controlbox-panes
'
);
var
$login
=
$panels
.
children
().
first
();
var
$login
=
$panels
.
children
().
first
();
var
$registration
=
$panels
.
children
().
last
();
var
$registration
=
$panels
.
children
().
last
();
expect
(
$tabs
.
find
(
'
li
'
).
first
().
text
()).
toBe
(
'
Sign in
'
);
expect
(
$tabs
.
find
(
'
li
'
).
last
().
text
()).
toBe
(
'
Register
'
);
spyOn
(
cbview
,
'
switchTab
'
).
andCallThrough
();
spyOn
(
cbview
,
'
switchTab
'
).
andCallThrough
();
cbview
.
delegateEvents
();
// We need to rebind all events otherwise our spy won't be called
cbview
.
delegateEvents
();
// We need to rebind all events otherwise our spy won't be called
$tabs
.
find
(
'
li
'
).
last
().
find
(
'
a
'
).
click
();
// Click the Register tab
$tabs
.
find
(
'
li
'
).
last
().
find
(
'
a
'
).
click
();
// Click the Register tab
...
@@ -94,7 +112,50 @@
...
@@ -94,7 +112,50 @@
},
converse
));
},
converse
));
it
(
"
will render a registration form as received from the XMPP provider
"
,
$
.
proxy
(
function
()
{
it
(
"
will render a registration form as received from the XMPP provider
"
,
$
.
proxy
(
function
()
{
// TODO
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
();
expect
(
registerview
.
_registering
).
toBeFalsy
();
expect
(
this
.
connection
.
connected
).
toBeFalsy
();
registerview
.
$
(
'
input[name=domain]
'
).
val
(
'
conversejs.org
'
);
registerview
.
$
(
'
input[type=submit]
'
).
click
();
expect
(
registerview
.
onProviderChosen
).
toHaveBeenCalled
();
expect
(
registerview
.
_registering
).
toBeTruthy
();
expect
(
this
.
connection
.
connect
).
toHaveBeenCalled
();
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
));
expect
(
registerview
.
getRegistrationFields
).
toHaveBeenCalled
();
expect
(
this
.
connection
.
connected
).
toBeTruthy
();
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
.
onRegistrationFields
).
toHaveBeenCalled
();
expect
(
registerview
.
renderRegistrationForm
).
toHaveBeenCalled
();
expect
(
registerview
.
$
(
'
input
'
).
length
).
toBe
(
5
);
expect
(
registerview
.
$
(
'
input[type=submit]
'
).
length
).
toBe
(
1
);
expect
(
registerview
.
$
(
'
input[type=button]
'
).
length
).
toBe
(
1
);
},
converse
));
},
converse
));
},
converse
,
mock
,
test_utils
));
},
converse
,
mock
,
test_utils
));
...
...
src/templates.js
View file @
03ec659b
...
@@ -35,6 +35,7 @@ define("converse-templates", [
...
@@ -35,6 +35,7 @@ define("converse-templates", [
"
tpl!register_panel
"
,
"
tpl!register_panel
"
,
"
tpl!register_tab
"
,
"
tpl!register_tab
"
,
"
tpl!registration_form
"
,
"
tpl!registration_form
"
,
"
tpl!registration_request
"
,
"
tpl!requesting_contact
"
,
"
tpl!requesting_contact
"
,
"
tpl!requesting_contacts
"
,
"
tpl!requesting_contacts
"
,
"
tpl!room_description
"
,
"
tpl!room_description
"
,
...
@@ -86,18 +87,19 @@ define("converse-templates", [
...
@@ -86,18 +87,19 @@ define("converse-templates", [
register_panel
:
arguments
[
33
],
register_panel
:
arguments
[
33
],
register_tab
:
arguments
[
34
],
register_tab
:
arguments
[
34
],
registration_form
:
arguments
[
35
],
registration_form
:
arguments
[
35
],
requesting_contact
:
arguments
[
36
],
registration_request
:
arguments
[
36
],
requesting_contacts
:
arguments
[
37
],
requesting_contact
:
arguments
[
37
],
room_description
:
arguments
[
38
],
requesting_contacts
:
arguments
[
38
],
room_item
:
arguments
[
39
],
room_description
:
arguments
[
39
],
room_panel
:
arguments
[
40
],
room_item
:
arguments
[
40
],
roster
:
arguments
[
41
],
room_panel
:
arguments
[
41
],
roster_item
:
arguments
[
42
],
roster
:
arguments
[
42
],
search_contact
:
arguments
[
43
],
roster_item
:
arguments
[
43
],
select_option
:
arguments
[
44
],
search_contact
:
arguments
[
44
],
status_option
:
arguments
[
45
],
select_option
:
arguments
[
45
],
toggle_chats
:
arguments
[
46
],
status_option
:
arguments
[
46
],
toolbar
:
arguments
[
47
],
toggle_chats
:
arguments
[
47
],
trimmed_chat
:
arguments
[
48
]
toolbar
:
arguments
[
48
],
trimmed_chat
:
arguments
[
49
]
};
};
});
});
src/templates/registration_request.html
0 → 100644
View file @
03ec659b
<span
class=
"spinner login-submit"
/>
<p
class=
"info"
>
{{info_message}}
</p>
<button
class=
"cancel hor_centered"
>
{{cancel}}
</button>
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