* Added test for draft_scheduled_post and header component * Added test for drafts_button/index.ts * Added test for send_button/index.ts * Added test for servers/scheduled_post.ts queries * Added test for global_scheduled_post_list/index.ts * Added test for rescheduled draft index file and minor update * Added test for core option and index * Added test for scheduled post options * Added test for send_draft index file * updated test for draft_scheduled_post and draft_scheduled_post_header * Updated test for drafts_button index * Updated test for send_button index * Updated test for server/scheduled_post * Updated test for global_scheduled_post/index * removed the unnecessary config and team data to populate in db for test * Update app/components/draft_scheduled_post/draft_scheduled_post.test.tsx Co-authored-by: Daniel Espino García <larkox@gmail.com> * linter fixes --------- Co-authored-by: Mattermost Build <build@mattermost.com> Co-authored-by: Daniel Espino García <larkox@gmail.com>
68 lines
2.6 KiB
TypeScript
68 lines
2.6 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import React from 'react';
|
|
|
|
import {storeGlobal} from '@actions/app/global';
|
|
import {Tutorial} from '@constants';
|
|
import {SYSTEM_IDENTIFIERS} from '@constants/database';
|
|
import DatabaseManager from '@database/manager';
|
|
import {renderWithEverything, waitFor} from '@test/intl-test-helper';
|
|
|
|
import SendButton from './send_button';
|
|
|
|
import EnhancedSendButton from './index';
|
|
|
|
import type ServerDataOperator from '@database/operator/server_data_operator';
|
|
import type {Database} from '@nozbe/watermelondb';
|
|
|
|
jest.mock('./send_button', () => ({
|
|
__esModule: true,
|
|
default: jest.fn(),
|
|
}));
|
|
|
|
jest.mocked(SendButton).mockImplementation((props) => React.createElement('SendButton', {...props, testID: 'send-button'}));
|
|
|
|
describe('SendButton', () => {
|
|
const serverUrl = 'server-1';
|
|
const teamId = 'team1';
|
|
let database: Database;
|
|
let operator: ServerDataOperator;
|
|
|
|
beforeEach(async () => {
|
|
await DatabaseManager.init([serverUrl]);
|
|
const serverDatabaseAndOperator = DatabaseManager.getServerDatabaseAndOperator(serverUrl);
|
|
database = serverDatabaseAndOperator.database;
|
|
operator = serverDatabaseAndOperator.operator;
|
|
|
|
await operator.handleSystem({systems: [{id: SYSTEM_IDENTIFIERS.CURRENT_TEAM_ID, value: teamId}], prepareRecordsOnly: false});
|
|
});
|
|
|
|
afterEach(async () => {
|
|
await DatabaseManager.destroyServerDatabase(serverUrl);
|
|
await storeGlobal(Tutorial.SCHEDULED_POST, null, false);
|
|
});
|
|
|
|
const defaultProps: Parameters<typeof EnhancedSendButton>[0] = {
|
|
testID: 'send-button',
|
|
disabled: false,
|
|
sendMessage: jest.fn(),
|
|
showScheduledPostOptions: jest.fn(),
|
|
scheduledPostEnabled: true,
|
|
};
|
|
|
|
it('should return false if the scheduled post tutorial is not watched', async () => {
|
|
const {getByTestId} = renderWithEverything(<EnhancedSendButton {...defaultProps}/>, {database});
|
|
const sendButton = getByTestId('send-button');
|
|
expect(sendButton.props.scheduledPostFeatureTooltipWatched).toBe(false);
|
|
});
|
|
|
|
it('should return true if the scheduled post tutorial is watched', async () => {
|
|
await storeGlobal(Tutorial.SCHEDULED_POST, 'true', false);
|
|
await waitFor(() => {
|
|
const {getByTestId} = renderWithEverything(<EnhancedSendButton {...defaultProps}/>, {database});
|
|
const sendButton = getByTestId('send-button');
|
|
expect(sendButton.props.scheduledPostFeatureTooltipWatched).toBe(true);
|
|
});
|
|
});
|
|
});
|