sforkowany z mirror/soapbox
				
			Merge branch 'chats-query' into 'develop'
Do not make requests to chats endpoint from profile page if chats are not supported See merge request soapbox-pub/soapbox!2046ci-build
						commit
						191cf7e19a
					
				| 
						 | 
				
			
			@ -5,7 +5,7 @@ import { __stub } from 'soapbox/api';
 | 
			
		|||
import { ChatContext } from 'soapbox/contexts/chat-context';
 | 
			
		||||
import { StatProvider } from 'soapbox/contexts/stat-context';
 | 
			
		||||
import chats from 'soapbox/jest/fixtures/chats.json';
 | 
			
		||||
import { render, screen, waitFor } from 'soapbox/jest/test-helpers';
 | 
			
		||||
import { mockStore, render, rootState, screen, waitFor } from 'soapbox/jest/test-helpers';
 | 
			
		||||
 | 
			
		||||
import ChatPane from '../chat-pane';
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -23,7 +23,12 @@ const renderComponentWithChatContext = (store = {}) => render(
 | 
			
		|||
 | 
			
		||||
describe('<ChatPane />', () => {
 | 
			
		||||
  describe('when there are no chats', () => {
 | 
			
		||||
    let store: ReturnType<typeof mockStore>;
 | 
			
		||||
 | 
			
		||||
    beforeEach(() => {
 | 
			
		||||
      const state = rootState.setIn(['instance', 'version'], '2.7.2 (compatible; Pleroma 2.2.0)');
 | 
			
		||||
      store = mockStore(state);
 | 
			
		||||
 | 
			
		||||
      __stub((mock) => {
 | 
			
		||||
        mock.onGet('/api/v1/pleroma/chats').reply(200, [], {
 | 
			
		||||
          link: null,
 | 
			
		||||
| 
						 | 
				
			
			@ -32,7 +37,7 @@ describe('<ChatPane />', () => {
 | 
			
		|||
    });
 | 
			
		||||
 | 
			
		||||
    it('renders the blankslate', async () => {
 | 
			
		||||
      renderComponentWithChatContext();
 | 
			
		||||
      renderComponentWithChatContext(store);
 | 
			
		||||
 | 
			
		||||
      await waitFor(() => {
 | 
			
		||||
        expect(screen.getByTestId('chat-pane-blankslate')).toBeInTheDocument();
 | 
			
		||||
| 
						 | 
				
			
			@ -57,4 +62,4 @@ describe('<ChatPane />', () => {
 | 
			
		|||
      });
 | 
			
		||||
    });
 | 
			
		||||
  });
 | 
			
		||||
});
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -178,7 +178,8 @@ describe('useChats', () => {
 | 
			
		|||
 | 
			
		||||
  describe('with a successful request', () => {
 | 
			
		||||
    beforeEach(() => {
 | 
			
		||||
      store = mockStore(rootState);
 | 
			
		||||
      const state = rootState.setIn(['instance', 'version'], '2.7.2 (compatible; Pleroma 2.2.0)');
 | 
			
		||||
      store = mockStore(state);
 | 
			
		||||
 | 
			
		||||
      __stub((mock) => {
 | 
			
		||||
        mock.onGet('/api/v1/pleroma/chats')
 | 
			
		||||
| 
						 | 
				
			
			@ -378,4 +379,4 @@ describe('useChatActions', () => {
 | 
			
		|||
      expect((nextQueryData as any).message_expiration).toBe(1200);
 | 
			
		||||
    });
 | 
			
		||||
  });
 | 
			
		||||
});
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -157,6 +157,7 @@ const useChats = (search?: string) => {
 | 
			
		|||
 | 
			
		||||
  const queryInfo = useInfiniteQuery(ChatKeys.chatSearch(search), ({ pageParam }) => getChats(pageParam), {
 | 
			
		||||
    keepPreviousData: true,
 | 
			
		||||
    enabled: features.chats,
 | 
			
		||||
    getNextPageParam: (config) => {
 | 
			
		||||
      if (config.hasMore) {
 | 
			
		||||
        return { link: config.link };
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Ładowanie…
	
		Reference in New Issue