Skip to content

Commit

Permalink
js: Normalize strings to double quotes.
Browse files Browse the repository at this point in the history
Prettier would do this anyway, but it’s separated out for a more
reviewable diff.  Generated by ESLint.

Signed-off-by: Anders Kaseorg <[email protected]>
  • Loading branch information
andersk authored and timabbott committed Jul 17, 2020
1 parent 06691e1 commit f3726db
Show file tree
Hide file tree
Showing 344 changed files with 14,450 additions and 14,445 deletions.
5 changes: 5 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@
}
],
"quote-props": [ "error", "as-needed" ],
"quotes": [
"error",
"double",
{ "avoidEscape": true, "allowTemplateLiterals": false }
],
"radix": "error",
"semi": "error",
"semi-spacing": "error",
Expand Down
82 changes: 41 additions & 41 deletions frontend_tests/casper_lib/common.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var util = require("util");

var test_credentials = require('../../var/casper/test_credentials.js').test_credentials;
var test_credentials = require("../../var/casper/test_credentials.js").test_credentials;

casper.options.clientScripts.push("frontend_tests/casper_lib/polyfill.js");

Expand All @@ -14,7 +14,7 @@ var last_send_or_update = -1;
function log_in() {
var credentials = test_credentials.default_user;

casper.test.info('Logging in');
casper.test.info("Logging in");
casper.fill('form[action^="/accounts/login/"]', {
username: credentials.username,
password: credentials.password,
Expand Down Expand Up @@ -55,39 +55,39 @@ exports.initialize_casper = function () {
// set this at the PhantomJS level.
casper.page.onError = function (msg, trace) {
casper.test.error(msg);
casper.echo('Traceback:');
casper.echo("Traceback:");
trace.forEach(function (item) {
casper.echo(' ' + item.file + ':' + item.line);
casper.echo(" " + item.file + ":" + item.line);
});
casper.exit(1);
};

// Capture screens from all failures
var casper_failure_count = 1;
casper.test.on('fail', function failure() {
casper.test.on("fail", function failure() {
if (casper_failure_count <= 10) {
casper.capture("var/casper/casper-failure" + casper_failure_count + ".png");
casper_failure_count += 1;
}
});

// Update last_send_or_update whenever get_events returns.
casper.on('resource.received', function (resource) {
casper.on("resource.received", function (resource) {
if (/\/json\/get_events/.test(resource.url)) {
last_send_or_update = timestamp();
}
});

casper.on('load.finished', function () {
casper.test.info('page load finished');
casper.on("load.finished", function () {
casper.test.info("page load finished");
});

casper.evaluate(function () {
window.localStorage.clear();
});

// This captures console messages from the app.
casper.on('remote.message', function (msg) {
casper.on("remote.message", function (msg) {
casper.echo("app console: " + msg);
});
};
Expand Down Expand Up @@ -116,14 +116,14 @@ exports.then_log_in = function () {
};

exports.then_log_out = function () {
var menu_selector = '#settings-dropdown';
var menu_selector = "#settings-dropdown";
var logout_selector = 'a[href="#logout"]';

casper.waitUntilVisible(menu_selector, function () {
casper.click(menu_selector);

casper.waitUntilVisible(logout_selector, function () {
casper.test.info('Logging out');
casper.test.info("Logging out");
casper.click(logout_selector);

});
Expand All @@ -139,15 +139,15 @@ exports.then_log_out = function () {
// select the menu item matching item by typing str.
exports.select_item_via_typeahead = function (field_selector, str, item) {
casper.then(function () {
casper.test.info('Looking in ' + field_selector + ' to select ' + str + ', ' + item);
casper.test.info("Looking in " + field_selector + " to select " + str + ", " + item);

casper.evaluate(function (field_selector, str, item) {
// Set the value and then send a bogus keyup event to trigger
// the typeahead.
$(field_selector)
.focus()
.val(str)
.trigger($.Event('keyup', { which: 0 }));
.trigger($.Event("keyup", { which: 0 }));

// You might think these steps should be split by casper.then,
// but apparently that's enough to make the typeahead close (??),
Expand Down Expand Up @@ -227,13 +227,13 @@ exports.wait_for_message_fully_processed = function (content) {
don't add the star icon until the server
responds.
*/
return row.find('.star').length === 1;
return row.find(".star").length === 1;
}, { content: content});
});
};

exports.turn_off_press_enter_to_send = function () {
var enter_send_selector = '#enter_sends';
var enter_send_selector = "#enter_sends";
casper.waitForSelector(enter_send_selector);

var is_checked = casper.evaluate(function (enter_send_selector) {
Expand Down Expand Up @@ -269,15 +269,15 @@ exports.then_send_message = function (type, params) {
delete params.outside_view;

casper.then(function () {
casper.waitForSelector('#compose-send-button:enabled');
casper.waitForSelector('#compose-textarea');
casper.waitForSelector("#compose-send-button:enabled");
casper.waitForSelector("#compose-textarea");
});

casper.then(function () {
if (type === "stream") {
casper.page.sendEvent('keypress', "c");
casper.page.sendEvent("keypress", "c");
} else if (type === "private") {
casper.page.sendEvent('keypress', "x");
casper.page.sendEvent("keypress", "x");
} else {
casper.test.assertTrue(false, "send_message got valid message type");
}
Expand All @@ -300,13 +300,13 @@ exports.then_send_message = function (type, params) {
exports.turn_off_press_enter_to_send();

casper.then(function () {
casper.click('#compose-send-button');
casper.click("#compose-send-button");
});
});

casper.then(function () {
casper.waitFor(function emptyComposeBox() {
return casper.getFormValues('form[action^="/json/messages"]').content === '';
return casper.getFormValues('form[action^="/json/messages"]').content === "";
});
if (!outside_view) {
exports.wait_for_message_fully_processed(params.content);
Expand All @@ -328,16 +328,16 @@ exports.then_send_message = function (type, params) {
// 'table' here).
exports.get_rendered_messages = function (table) {
return casper.evaluate(function (table) {
var tbl = $('#' + table);
var tbl = $("#" + table);
return {
headings: $.map(tbl.find('.recipient_row .message-header-contents'), function (elem) {
headings: $.map(tbl.find(".recipient_row .message-header-contents"), function (elem) {
var $clone = $(elem).clone(true);
$clone.find(".recipient_row_date").remove();

return $clone.text().trim().replace(/\s+/g, ' ');
return $clone.text().trim().replace(/\s+/g, " ");
}),

bodies: $.map(tbl.find('.message_content'), function (elem) {
bodies: $.map(tbl.find(".message_content"), function (elem) {
return elem.innerHTML;
}),
};
Expand Down Expand Up @@ -373,7 +373,7 @@ exports.get_stream_id = function (stream_name) {
// presses by code, only strings of printable characters.
exports.keypress = function (code) {
casper.evaluate(function (code) {
$('body').trigger($.Event('keydown', { which: code }));
$("body").trigger($.Event("keydown", { which: code }));
}, {
code: code,
});
Expand All @@ -382,7 +382,7 @@ exports.keypress = function (code) {
exports.then_send_many = function (msgs) {
msgs.forEach(function (msg) {
exports.then_send_message(
msg.stream !== undefined ? 'stream' : 'private',
msg.stream !== undefined ? "stream" : "private",
msg);
});
};
Expand All @@ -397,21 +397,21 @@ exports.wait_for_receive = function (step) {

// Wait until the loading spinner goes away (helpful just after logging in).
exports.wait_for_load = function (step) {
casper.waitWhileVisible('#page_loading_indicator', step);
casper.waitWhileVisible("#page_loading_indicator", step);
};

// innerText sometimes gives us non-breaking space characters, and occasionally
// a different number of spaces than we expect.
exports.normalize_spaces = function (str) {
return str.replace(/\s+/g, ' ');
return str.replace(/\s+/g, " ");
};

exports.ltrim = function (str) {
return str.replace(/^\s+/g, '');
return str.replace(/^\s+/g, "");
};

exports.rtrim = function (str) {
return str.replace(/\s+$/g, '');
return str.replace(/\s+$/g, "");
};

exports.trim = function (str) {
Expand All @@ -421,24 +421,24 @@ exports.trim = function (str) {
// Call get_rendered_messages and then check that the last few headings and
// bodies match the specified arrays.
exports.expected_messages = function (table, headings, bodies) {
casper.test.assertVisible('#' + table, table + ' is visible');
casper.test.assertVisible("#" + table, table + " is visible");

var msg = exports.get_rendered_messages(table);

casper.test.assertEquals(
msg.headings.slice(-headings.length),
headings.map(exports.trim),
'Got expected message headings');
"Got expected message headings");

casper.test.assertEquals(
msg.bodies.slice(-bodies.length),
bodies,
'Got expected message bodies');
"Got expected message bodies");
};

exports.un_narrow = function () {
casper.test.info('Un-narrowing');
if (casper.visible('.message_comp')) {
casper.test.info("Un-narrowing");
if (casper.visible(".message_comp")) {
// close the compose box
common.keypress(27); // Esc
}
Expand All @@ -447,20 +447,20 @@ exports.un_narrow = function () {

exports.manage_organization = function () {
casper.then(function () {
var menu_selector = '#settings-dropdown';
var menu_selector = "#settings-dropdown";
casper.waitUntilVisible(menu_selector, function () {
casper.click(menu_selector);
});
});

casper.then(function () {
casper.test.info('Organization page');
casper.test.info("Organization page");
casper.click('a[href^="#organization"]');
});

casper.waitForSelector('#settings_overlay_container.show', function () {
casper.test.info('Organization page is active');
casper.test.assertUrlMatch(/^http:\/\/[^/]+\/#organization/, 'URL suggests we are on organization page');
casper.waitForSelector("#settings_overlay_container.show", function () {
casper.test.info("Organization page is active");
casper.test.assertUrlMatch(/^http:\/\/[^/]+\/#organization/, "URL suggests we are on organization page");
});

casper.then(function () {
Expand Down
40 changes: 20 additions & 20 deletions frontend_tests/casper_tests/00-realm-creation.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
var common = require('../casper_lib/common.js');
var common = require("../casper_lib/common.js");

var email = '[email protected]';
var subdomain = 'testsubdomain';
var organization_name = 'Awesome Organization';
var email = "[email protected]";
var subdomain = "testsubdomain";
var organization_name = "Awesome Organization";
var host = "zulipdev.com:9981";
var realm_host = "testsubdomain" + '.' + host;
var realm_host = "testsubdomain" + "." + host;

casper.start('http://' + host + '/new/');
casper.start("http://" + host + "/new/");

casper.then(function () {
// Submit the email for realm creation
Expand All @@ -17,58 +17,58 @@ casper.then(function () {
});
// Make sure confirmation email is send
this.waitWhileVisible('form[name="email_form"]', function () {
var regex = new RegExp('^http://[^/]+/accounts/new/send_confirm/' + email);
this.test.assertUrlMatch(regex, 'Confirmation mail send');
var regex = new RegExp("^http://[^/]+/accounts/new/send_confirm/" + email);
this.test.assertUrlMatch(regex, "Confirmation mail send");
});
});

// Special endpoint enabled only during tests for extracting confirmation key
casper.thenOpen('http://' + host + '/confirmation_key/');
casper.thenOpen("http://" + host + "/confirmation_key/");

// Open the confirmation URL
casper.then(function () {
var confirmation_key = JSON.parse(this.getPageContent()).confirmation_key;
var confirmation_url = 'http://' + host + '/accounts/do_confirm/' + confirmation_key;
var confirmation_url = "http://" + host + "/accounts/do_confirm/" + confirmation_key;
this.thenOpen(confirmation_url);
});

// Make sure the realm creation page is loaded correctly
casper.then(function () {
this.waitUntilVisible('.pitch', function () {
this.test.assertSelectorContains('.pitch', "We just need you to do one last thing.");
this.waitUntilVisible(".pitch", function () {
this.test.assertSelectorContains(".pitch", "We just need you to do one last thing.");
});

this.waitUntilVisible('#id_email', function () {
this.waitUntilVisible("#id_email", function () {
this.test.assertEvalEquals(function () {
return $('#id_email').attr('placeholder');
return $("#id_email").attr("placeholder");
}, email);
});

this.waitUntilVisible('label[for=id_team_name]', function () {
this.test.assertSelectorHasText('label[for=id_team_name]', 'Organization name');
this.waitUntilVisible("label[for=id_team_name]", function () {
this.test.assertSelectorHasText("label[for=id_team_name]", "Organization name");
});
});

casper.then(function () {
this.waitUntilVisible('form[action^="/accounts/register/"]', function () {
this.fill('form[action^="/accounts/register/"]', {
full_name: 'Alice',
full_name: "Alice",
realm_name: organization_name,
realm_subdomain: subdomain,
password: 'passwordwhichisreallyreallyreallycomplexandnotguessable',
password: "passwordwhichisreallyreallyreallycomplexandnotguessable",
terms: true,
realm_in_root_domain: false,
}, true);
});

this.waitWhileVisible('form[action^="/accounts/register/"]', function () {
casper.test.assertUrlMatch(realm_host + '/', 'Home page loaded');
casper.test.assertUrlMatch(realm_host + "/", "Home page loaded");
});
});

casper.then(function () {
// The user is logged in to the newly created realm and the app is loaded
casper.waitUntilVisible('.message_row', function () {
casper.waitUntilVisible(".message_row", function () {
this.test.assertTitleMatch(/ - Zulip$/, "Successfully logged into Zulip webapp");
}, null, 20000);
});
Expand Down
4 changes: 2 additions & 2 deletions frontend_tests/casper_tests/01-login.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
var common = require('../casper_lib/common.js');
var common = require("../casper_lib/common.js");
var realm_url = "http://zulip.zulipdev.com:9981/";

// Start of test script.
common.init_viewport();
casper.start(realm_url, common.initialize_casper);

casper.then(function () {
casper.test.assertUrlMatch(/^http:\/\/[^/]+\/login\/$/, 'Redirected to /login/');
casper.test.assertUrlMatch(/^http:\/\/[^/]+\/login\/$/, "Redirected to /login/");
});

common.then_log_in();
Expand Down
Loading

0 comments on commit f3726db

Please sign in to comment.