mirror of
https://github.com/thelounge/thelounge
synced 2024-11-27 06:20:26 +00:00
d1548572d4
This change improves privacy/security by ensuring all local storage (which includes settings, etc.) is destroyed on sign out or when revoking a remote session. Because signing out is now more "risky", the button has been moved to the settings along with other existing sessions. This commit: - Removes the power/sign-out icon from the sidebar footer (gives additional room for when the admin panel gets added) - Adds a "Sign out" button next to the current session info in the settings session list - Renames "Disconnect" buttons into "Revoke" to better clarify the intent (I will admit that I borrowed the wording from Telegram) - Fixes incorrect `localStorage.remove` method - Uses Sinon.js to mock wrappers for `window.localStorage` and `window.location` (does not mock those themselves, in the "Do not mock what you do not own" fashion, mock our layer instead). I expect we will be able to test a bit more from the UI with this. A good next candidate will be the `mockLogger` things.
31 lines
775 B
JavaScript
31 lines
775 B
JavaScript
"use strict";
|
|
|
|
const expect = require("chai").expect;
|
|
const stub = require("sinon").stub;
|
|
const Auth = require("../../../client/js/auth");
|
|
const localStorage = require("../../../client/js/localStorage");
|
|
const location = require("../../../client/js/location");
|
|
|
|
describe("Auth", function() {
|
|
describe(".signout", function() {
|
|
beforeEach(function() {
|
|
stub(localStorage, "clear");
|
|
stub(location, "reload");
|
|
});
|
|
|
|
afterEach(function() {
|
|
localStorage.clear.restore();
|
|
location.reload.restore();
|
|
});
|
|
|
|
it("should empty the local storage", function() {
|
|
Auth.signout();
|
|
expect(localStorage.clear.calledOnce).to.be.true;
|
|
});
|
|
|
|
it("should reload the page", function() {
|
|
Auth.signout();
|
|
expect(location.reload.calledOnce).to.be.true;
|
|
});
|
|
});
|
|
});
|