Pressing Esc in left pane composer menu should go back

This commit is contained in:
Evan Hahn
2021-04-02 16:43:39 -05:00
committed by Josh Perez
parent 2d35fa8f57
commit f05d45ac9b
12 changed files with 168 additions and 5 deletions

View File

@@ -2,6 +2,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
import { assert } from 'chai';
import * as sinon from 'sinon';
import { v4 as uuid } from 'uuid';
import { RowType } from '../../../components/ConversationList';
import { FindDirection } from '../../../components/leftPane/LeftPaneHelper';
@@ -15,6 +16,15 @@ describe('LeftPaneArchiveHelper', () => {
type: 'direct' as const,
});
describe('getBackAction', () => {
it('returns the "show inbox" action', () => {
const showInbox = sinon.fake();
const helper = new LeftPaneArchiveHelper({ archivedConversations: [] });
assert.strictEqual(helper.getBackAction({ showInbox }), showInbox);
});
});
describe('getRowCount', () => {
it('returns the number of archived conversations', () => {
assert.strictEqual(

View File

@@ -45,6 +45,18 @@ describe('LeftPaneChooseGroupMembersHelper', () => {
sinonSandbox.restore();
});
describe('getBackAction', () => {
it('returns the "show composer" action', () => {
const startComposing = sinon.fake();
const helper = new LeftPaneChooseGroupMembersHelper(defaults);
assert.strictEqual(
helper.getBackAction({ startComposing }),
startComposing
);
});
});
describe('getRowCount', () => {
it('returns 0 if there are no contacts', () => {
assert.strictEqual(

View File

@@ -35,6 +35,19 @@ describe('LeftPaneComposeHelper', () => {
sinonSandbox.restore();
});
describe('getBackAction', () => {
it('returns the "show inbox" action', () => {
const showInbox = sinon.fake();
const helper = new LeftPaneComposeHelper({
composeContacts: [],
regionCode: 'US',
searchTerm: '',
});
assert.strictEqual(helper.getBackAction({ showInbox }), showInbox);
});
});
describe('getRowCount', () => {
it('returns 1 (for the "new group" button) if not searching and there are no contacts', () => {
assert.strictEqual(

View File

@@ -2,6 +2,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
import { assert } from 'chai';
import * as sinon from 'sinon';
import { v4 as uuid } from 'uuid';
import { RowType } from '../../../components/ConversationList';
import { FindDirection } from '../../../components/leftPane/LeftPaneHelper';
@@ -15,6 +16,24 @@ describe('LeftPaneInboxHelper', () => {
type: 'direct' as const,
});
describe('getBackAction', () => {
it("returns undefined; you can't go back from the main inbox", () => {
const helper = new LeftPaneInboxHelper({
conversations: [],
pinnedConversations: [],
archivedConversations: [],
});
assert.isUndefined(
helper.getBackAction({
showChooseGroupMembers: sinon.fake(),
showInbox: sinon.fake(),
startComposing: sinon.fake(),
})
);
});
});
describe('getRowCount', () => {
it('returns 0 if there are no conversations', () => {
const helper = new LeftPaneInboxHelper({

View File

@@ -2,6 +2,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
import { assert } from 'chai';
import * as sinon from 'sinon';
import { v4 as uuid } from 'uuid';
import { RowType } from '../../../components/ConversationList';
@@ -19,6 +20,25 @@ describe('LeftPaneSearchHelper', () => {
conversationId: uuid(),
});
describe('getBackAction', () => {
it('returns undefined; going back is handled elsewhere in the app', () => {
const helper = new LeftPaneSearchHelper({
conversationResults: { isLoading: false, results: [] },
contactResults: { isLoading: false, results: [] },
messageResults: { isLoading: false, results: [] },
searchTerm: 'foo',
});
assert.isUndefined(
helper.getBackAction({
showChooseGroupMembers: sinon.fake(),
showInbox: sinon.fake(),
startComposing: sinon.fake(),
})
);
});
});
describe('getRowCount', () => {
it('returns 0 when there are no search results', () => {
const helper = new LeftPaneSearchHelper({

View File

@@ -2,6 +2,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
import { assert } from 'chai';
import * as sinon from 'sinon';
import { v4 as uuid } from 'uuid';
import { RowType } from '../../../components/ConversationList';
@@ -14,6 +15,38 @@ describe('LeftPaneSetGroupMetadataHelper', () => {
type: 'direct' as const,
});
describe('getBackAction', () => {
it('returns the "show composer" action if a request is not active', () => {
const showChooseGroupMembers = sinon.fake();
const helper = new LeftPaneSetGroupMetadataHelper({
groupAvatar: undefined,
groupName: '',
hasError: false,
isCreating: false,
selectedContacts: [],
});
assert.strictEqual(
helper.getBackAction({ showChooseGroupMembers }),
showChooseGroupMembers
);
});
it("returns undefined (i.e., you can't go back) if a request is active", () => {
const helper = new LeftPaneSetGroupMetadataHelper({
groupAvatar: undefined,
groupName: 'Foo Bar',
hasError: false,
isCreating: true,
selectedContacts: [],
});
assert.isUndefined(
helper.getBackAction({ showChooseGroupMembers: sinon.fake() })
);
});
});
describe('getRowCount', () => {
it('returns 0 if there are no contacts', () => {
assert.strictEqual(