Move all status/alert dialogs into the Left Pane

This commit is contained in:
Josh Perez 2020-02-12 13:30:58 -08:00 committed by GitHub
parent 101070bf42
commit 18fd44f504
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
50 changed files with 1298 additions and 607 deletions

View file

@ -8,10 +8,6 @@ describe('i18n', () => {
it('returns message for given string', () => {
assert.equal(i18n('reportIssue'), 'Report an issue');
});
it('returns message with single substitution', () => {
const actual = i18n('attemptingReconnection', 5);
assert.equal(actual, 'Attempting reconnect in 5 seconds');
});
it('returns message with multiple substitutions', () => {
const actual = i18n('theyChangedTheTimer', ['Someone', '5 minutes']);
assert.equal(

View file

@ -35,7 +35,6 @@
<script type='text/x-tmpl-mustache' id='two-column'>
<div class='gutter'>
<div class='network-status-container'></div>
<div class='left-pane-placeholder'></div>
</div>
<div class='conversation-stack'>
@ -66,13 +65,6 @@
</div>
</script>
<script type='text/x-tmpl-mustache' id='expired_alert'>
<a target='_blank' href='https://signal.org/download/'>
<button class='upgrade'>{{ upgrade }}</button>
</a>
{{ expiredWarning }}
</script>
<script type='text/x-tmpl-mustache' id='banner'>
<div class='body'>
<span class='icon warning'></span>
@ -237,23 +229,6 @@
{{/isStep2}}
</script>
<script type='text/x-tmpl-mustache' id='networkStatus'>
<div class='network-status-message'>
<h3>{{ message }}</h3>
<span>{{ instructions }}</span>
</div>
{{ #reconnectDurationAsSeconds }}
<div class="network-status-message">
{{ attemptingReconnectionMessage }}
</div>
{{/reconnectDurationAsSeconds }}
{{ #action }}
<div class="action">
<button class='small blue {{ buttonClass }}'>{{ action }}</button>
</div>
{{/action }}
</script>
<script type='text/x-tmpl-mustache' id='import-flow-template'>
{{#isStep2}}
<div id='step2' class='step'>
@ -459,7 +434,6 @@
<script type="text/javascript" src="test.js"></script>
<script type='text/javascript' src='../js/registration.js' data-cover></script>
<script type="text/javascript" src="../js/expire.js" data-cover></script>
<script type="text/javascript" src="../js/chromium.js" data-cover></script>
<script type="text/javascript" src="../js/database.js" data-cover></script>
<script type="text/javascript" src="../js/storage.js" data-cover></script>
@ -490,7 +464,6 @@
<script type='text/javascript' src='../js/views/recorder_view.js' data-cover></script>
<script type='text/javascript' src='../js/views/conversation_view.js' data-cover></script>
<script type='text/javascript' src='../js/views/inbox_view.js' data-cover></script>
<script type='text/javascript' src='../js/views/network_status_view.js'></script>
<script type='text/javascript' src='../js/views/confirmation_dialog_view.js' data-cover></script>
<script type='text/javascript' src='../js/views/identicon_svg_view.js' data-cover></script>
<script type='text/javascript' src='../js/views/banner_view.js' data-cover></script>
@ -500,7 +473,6 @@
<script type="text/javascript" src="views/whisper_view_test.js"></script>
<script type="text/javascript" src="views/list_view_test.js"></script>
<script type="text/javascript" src="views/network_status_view_test.js"></script>
<script type="text/javascript" src="models/messages_test.js"></script>

View file

@ -1,180 +0,0 @@
/* global _, $, Whisper */
describe('NetworkStatusView', () => {
describe('getNetworkStatus', () => {
let networkStatusView;
let socketStatus = WebSocket.OPEN;
let oldGetSocketStatus;
/* BEGIN stubbing globals */
before(() => {
oldGetSocketStatus = window.getSocketStatus;
window.getSocketStatus = () => socketStatus;
});
after(() => {
window.getSocketStatus = oldGetSocketStatus;
// It turns out that continued calls to window.getSocketStatus happen
// because we host NetworkStatusView in three mock interfaces, and the view
// checks every N seconds. That results in infinite errors unless there is
// something to call.
window.getSocketStatus = () => WebSocket.OPEN;
});
/* END stubbing globals */
beforeEach(() => {
networkStatusView = new Whisper.NetworkStatusView();
$('.network-status-container').append(networkStatusView.el);
});
afterEach(() => {
// prevents huge number of errors on console after running tests
clearInterval(networkStatusView.renderIntervalHandle);
networkStatusView = null;
});
describe('initialization', () => {
it('should have an empty interval', () => {
assert.equal(
networkStatusView.socketReconnectWaitDuration.asSeconds(),
0
);
});
});
describe('network status with no connection', () => {
beforeEach(() => {
networkStatusView.navigatorOnLine = () => false;
});
it('should be interrupted', () => {
networkStatusView.update();
const status = networkStatusView.getNetworkStatus();
assert(status.hasInterruption);
assert.equal(status.instructions, 'Check your network connection.');
});
it('should display an offline message', () => {
networkStatusView.update();
assert.match(networkStatusView.$el.text(), /Offline/);
});
it('should override socket status', () => {
_([
WebSocket.CONNECTING,
WebSocket.OPEN,
WebSocket.CLOSING,
WebSocket.CLOSED,
]).forEach(socketStatusVal => {
socketStatus = socketStatusVal;
networkStatusView.update();
assert.match(networkStatusView.$el.text(), /Offline/);
});
});
it('should override registration status', () => {
Whisper.Registration.remove();
networkStatusView.update();
assert.match(networkStatusView.$el.text(), /Offline/);
});
});
describe('network status when registration is not done', () => {
beforeEach(() => {
Whisper.Registration.remove();
});
it('should display an unlinked message', () => {
networkStatusView.update();
assert.match(networkStatusView.$el.text(), /Relink/);
});
it('should override socket status', () => {
_([
WebSocket.CONNECTING,
WebSocket.OPEN,
WebSocket.CLOSING,
WebSocket.CLOSED,
]).forEach(socketStatusVal => {
socketStatus = socketStatusVal;
networkStatusView.update();
assert.match(networkStatusView.$el.text(), /Relink/);
});
});
});
describe('network status when registration is done', () => {
beforeEach(() => {
networkStatusView.navigatorOnLine = () => true;
Whisper.Registration.markDone();
networkStatusView.update();
});
it('should not display an unlinked message', () => {
networkStatusView.update();
assert.notMatch(networkStatusView.$el.text(), /Relink/);
});
});
describe('network status when socket is connecting', () => {
beforeEach(() => {
Whisper.Registration.markDone();
socketStatus = WebSocket.CONNECTING;
networkStatusView.update();
});
it('it should display a connecting string if connecting and not in the connecting grace period', () => {
networkStatusView.withinConnectingGracePeriod = false;
networkStatusView.getNetworkStatus();
assert.match(networkStatusView.$el.text(), /Connecting/);
});
it('it should not be interrupted if in connecting grace period', () => {
assert(networkStatusView.withinConnectingGracePeriod);
const status = networkStatusView.getNetworkStatus();
assert.match(networkStatusView.$el.text(), /Connecting/);
assert(!status.hasInterruption);
});
it('it should be interrupted if connecting grace period is over', () => {
networkStatusView.withinConnectingGracePeriod = false;
const status = networkStatusView.getNetworkStatus();
assert(status.hasInterruption);
});
});
describe('network status when socket is open', () => {
before(() => {
socketStatus = WebSocket.OPEN;
});
it('should not be interrupted', () => {
const status = networkStatusView.getNetworkStatus();
assert(!status.hasInterruption);
assert.match(
networkStatusView.$el
.find('.network-status-message')
.text()
.trim(),
/^$/
);
});
});
describe('network status when socket is closed or closing', () => {
_([WebSocket.CLOSED, WebSocket.CLOSING]).forEach(socketStatusVal => {
it('should be interrupted', () => {
socketStatus = socketStatusVal;
networkStatusView.update();
const status = networkStatusView.getNetworkStatus();
assert(status.hasInterruption);
});
});
});
describe('the socket reconnect interval', () => {
beforeEach(() => {
socketStatus = WebSocket.CLOSED;
networkStatusView.setSocketReconnectInterval(61000);
networkStatusView.update();
});
it('should format the message based on the socketReconnectWaitDuration property', () => {
assert.equal(
networkStatusView.socketReconnectWaitDuration.asSeconds(),
61
);
assert.match(
networkStatusView.$('.network-status-message:last').text(),
/Attempting reconnect/
);
});
it('should be reset by changing the socketStatus to CONNECTING', () => {});
});
});
});