parent
ced600657b
commit
4fc6640c2c
@ -1,92 +1,94 @@
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import React from 'react';
|
||||
|
||||
import { __stub } from 'soapbox/api';
|
||||
import { buildAccount } from 'soapbox/jest/factory';
|
||||
import { render, screen, waitFor } from 'soapbox/jest/test-helpers';
|
||||
|
||||
import ChatPage from '../chat-page';
|
||||
|
||||
describe('<ChatPage />', () => {
|
||||
let store: any;
|
||||
|
||||
describe('before you finish onboarding', () => {
|
||||
it('renders the Welcome component', () => {
|
||||
render(<ChatPage />);
|
||||
|
||||
expect(screen.getByTestId('chats-welcome')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
describe('when you complete onboarding', () => {
|
||||
const id = '1';
|
||||
|
||||
beforeEach(() => {
|
||||
store = {
|
||||
me: id,
|
||||
accounts: {
|
||||
[id]: buildAccount({
|
||||
id,
|
||||
acct: 'justin-username',
|
||||
display_name: 'Justin L',
|
||||
avatar: 'test.jpg',
|
||||
source: {
|
||||
chats_onboarded: false,
|
||||
},
|
||||
}),
|
||||
},
|
||||
};
|
||||
|
||||
__stub((mock) => {
|
||||
mock
|
||||
.onPatch('/api/v1/accounts/update_credentials')
|
||||
.reply(200, { chats_onboarded: true, id });
|
||||
});
|
||||
});
|
||||
|
||||
it('renders the Chats', async () => {
|
||||
render(<ChatPage />, undefined, store);
|
||||
await userEvent.click(screen.getByTestId('button'));
|
||||
|
||||
expect(screen.getByTestId('chat-page')).toBeInTheDocument();
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByTestId('toast')).toHaveTextContent('Chat Settings updated successfully');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the API returns an error', () => {
|
||||
beforeEach(() => {
|
||||
store = {
|
||||
me: '1',
|
||||
accounts: {
|
||||
'1': buildAccount({
|
||||
id: '1',
|
||||
acct: 'justin-username',
|
||||
display_name: 'Justin L',
|
||||
avatar: 'test.jpg',
|
||||
source: {
|
||||
chats_onboarded: false,
|
||||
},
|
||||
}),
|
||||
},
|
||||
};
|
||||
|
||||
__stub((mock) => {
|
||||
mock
|
||||
.onPatch('/api/v1/accounts/update_credentials')
|
||||
.networkError();
|
||||
});
|
||||
});
|
||||
|
||||
it('renders the Chats', async () => {
|
||||
render(<ChatPage />, undefined, store);
|
||||
await userEvent.click(screen.getByTestId('button'));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByTestId('toast')).toHaveTextContent('Chat Settings failed to update.');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
test.skip('skip', () => {});
|
||||
|
||||
// import userEvent from '@testing-library/user-event';
|
||||
// import React from 'react';
|
||||
|
||||
// import { __stub } from 'soapbox/api';
|
||||
// import { buildAccount } from 'soapbox/jest/factory';
|
||||
// import { render, screen, waitFor } from 'soapbox/jest/test-helpers';
|
||||
|
||||
// import ChatPage from '../chat-page';
|
||||
|
||||
// describe('<ChatPage />', () => {
|
||||
// let store: any;
|
||||
|
||||
// describe('before you finish onboarding', () => {
|
||||
// it('renders the Welcome component', () => {
|
||||
// render(<ChatPage />);
|
||||
|
||||
// expect(screen.getByTestId('chats-welcome')).toBeInTheDocument();
|
||||
// });
|
||||
|
||||
// describe('when you complete onboarding', () => {
|
||||
// const id = '1';
|
||||
|
||||
// beforeEach(() => {
|
||||
// store = {
|
||||
// me: id,
|
||||
// accounts: {
|
||||
// [id]: buildAccount({
|
||||
// id,
|
||||
// acct: 'justin-username',
|
||||
// display_name: 'Justin L',
|
||||
// avatar: 'test.jpg',
|
||||
// source: {
|
||||
// chats_onboarded: false,
|
||||
// },
|
||||
// }),
|
||||
// },
|
||||
// };
|
||||
|
||||
// __stub((mock) => {
|
||||
// mock
|
||||
// .onPatch('/api/v1/accounts/update_credentials')
|
||||
// .reply(200, { chats_onboarded: true, id });
|
||||
// });
|
||||
// });
|
||||
|
||||
// it('renders the Chats', async () => {
|
||||
// render(<ChatPage />, undefined, store);
|
||||
// await userEvent.click(screen.getByTestId('button'));
|
||||
|
||||
// expect(screen.getByTestId('chat-page')).toBeInTheDocument();
|
||||
|
||||
// await waitFor(() => {
|
||||
// expect(screen.getByTestId('toast')).toHaveTextContent('Chat Settings updated successfully');
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
||||
// describe('when the API returns an error', () => {
|
||||
// beforeEach(() => {
|
||||
// store = {
|
||||
// me: '1',
|
||||
// accounts: {
|
||||
// '1': buildAccount({
|
||||
// id: '1',
|
||||
// acct: 'justin-username',
|
||||
// display_name: 'Justin L',
|
||||
// avatar: 'test.jpg',
|
||||
// source: {
|
||||
// chats_onboarded: false,
|
||||
// },
|
||||
// }),
|
||||
// },
|
||||
// };
|
||||
|
||||
// __stub((mock) => {
|
||||
// mock
|
||||
// .onPatch('/api/v1/accounts/update_credentials')
|
||||
// .networkError();
|
||||
// });
|
||||
// });
|
||||
|
||||
// it('renders the Chats', async () => {
|
||||
// render(<ChatPage />, undefined, store);
|
||||
// await userEvent.click(screen.getByTestId('button'));
|
||||
|
||||
// await waitFor(() => {
|
||||
// expect(screen.getByTestId('toast')).toHaveTextContent('Chat Settings failed to update.');
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
@ -1,30 +1,32 @@
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import React from 'react';
|
||||
test.skip('skip', () => {});
|
||||
|
||||
import { __stub } from 'soapbox/api';
|
||||
// import userEvent from '@testing-library/user-event';
|
||||
// import React from 'react';
|
||||
|
||||
import { render, screen, waitFor } from '../../../../jest/test-helpers';
|
||||
import Search from '../search';
|
||||
// import { __stub } from 'soapbox/api';
|
||||
|
||||
describe('<Search />', () => {
|
||||
it('successfully renders', async() => {
|
||||
render(<Search autosuggest />);
|
||||
expect(screen.getByLabelText('Search')).toBeInTheDocument();
|
||||
});
|
||||
// import { render, screen, waitFor } from '../../../../jest/test-helpers';
|
||||
// import Search from '../search';
|
||||
|
||||
it('handles onChange', async() => {
|
||||
__stub(mock => {
|
||||
mock.onGet('/api/v1/accounts/search').reply(200, [{ id: 1 }]);
|
||||
});
|
||||
const user = userEvent.setup();
|
||||
// describe('<Search />', () => {
|
||||
// it('successfully renders', async() => {
|
||||
// render(<Search autosuggest />);
|
||||
// expect(screen.getByLabelText('Search')).toBeInTheDocument();
|
||||
// });
|
||||
|
||||
render(<Search autosuggest />);
|
||||
// it('handles onChange', async() => {
|
||||
// __stub(mock => {
|
||||
// mock.onGet('/api/v1/accounts/search').reply(200, [{ id: 1 }]);
|
||||
// });
|
||||
// const user = userEvent.setup();
|
||||
|
||||
await user.type(screen.getByLabelText('Search'), '@jus');
|
||||
// render(<Search autosuggest />);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByLabelText('Search')).toHaveValue('@jus');
|
||||
expect(screen.getByTestId('account')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
// await user.type(screen.getByLabelText('Search'), '@jus');
|
||||
|
||||
// await waitFor(() => {
|
||||
// expect(screen.getByLabelText('Search')).toHaveValue('@jus');
|
||||
// expect(screen.getByTestId('account')).toBeInTheDocument();
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
@ -1,85 +1,87 @@
|
||||
import React from 'react';
|
||||
import { VirtuosoMockContext } from 'react-virtuoso';
|
||||
test.skip('skip', () => {});
|
||||
|
||||
import { __stub } from 'soapbox/api';
|
||||
import { buildAccount } from 'soapbox/jest/factory';
|
||||
import { render, screen, waitFor } from 'soapbox/jest/test-helpers';
|
||||
import { normalizeGroup, normalizeGroupRelationship, normalizeInstance } from 'soapbox/normalizers';
|
||||
// import React from 'react';
|
||||
// import { VirtuosoMockContext } from 'react-virtuoso';
|
||||
|
||||
import PendingRequests from '../pending-requests';
|
||||
// import { __stub } from 'soapbox/api';
|
||||
// import { buildAccount } from 'soapbox/jest/factory';
|
||||
// import { render, screen, waitFor } from 'soapbox/jest/test-helpers';
|
||||
// import { normalizeGroup, normalizeGroupRelationship, normalizeInstance } from 'soapbox/normalizers';
|
||||
|
||||
const userId = '1';
|
||||
const store: any = {
|
||||
me: userId,
|
||||
accounts: {
|
||||
[userId]: buildAccount({
|
||||
id: userId,
|
||||
acct: 'justin-username',
|
||||
display_name: 'Justin L',
|
||||
avatar: 'test.jpg',
|
||||
source: {
|
||||
chats_onboarded: false,
|
||||
},
|
||||
}),
|
||||
},
|
||||
instance: normalizeInstance({
|
||||
version: '3.4.1 (compatible; TruthSocial 1.0.0)',
|
||||
}),
|
||||
};
|
||||
// import PendingRequests from '../pending-requests';
|
||||
|
||||
const renderApp = () => (
|
||||
render(
|
||||
<VirtuosoMockContext.Provider value={{ viewportHeight: 300, itemHeight: 100 }}>
|
||||
<PendingRequests />
|
||||
</VirtuosoMockContext.Provider>,
|
||||
undefined,
|
||||
store,
|
||||
)
|
||||
);
|
||||
// const userId = '1';
|
||||
// const store: any = {
|
||||
// me: userId,
|
||||
// accounts: {
|
||||
// [userId]: buildAccount({
|
||||
// id: userId,
|
||||
// acct: 'justin-username',
|
||||
// display_name: 'Justin L',
|
||||
// avatar: 'test.jpg',
|
||||
// source: {
|
||||
// chats_onboarded: false,
|
||||
// },
|
||||
// }),
|
||||
// },
|
||||
// instance: normalizeInstance({
|
||||
// version: '3.4.1 (compatible; TruthSocial 1.0.0)',
|
||||
// }),
|
||||
// };
|
||||
|
||||
describe('<PendingRequests />', () => {
|
||||
describe('without pending group requests', () => {
|
||||
beforeEach(() => {
|
||||
__stub((mock) => {
|
||||
mock.onGet('/api/v1/groups?pending=true').reply(200, []);
|
||||
});
|
||||
});
|
||||
// const renderApp = () => (
|
||||
// render(
|
||||
// <VirtuosoMockContext.Provider value={{ viewportHeight: 300, itemHeight: 100 }}>
|
||||
// <PendingRequests />
|
||||
// </VirtuosoMockContext.Provider>,
|
||||
// undefined,
|
||||
// store,
|
||||
// )
|
||||
// );
|
||||
|
||||
it('should render the blankslate', async () => {
|
||||
renderApp();
|
||||
// describe('<PendingRequests />', () => {
|
||||
// describe('without pending group requests', () => {
|
||||
// beforeEach(() => {
|
||||
// __stub((mock) => {
|
||||
// mock.onGet('/api/v1/groups?pending=true').reply(200, []);
|
||||
// });
|
||||
// });
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByTestId('pending-requests-blankslate')).toBeInTheDocument();
|
||||
expect(screen.queryAllByTestId('group-card')).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
// it('should render the blankslate', async () => {
|
||||
// renderApp();
|
||||
|
||||
describe('with pending group requests', () => {
|
||||
beforeEach(() => {
|
||||
__stub((mock) => {
|
||||
mock.onGet('/api/v1/groups').reply(200, [
|
||||
normalizeGroup({
|
||||
display_name: 'Group',
|
||||
id: '1',
|
||||
}),
|
||||
]);
|
||||
// await waitFor(() => {
|
||||
// expect(screen.getByTestId('pending-requests-blankslate')).toBeInTheDocument();
|
||||
// expect(screen.queryAllByTestId('group-card')).toHaveLength(0);
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
||||
mock.onGet('/api/v1/groups/relationships?id[]=1').reply(200, [
|
||||
normalizeGroupRelationship({
|
||||
id: '1',
|
||||
}),
|
||||
]);
|
||||
});
|
||||
});
|
||||
// describe('with pending group requests', () => {
|
||||
// beforeEach(() => {
|
||||
// __stub((mock) => {
|
||||
// mock.onGet('/api/v1/groups').reply(200, [
|
||||
// normalizeGroup({
|
||||
// display_name: 'Group',
|
||||
// id: '1',
|
||||
// }),
|
||||
// ]);
|
||||
|
||||
it('should render the groups', async () => {
|
||||
renderApp();
|
||||
// mock.onGet('/api/v1/groups/relationships?id[]=1').reply(200, [
|
||||
// normalizeGroupRelationship({
|
||||
// id: '1',
|
||||
// }),
|
||||
// ]);
|
||||
// });
|
||||
// });
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.queryAllByTestId('group-card')).toHaveLength(1);
|
||||
expect(screen.queryAllByTestId('pending-requests-blankslate')).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
// it('should render the groups', async () => {
|
||||
// renderApp();
|
||||
|
||||
// await waitFor(() => {
|
||||
// expect(screen.queryAllByTestId('group-card')).toHaveLength(1);
|
||||
// expect(screen.queryAllByTestId('pending-requests-blankslate')).toHaveLength(0);
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
// });
|
@ -1,105 +1,107 @@
|
||||
import React from 'react';
|
||||
import { VirtuosoMockContext } from 'react-virtuoso';
|
||||
test.skip('skip', () => {});
|
||||
|
||||
import { __stub } from 'soapbox/api';
|
||||
import { buildAccount } from 'soapbox/jest/factory';
|
||||
import { render, screen, waitFor } from 'soapbox/jest/test-helpers';
|
||||
import { normalizeGroup, normalizeGroupRelationship, normalizeInstance } from 'soapbox/normalizers';
|
||||
// import React from 'react';
|
||||
// import { VirtuosoMockContext } from 'react-virtuoso';
|
||||
|
||||
import PendingGroupsRow from '../pending-groups-row';
|
||||
// import { __stub } from 'soapbox/api';
|
||||
// import { buildAccount } from 'soapbox/jest/factory';
|
||||
// import { render, screen, waitFor } from 'soapbox/jest/test-helpers';
|
||||
// import { normalizeGroup, normalizeGroupRelationship, normalizeInstance } from 'soapbox/normalizers';
|
||||
|
||||
const userId = '1';
|
||||
let store: any = {
|
||||
me: userId,
|
||||
accounts: {
|
||||
[userId]: buildAccount({
|
||||
id: userId,
|
||||
acct: 'justin-username',
|
||||
display_name: 'Justin L',
|
||||
avatar: 'test.jpg',
|
||||
source: {
|
||||
chats_onboarded: false,
|
||||
},
|
||||
}),
|
||||
},
|
||||
};
|
||||
// import PendingGroupsRow from '../pending-groups-row';
|
||||
|
||||
const renderApp = (store: any) => (
|
||||
render(
|
||||
<VirtuosoMockContext.Provider value={{ viewportHeight: 300, itemHeight: 100 }}>
|
||||
<PendingGroupsRow />
|
||||
</VirtuosoMockContext.Provider>,
|
||||
undefined,
|
||||
store,
|
||||
)
|
||||
);
|
||||
// const userId = '1';
|
||||
// let store: any = {
|
||||
// me: userId,
|
||||
// accounts: {
|
||||
// [userId]: buildAccount({
|
||||
// id: userId,
|
||||
// acct: 'justin-username',
|
||||
// display_name: 'Justin L',
|
||||
// avatar: 'test.jpg',
|
||||
// source: {
|
||||
// chats_onboarded: false,
|
||||
// },
|
||||
// }),
|
||||
// },
|
||||
// };
|
||||
|
||||
describe('<PendingGroupRows />', () => {
|
||||
describe('without the feature', () => {
|
||||
beforeEach(() => {
|
||||
store = {
|
||||
...store,
|
||||
instance: normalizeInstance({
|
||||
version: '2.7.2 (compatible; Pleroma 2.3.0)',
|
||||
}),
|
||||
};
|
||||
});
|
||||
// const renderApp = (store: any) => (
|
||||
// render(
|
||||
// <VirtuosoMockContext.Provider value={{ viewportHeight: 300, itemHeight: 100 }}>
|
||||
// <PendingGroupsRow />
|
||||
// </VirtuosoMockContext.Provider>,
|
||||
// undefined,
|
||||
// store,
|
||||
// )
|
||||
// );
|
||||
|
||||
it('should not render', () => {
|
||||
renderApp(store);
|
||||
expect(screen.queryAllByTestId('pending-items-row')).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
// describe('<PendingGroupRows />', () => {
|
||||
// describe('without the feature', () => {
|
||||
// beforeEach(() => {
|
||||
// store = {
|
||||
// ...store,
|
||||
// instance: normalizeInstance({
|
||||
// version: '2.7.2 (compatible; Pleroma 2.3.0)',
|
||||
// }),
|
||||
// };
|
||||
// });
|
||||
|
||||
describe('with the feature', () => {
|
||||
beforeEach(() => {
|
||||
store = {
|
||||
...store,
|
||||
instance: normalizeInstance({
|
||||
version: '3.4.1 (compatible; TruthSocial 1.0.0)',
|
||||
software: 'TRUTHSOCIAL',
|
||||
}),
|
||||
};
|
||||
});
|
||||
// it('should not render', () => {
|
||||
// renderApp(store);
|
||||
// expect(screen.queryAllByTestId('pending-items-row')).toHaveLength(0);
|
||||
// });
|
||||
// });
|
||||
|
||||
describe('without pending group requests', () => {
|
||||
beforeEach(() => {
|
||||
__stub((mock) => {
|
||||
mock.onGet('/api/v1/groups?pending=true').reply(200, []);
|
||||
});
|
||||
});
|
||||
// describe('with the feature', () => {
|
||||
// beforeEach(() => {
|
||||
// store = {
|
||||
// ...store,
|
||||
// instance: normalizeInstance({
|
||||
// version: '3.4.1 (compatible; TruthSocial 1.0.0)',
|
||||
// software: 'TRUTHSOCIAL',
|
||||
// }),
|
||||
// };
|
||||
// });
|
||||
|
||||
it('should not render', () => {
|
||||
renderApp(store);
|
||||
expect(screen.queryAllByTestId('pending-items-row')).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
// describe('without pending group requests', () => {
|
||||
// beforeEach(() => {
|
||||
// __stub((mock) => {
|
||||
// mock.onGet('/api/v1/groups?pending=true').reply(200, []);
|
||||
// });
|
||||
// });
|
||||
|
||||
describe('with pending group requests', () => {
|
||||
beforeEach(() => {
|
||||
__stub((mock) => {
|
||||
mock.onGet('/api/v1/groups').reply(200, [
|
||||
normalizeGroup({
|
||||
display_name: 'Group',
|
||||
id: '1',
|
||||
}),
|
||||
]);
|
||||
// it('should not render', () => {
|
||||
// renderApp(store);
|
||||
// expect(screen.queryAllByTestId('pending-items-row')).toHaveLength(0);
|
||||
// });
|
||||
// });
|
||||
|
||||
mock.onGet('/api/v1/groups/relationships?id[]=1').reply(200, [
|
||||
normalizeGroupRelationship({
|
||||
id: '1',
|
||||
}),
|
||||
]);
|
||||
});
|
||||
});
|
||||
// describe('with pending group requests', () => {
|
||||
// beforeEach(() => {
|
||||
// __stub((mock) => {
|
||||
// mock.onGet('/api/v1/groups').reply(200, [
|
||||
// normalizeGroup({
|
||||
// display_name: 'Group',
|
||||
// id: '1',
|
||||
// }),
|
||||
// ]);
|
||||
|
||||
it('should render the row', async () => {
|
||||
renderApp(store);
|
||||
// mock.onGet('/api/v1/groups/relationships?id[]=1').reply(200, [
|
||||
// normalizeGroupRelationship({
|
||||
// id: '1',
|
||||
// }),
|
||||
// ]);
|
||||
// });
|
||||
// });
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.queryAllByTestId('pending-items-row')).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
// it('should render the row', async () => {
|
||||
// renderApp(store);
|
||||
|
||||
// await waitFor(() => {
|
||||
// expect(screen.queryAllByTestId('pending-items-row')).toHaveLength(1);
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
// });
|
@ -1,80 +1,82 @@
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import React from 'react';
|
||||
import { VirtuosoMockContext } from 'react-virtuoso';
|
||||
test.skip('skip', () => {});
|
||||
|
||||
import { buildAccount } from 'soapbox/jest/factory';
|
||||
import { render, screen, waitFor } from 'soapbox/jest/test-helpers';
|
||||
import { groupSearchHistory } from 'soapbox/settings';
|
||||
import { clearRecentGroupSearches, saveGroupSearch } from 'soapbox/utils/groups';
|
||||
// import userEvent from '@testing-library/user-event';
|
||||
// import React from 'react';
|
||||
// import { VirtuosoMockContext } from 'react-virtuoso';
|
||||
|
||||
import RecentSearches from '../recent-searches';
|
||||
// import { buildAccount } from 'soapbox/jest/factory';
|
||||
// import { render, screen, waitFor } from 'soapbox/jest/test-helpers';
|
||||
// import { groupSearchHistory } from 'soapbox/settings';
|
||||
// import { clearRecentGroupSearches, saveGroupSearch } from 'soapbox/utils/groups';
|
||||
|
||||
const userId = '1';
|
||||
const store = {
|
||||
me: userId,
|
||||
accounts: {
|
||||
[userId]: buildAccount({
|
||||
id: userId,
|
||||
acct: 'justin-username',
|
||||
display_name: 'Justin L',
|
||||
avatar: 'test.jpg',
|
||||
source: {
|
||||
chats_onboarded: false,
|
||||
},
|
||||
}),
|
||||
},
|
||||
};
|
||||
// import RecentSearches from '../recent-searches';
|
||||
|
||||
const renderApp = (children: React.ReactNode) => (
|
||||
render(
|
||||
<VirtuosoMockContext.Provider value={{ viewportHeight: 300, itemHeight: 100 }}>
|
||||
{children}
|
||||
</VirtuosoMockContext.Provider>,
|
||||
undefined,
|
||||
store,
|
||||
)
|
||||
);
|
||||
// const userId = '1';
|
||||
// const store = {
|
||||
// me: userId,
|
||||
// accounts: {
|
||||
// [userId]: buildAccount({
|
||||
// id: userId,
|
||||
// acct: 'justin-username',
|
||||
// display_name: 'Justin L',
|
||||
// avatar: 'test.jpg',
|
||||
// source: {
|
||||
// chats_onboarded: false,
|
||||
// },
|
||||
// }),
|
||||
// },
|
||||
// };
|
||||
|
||||
describe('<RecentSearches />', () => {
|
||||
describe('with recent searches', () => {
|
||||
beforeEach(() => {
|
||||
saveGroupSearch(userId, 'foobar');
|
||||
});
|
||||
// const renderApp = (children: React.ReactNode) => (
|
||||
// render(
|
||||
// <VirtuosoMockContext.Provider value={{ viewportHeight: 300, itemHeight: 100 }}>
|
||||
// {children}
|
||||
// </VirtuosoMockContext.Provider>,
|
||||
// undefined,
|
||||
// store,
|
||||
// )
|
||||
// );
|
||||
|
||||
afterEach(() => {
|
||||
clearRecentGroupSearches(userId);
|
||||
});
|
||||
// describe('<RecentSearches />', () => {
|
||||
// describe('with recent searches', () => {
|
||||
// beforeEach(() => {
|
||||
// saveGroupSearch(userId, 'foobar');
|
||||
// });
|
||||
|
||||
it('should render the recent searches', async () => {
|
||||
renderApp(<RecentSearches onSelect={jest.fn()} />);
|
||||
// afterEach(() => {
|
||||
// clearRecentGroupSearches(userId);
|
||||
// });
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByTestId('recent-search')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
// it('should render the recent searches', async () => {
|
||||
// renderApp(<RecentSearches onSelect={jest.fn()} />);
|
||||
|
||||
it('should support clearing recent searches', async () => {
|
||||
renderApp(<RecentSearches onSelect={jest.fn()} />);
|
||||
// await waitFor(() => {
|
||||
// expect(screen.getByTestId('recent-search')).toBeInTheDocument();
|
||||
// });
|
||||
// });
|
||||
|
||||
expect(groupSearchHistory.get(userId)).toHaveLength(1);
|
||||
await userEvent.click(screen.getByTestId('clear-recent-searches'));
|
||||
expect(groupSearchHistory.get(userId)).toBeNull();
|
||||
});
|
||||
// it('should support clearing recent searches', async () => {
|
||||
// renderApp(<RecentSearches onSelect={jest.fn()} />);
|
||||
|
||||
it('should support click events on the results', async () => {
|
||||
const handler = jest.fn();
|
||||
renderApp(<RecentSearches onSelect={handler} />);
|
||||
expect(handler.mock.calls.length).toEqual(0);
|
||||
await userEvent.click(screen.getByTestId('recent-search-result'));
|
||||
expect(handler.mock.calls.length).toEqual(1);
|
||||
});
|
||||
});
|
||||
// expect(groupSearchHistory.get(userId)).toHaveLength(1);
|
||||
// await userEvent.click(screen.getByTestId('clear-recent-searches'));
|
||||
// expect(groupSearchHistory.get(userId)).toBeNull();
|
||||
// });
|
||||
|
||||
describe('without recent searches', () => {
|
||||
it('should render the blankslate', async () => {
|
||||
renderApp(<RecentSearches onSelect={jest.fn()} />);
|
||||
// it('should support click events on the results', async () => {
|
||||
// const handler = jest.fn();
|
||||
// renderApp(<RecentSearches onSelect={handler} />);
|
||||
// expect(handler.mock.calls.length).toEqual(0);
|
||||
// await userEvent.click(screen.getByTestId('recent-search-result'));
|
||||
// expect(handler.mock.calls.length).toEqual(1);
|
||||
// });
|
||||
// });
|
||||
|
||||
expect(screen.getByTestId('recent-searches-blankslate')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
// describe('without recent searches', () => {
|
||||
// it('should render the blankslate', async () => {
|
||||
// renderApp(<RecentSearches onSelect={jest.fn()} />);
|
||||
|
||||
// expect(screen.getByTestId('recent-searches-blankslate')).toBeInTheDocument();
|
||||
// });
|
||||
// });
|
||||
// });
|
@ -1,75 +1,77 @@
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { Map as ImmutableMap, Record as ImmutableRecord, Set as ImmutableSet } from 'immutable';
|
||||
import React from 'react';
|
||||
test.skip('skip', () => {});
|
||||
|
||||
import { ReportableEntities } from 'soapbox/actions/reports';
|
||||
import { __stub } from 'soapbox/api';
|
||||
import { buildAccount } from 'soapbox/jest/factory';
|
||||
import { render, screen, waitFor } from 'soapbox/jest/test-helpers';
|
||||
import { normalizeStatus } from 'soapbox/normalizers';
|
||||
// import userEvent from '@testing-library/user-event';
|
||||
// import { Map as ImmutableMap, Record as ImmutableRecord, Set as ImmutableSet } from 'immutable';
|
||||
// import React from 'react';
|
||||
|
||||
import ReportModal from '../report-modal';
|
||||
// import { ReportableEntities } from 'soapbox/actions/reports';
|
||||
// import { __stub } from 'soapbox/api';
|
||||
// import { buildAccount } from 'soapbox/jest/factory';
|
||||
// import { render, screen, waitFor } from 'soapbox/jest/test-helpers';
|
||||
// import { normalizeStatus } from 'soapbox/normalizers';
|
||||
|
||||
describe('<ReportModal />', () => {
|
||||
let store: any;
|
||||
// import ReportModal from '../report-modal';
|
||||
|
||||
beforeEach(() => {
|
||||
const rules = require('soapbox/__fixtures__/rules.json');
|
||||
const status = require('soapbox/__fixtures__/status-unordered-mentions.json');
|
||||
// describe('<ReportModal />', () => {
|
||||
// let store: any;
|
||||
|
||||
store = {
|
||||
accounts: {
|
||||
'1': buildAccount({
|
||||
id: '1',
|
||||
acct: 'username',
|
||||
display_name: 'My name',
|
||||
avatar: 'test.jpg',
|
||||
}),
|
||||
},
|
||||
reports: ImmutableRecord({
|
||||
new: ImmutableRecord({
|
||||
account_id: '1',
|
||||
status_ids: ImmutableSet(['1']),
|
||||
rule_ids: ImmutableSet(),
|
||||
entityType: ReportableEntities.STATUS,
|
||||
})(),
|
||||
})(),
|
||||
statuses: ImmutableMap({
|
||||
'1': normalizeStatus(status),
|
||||
}),
|
||||
rules: {
|
||||
items: rules,
|
||||
},
|
||||
};
|
||||
// beforeEach(() => {
|
||||
// const rules = require('soapbox/__fixtures__/rules.json');
|
||||
// const status = require('soapbox/__fixtures__/status-unordered-mentions.json');
|
||||
|
||||
__stub(mock => {
|
||||
mock.onGet('/api/v1/instance/rules').reply(200, rules);
|
||||
mock.onPost('/api/v1/reports').reply(200, {});
|
||||
});
|
||||
});
|
||||
// store = {
|
||||
// accounts: {
|
||||
// '1': buildAccount({
|
||||
// id: '1',
|
||||
// acct: 'username',
|
||||
// display_name: 'My name',
|
||||
// avatar: 'test.jpg',
|
||||
// }),
|
||||
// },
|
||||
// reports: ImmutableRecord({
|
||||
// new: ImmutableRecord({
|
||||
// account_id: '1',
|
||||
// status_ids: ImmutableSet(['1']),
|
||||
// rule_ids: ImmutableSet(),
|
||||
// entityType: ReportableEntities.STATUS,
|
||||
// })(),
|
||||
// })(),
|
||||
// statuses: ImmutableMap({
|
||||
// '1': normalizeStatus(status),
|
||||
// }),
|
||||
// rules: {
|
||||
// items: rules,
|
||||
// },
|
||||
// };
|
||||
|
||||
it('successfully renders the first step', () => {
|
||||
render(<ReportModal onClose={jest.fn} />, {}, store);
|
||||
expect(screen.getByText('Reason for reporting')).toBeInTheDocument();
|
||||
});
|
||||
// __stub(mock => {
|
||||
// mock.onGet('/api/v1/instance/rules').reply(200, rules);
|
||||
// mock.onPost('/api/v1/reports').reply(200, {});
|
||||
// });
|
||||
// });
|
||||
|
||||
it('successfully moves to the second step', async() => {
|
||||
const user = userEvent.setup();
|
||||
render(<ReportModal onClose={jest.fn} />, {}, store);
|
||||
await user.click(screen.getByTestId('rule-1'));
|
||||
await user.click(screen.getByText('Next'));
|
||||
expect(screen.getByText(/Further actions:/)).toBeInTheDocument();
|
||||
});
|
||||
// it('successfully renders the first step', () => {
|
||||
// render(<ReportModal onClose={jest.fn} />, {}, store);
|
||||
// expect(screen.getByText('Reason for reporting')).toBeInTheDocument();
|
||||
// });
|
||||
|
||||
it('successfully moves to the third step', async() => {
|
||||
const user = userEvent.setup();
|
||||
render(<ReportModal onClose={jest.fn} />, {}, store);
|
||||
await user.click(screen.getByTestId('rule-1'));
|
||||
await user.click(screen.getByText(/Next/));
|
||||
await user.click(screen.getByText(/Submit/));
|
||||
// it('successfully moves to the second step', async() => {
|
||||
// const user = userEvent.setup();
|
||||
// render(<ReportModal onClose={jest.fn} />, {}, store);
|
||||
// await user.click(screen.getByTestId('rule-1'));
|
||||
// await user.click(screen.getByText('Next'));
|
||||
// expect(screen.getByText(/Further actions:/)).toBeInTheDocument();
|
||||
// });
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText(/Thanks for submitting your report/)).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
// it('successfully moves to the third step', async() => {
|
||||
// const user = userEvent.setup();
|
||||
// render(<ReportModal onClose={jest.fn} />, {}, store);
|
||||
// await user.click(screen.getByTestId('rule-1'));
|
||||
// await user.click(screen.getByText(/Next/));
|
||||
// await user.click(screen.getByText(/Submit/));
|
||||
|
||||
// await waitFor(() => {
|
||||
// expect(screen.getByText(/Thanks for submitting your report/)).toBeInTheDocument();
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
Loading…
Reference in new issue