mirror of
https://github.com/zulip/zulip.git
synced 2025-11-08 16:01:58 +00:00
stream_creation: Add a clear error message for duplicate streams.
User is now unable to create a stream with duplicate or empty name through the create stream modal. An appropriate error message appears on attempt.
This commit is contained in:
@@ -66,7 +66,8 @@ casper.waitFor(function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
casper.then(function () {
|
casper.then(function () {
|
||||||
casper.test.assertSelectorHasText('.subscription_name', 'Waseemio', 'Subscribing to a stream');
|
casper.test.info("User should be subscribed to stream Waseemio");
|
||||||
|
casper.test.assertSelectorHasText('.subscription_name', 'Waseemio');
|
||||||
casper.fill('form#add_new_subscription', {stream_name: 'WASeemio'});
|
casper.fill('form#add_new_subscription', {stream_name: 'WASeemio'});
|
||||||
casper.click('form#add_new_subscription input.btn');
|
casper.click('form#add_new_subscription input.btn');
|
||||||
});
|
});
|
||||||
@@ -74,19 +75,23 @@ casper.waitForText('Already subscribed', function () {
|
|||||||
casper.test.assertTextExists('Already subscribed', "Can't subscribe twice to a stream");
|
casper.test.assertTextExists('Already subscribed', "Can't subscribe twice to a stream");
|
||||||
casper.fill('form#add_new_subscription', {stream_name: ' '});
|
casper.fill('form#add_new_subscription', {stream_name: ' '});
|
||||||
casper.click('form#add_new_subscription input.btn');
|
casper.click('form#add_new_subscription input.btn');
|
||||||
});
|
|
||||||
casper.waitForText('Create stream', function () {
|
|
||||||
casper.test.assertTextExists('Create stream', 'Modal for specifying new stream users');
|
|
||||||
casper.fill('form#stream_creation_form', {stream_name: ' '});
|
casper.fill('form#stream_creation_form', {stream_name: ' '});
|
||||||
casper.click('form#stream_creation_form button.btn.btn-primary');
|
casper.click('form#stream_creation_form button.btn.btn-primary');
|
||||||
});
|
});
|
||||||
casper.waitForText('Error creating stream', function () {
|
casper.waitForText('A stream needs to have a name', function () {
|
||||||
casper.test.assertTextExists('Invalid stream name', "Can't create a stream without a name");
|
casper.test.assertTextExists('A stream needs to have a name', "Can't create a stream with an empty name");
|
||||||
|
casper.click('form#stream_creation_form button.btn.btn-default');
|
||||||
|
casper.fill('form#add_new_subscription', {stream_name: ' '});
|
||||||
|
casper.click('form#add_new_subscription input.btn');
|
||||||
|
casper.fill('form#stream_creation_form', {stream_name: 'Waseemio'});
|
||||||
|
casper.click('form#stream_creation_form button.btn.btn-primary');
|
||||||
});
|
});
|
||||||
casper.then(function () {
|
casper.waitForText('A stream with this name already exists', function () {
|
||||||
|
casper.test.assertTextExists('A stream with this name already exists', "Can't create a stream with a duplicate name");
|
||||||
casper.test.info('Streams should be filtered when typing in the create box');
|
casper.test.info('Streams should be filtered when typing in the create box');
|
||||||
|
casper.click('form#stream_creation_form button.btn.btn-default');
|
||||||
});
|
});
|
||||||
casper.then(function () {
|
casper.waitForText('Filter by stream name', function () {
|
||||||
casper.test.assertSelectorHasText('.subscription_row .subscription_name', 'Verona', 'Verona stream exists before filtering');
|
casper.test.assertSelectorHasText('.subscription_row .subscription_name', 'Verona', 'Verona stream exists before filtering');
|
||||||
casper.test.assertSelectorDoesntHaveText('.subscription_row.notdisplayed .subscription_name', 'Verona', 'Verona stream shown before filtering');
|
casper.test.assertSelectorDoesntHaveText('.subscription_row.notdisplayed .subscription_name', 'Verona', 'Verona stream shown before filtering');
|
||||||
});
|
});
|
||||||
@@ -97,7 +102,7 @@ casper.then(function () {
|
|||||||
.trigger($.Event('input'));
|
.trigger($.Event('input'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
casper.then(function () {
|
casper.waitForSelectorTextChange('form#add_new_subscription', function () {
|
||||||
casper.test.assertSelectorHasText('.subscription_row.notdisplayed .subscription_name', 'Verona', 'Verona stream not shown after filtering');
|
casper.test.assertSelectorHasText('.subscription_row.notdisplayed .subscription_name', 'Verona', 'Verona stream not shown after filtering');
|
||||||
casper.test.assertSelectorHasText('.subscription_row .subscription_name', 'Waseemio', 'Waseemio stream exists after filtering');
|
casper.test.assertSelectorHasText('.subscription_row .subscription_name', 'Waseemio', 'Waseemio stream exists after filtering');
|
||||||
casper.test.assertSelectorDoesntHaveText('.subscription_row.notdisplayed .subscription_name', 'Waseemio', 'Waseemio stream shown after filtering');
|
casper.test.assertSelectorDoesntHaveText('.subscription_row.notdisplayed .subscription_name', 'Waseemio', 'Waseemio stream shown after filtering');
|
||||||
|
|||||||
@@ -717,6 +717,8 @@ function show_new_stream_modal() {
|
|||||||
$('#announce-new-stream input').prop('disabled', false);
|
$('#announce-new-stream input').prop('disabled', false);
|
||||||
$('#announce-new-stream input').prop('checked', true);
|
$('#announce-new-stream input').prop('checked', true);
|
||||||
|
|
||||||
|
$("#stream_name_error").hide();
|
||||||
|
|
||||||
$('#stream-creation').modal("show");
|
$('#stream-creation').modal("show");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -783,6 +785,7 @@ $(function () {
|
|||||||
if (stream_status === "does-not-exist" || !stream) {
|
if (stream_status === "does-not-exist" || !stream) {
|
||||||
$('#create_stream_name').val(stream);
|
$('#create_stream_name').val(stream);
|
||||||
show_new_stream_modal();
|
show_new_stream_modal();
|
||||||
|
$('#create_stream_name').focus();
|
||||||
} else {
|
} else {
|
||||||
ajaxSubscribe(stream);
|
ajaxSubscribe(stream);
|
||||||
}
|
}
|
||||||
@@ -858,9 +861,24 @@ $(function () {
|
|||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("#create_stream_name").on("focusout", function () {
|
||||||
|
var stream = $.trim($("#create_stream_name").val());
|
||||||
|
var stream_status = compose.check_stream_existence(stream);
|
||||||
|
if (stream.length < 1) {
|
||||||
|
$("#stream_name_error").text(i18n.t("A stream needs to have a name"));
|
||||||
|
$("#stream_name_error").show();
|
||||||
|
} else if (stream_status !== "does-not-exist") {
|
||||||
|
$("#stream_name_error").text(i18n.t("A stream with this name already exists"));
|
||||||
|
$("#stream_name_error").show();
|
||||||
|
} else {
|
||||||
|
$("#stream_name_error").hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$("#stream_creation_form").on("submit", function (e) {
|
$("#stream_creation_form").on("submit", function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var stream = $.trim($("#create_stream_name").val());
|
var stream = $.trim($("#create_stream_name").val());
|
||||||
|
if (!$("#stream_name_error").is(":visible")) {
|
||||||
var principals = _.map(
|
var principals = _.map(
|
||||||
$("#stream_creation_form input:checkbox[name=user]:checked"),
|
$("#stream_creation_form input:checkbox[name=user]:checked"),
|
||||||
function (elem) {
|
function (elem) {
|
||||||
@@ -874,6 +892,7 @@ $(function () {
|
|||||||
$('#stream_creation_form input[name=privacy]:checked').val() === "invite-only",
|
$('#stream_creation_form input[name=privacy]:checked').val() === "invite-only",
|
||||||
$('#announce-new-stream input').prop('checked')
|
$('#announce-new-stream input').prop('checked')
|
||||||
);
|
);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$("body").on("mouseover", ".subscribed-button", function (e) {
|
$("body").on("mouseover", ".subscribed-button", function (e) {
|
||||||
|
|||||||
@@ -2945,6 +2945,12 @@ form#add_new_subscription {
|
|||||||
margin-right: 38px;
|
margin-right: 38px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#stream_name_error {
|
||||||
|
display: none;
|
||||||
|
margin-left: 2px;
|
||||||
|
color: #FF0000;
|
||||||
|
}
|
||||||
|
|
||||||
.sub_settings_title {
|
.sub_settings_title {
|
||||||
line-height: 30px;
|
line-height: 30px;
|
||||||
margin: 10px 0;
|
margin: 10px 0;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
<b>{% trans %}Stream name{% endtrans %}</b><br />
|
<b>{% trans %}Stream name{% endtrans %}</b><br />
|
||||||
<input type="text" name="stream_name" id="create_stream_name"
|
<input type="text" name="stream_name" id="create_stream_name"
|
||||||
placeholder="{{ _('Stream name') }}" value="" autocomplete="off" />
|
placeholder="{{ _('Stream name') }}" value="" autocomplete="off" />
|
||||||
|
<div id="stream_name_error"></div>
|
||||||
</div>
|
</div>
|
||||||
<div id="make-invite-only">
|
<div id="make-invite-only">
|
||||||
<b>{% trans %}Stream accessibility{% endtrans %}</b><br />
|
<b>{% trans %}Stream accessibility{% endtrans %}</b><br />
|
||||||
|
|||||||
Reference in New Issue
Block a user