mirror of
https://github.com/mattermost/mattermost-mobile.git
synced 2026-11-07 19:30:14 +00:00
* Fix inconsistent permalink error messages between desktop and mobile Update the permalink inaccessible/deleted message error to match desktop: - Title: "Message not viewable" → "Message Not Found" - Body: "The message you are trying to view..." → "Permalink belongs to a deleted message or to a channel to which you do not have access." Add unit tests for PermalinkError component covering all error states. Made-with: Cursor * Fix lint errors and use path alias in permalink error test - Fix jsx-max-props-per-line violations by placing each prop on its own line - Replace relative import with @screens path alias per repo conventions Made-with: Cursor * Fix import order in permalink error test Reorder @screens before @test and remove empty line between aliased imports to satisfy import/order lint rule. Made-with: Cursor * Mock Markdown component in permalink error test The join channel error states render a Markdown component that requires a WatermelonDB database context. Add a mock following the existing pattern used in tool_card.test.tsx. Made-with: Cursor * Fix duplicate text match in join public channel test The title and button both render "Join channel", causing getByText to throw. Use getAllByText instead. Made-with: Cursor
107 lines
3.5 KiB
TypeScript
107 lines
3.5 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import React from 'react';
|
|
|
|
import PermalinkError from '@screens/permalink/permalink_error';
|
|
import {renderWithIntlAndTheme} from '@test/intl-test-helper';
|
|
|
|
jest.mock('@components/markdown', () => {
|
|
const {Text} = require('react-native');
|
|
const MockMarkdown = ({value}: {value: string}) => (
|
|
<Text testID='mock-markdown'>{value}</Text>
|
|
);
|
|
return MockMarkdown;
|
|
});
|
|
|
|
describe('PermalinkError', () => {
|
|
const baseProps = {
|
|
handleClose: jest.fn(),
|
|
handleJoin: jest.fn(),
|
|
};
|
|
|
|
beforeEach(() => {
|
|
jest.clearAllMocks();
|
|
});
|
|
|
|
describe('inaccessible message (notExist)', () => {
|
|
it('should display "Message Not Found" title', () => {
|
|
const error: PermalinkErrorType = {notExist: true};
|
|
const {getByText} = renderWithIntlAndTheme(
|
|
<PermalinkError
|
|
{...baseProps}
|
|
error={error}
|
|
/>,
|
|
);
|
|
|
|
expect(getByText('Message Not Found')).toBeTruthy();
|
|
});
|
|
|
|
it('should display the correct body text', () => {
|
|
const error: PermalinkErrorType = {notExist: true};
|
|
const {getByText} = renderWithIntlAndTheme(
|
|
<PermalinkError
|
|
{...baseProps}
|
|
error={error}
|
|
/>,
|
|
);
|
|
|
|
expect(getByText('Permalink belongs to a deleted message or to a channel to which you do not have access.')).toBeTruthy();
|
|
});
|
|
});
|
|
|
|
describe('unreachable message', () => {
|
|
it('should display "Message Not Found" title', () => {
|
|
const error: PermalinkErrorType = {unreachable: true};
|
|
const {getByText} = renderWithIntlAndTheme(
|
|
<PermalinkError
|
|
{...baseProps}
|
|
error={error}
|
|
/>,
|
|
);
|
|
|
|
expect(getByText('Message Not Found')).toBeTruthy();
|
|
});
|
|
|
|
it('should display the correct body text', () => {
|
|
const error: PermalinkErrorType = {unreachable: true};
|
|
const {getByText} = renderWithIntlAndTheme(
|
|
<PermalinkError
|
|
{...baseProps}
|
|
error={error}
|
|
/>,
|
|
);
|
|
|
|
expect(getByText('Permalink belongs to a deleted message or to a channel to which you do not have access.')).toBeTruthy();
|
|
});
|
|
});
|
|
|
|
describe('join public channel', () => {
|
|
it('should display "Join channel" title', () => {
|
|
const error: PermalinkErrorType = {channelName: 'test-channel', channelId: 'ch1'};
|
|
const {getAllByText} = renderWithIntlAndTheme(
|
|
<PermalinkError
|
|
{...baseProps}
|
|
error={error}
|
|
/>,
|
|
);
|
|
|
|
expect(getAllByText('Join channel').length).toBeGreaterThanOrEqual(1);
|
|
});
|
|
});
|
|
|
|
describe('join private channel', () => {
|
|
it('should display "Join private channel" title', () => {
|
|
const error: PermalinkErrorType = {privateChannel: true, channelName: 'private-channel', channelId: 'ch1'};
|
|
const {getByText} = renderWithIntlAndTheme(
|
|
<PermalinkError
|
|
{...baseProps}
|
|
error={error}
|
|
/>,
|
|
);
|
|
|
|
expect(getByText('Join private channel')).toBeTruthy();
|
|
});
|
|
});
|
|
});
|