mirror of
https://github.com/zulip/zulip.git
synced 2026-06-21 21:32:29 +08:00
Added new option to download .zuliprc file directly from settings page. This should help reduce friction when setting up new bots/integrations. This new feature is available in the bot cards and the 'show your API key' section. One caveat is that the filename is automatically set to 'zuliprc' instead of '.zuliprc', since as most browsers do not allow filenames to start with a dot. Fixes #2327.
38 lines
1.2 KiB
JavaScript
38 lines
1.2 KiB
JavaScript
var jsdom = require("jsdom");
|
|
var window = jsdom.jsdom().defaultView;
|
|
global.$ = require("jquery")(window);
|
|
|
|
set_global("page_params", {
|
|
realm_uri: "https://chat.example.com",
|
|
});
|
|
|
|
var settings = require("js/settings.js");
|
|
|
|
(function test_generate_zuliprc_uri() {
|
|
var bot = {
|
|
email: "[email protected]",
|
|
api_key: "QadL788EkiottHmukyhHgePUFHREiu8b",
|
|
};
|
|
var uri = settings.generate_zuliprc_uri(bot.email, bot.api_key);
|
|
var expected = "data:application/octet-stream;charset=utf-8," + encodeURIComponent(
|
|
"[api]\[email protected]\n" +
|
|
"key=QadL788EkiottHmukyhHgePUFHREiu8b\n" +
|
|
"site=https://chat.example.com\n"
|
|
);
|
|
|
|
assert.equal(uri, expected);
|
|
}());
|
|
|
|
(function test_generate_zuliprc_content() {
|
|
var user = {
|
|
email: "[email protected]",
|
|
api_key: "nSlA0mUm7G42LP85lMv7syqFTzDE2q34"
|
|
};
|
|
var content = settings.generate_zuliprc_content(user.email, user.api_key);
|
|
var expected = "[api]\[email protected]\n" +
|
|
"key=nSlA0mUm7G42LP85lMv7syqFTzDE2q34\n" +
|
|
"site=https://chat.example.com\n";
|
|
|
|
assert.equal(content, expected);
|
|
}());
|