optimizeSelectedIssue
} from '../../../components/SourceViewer/helpers/lines';
import { translate } from '../../../helpers/l10n';
+import { getBranchLikeQuery } from '../../../helpers/branches';
interface Props {
branchLike: T.BranchLike | undefined;
}
expandBlock = (snippetIndex: number, direction: T.ExpandDirection) => {
+ const { branchLike, snippetGroup } = this.props;
+ const { key } = snippetGroup.component;
const { snippets } = this.state;
const snippet = snippets[snippetIndex];
};
getSources({
- key: this.props.snippetGroup.component.key,
- ...range
+ key,
+ ...range,
+ ...getBranchLikeQuery(branchLike)
})
.then(lines =>
lines.reduce((lineMap: T.Dict<T.SourceLine>, line) => {
};
expandComponent = () => {
- const { key } = this.props.snippetGroup.component;
+ const { branchLike, snippetGroup } = this.props;
+ const { key } = snippetGroup.component;
this.setState({ loading: true });
- getSources({ key }).then(
+ getSources({ key, ...getBranchLikeQuery(branchLike) }).then(
lines => {
if (this.mounted) {
this.setState({ loading: false, snippets: [lines] });
mockSourceViewerFile,
mockFlowLocation,
mockSnippetsByComponent,
- mockSourceLine
+ mockSourceLine,
+ mockShortLivingBranch
} from '../../../../helpers/testMocks';
import { waitAndUpdate } from '../../../../helpers/testUtils';
import { getSources } from '../../../../api/components';
expect(wrapper.state('snippets')[0]).toHaveLength(14);
});
+it.only('should get the right branch when expanding', async () => {
+ (getSources as jest.Mock).mockResolvedValueOnce(
+ Object.values(
+ mockSnippetsByComponent('a', [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]).sources
+ )
+ );
+ const snippetGroup: T.SnippetGroup = {
+ locations: [mockFlowLocation()],
+ ...mockSnippetsByComponent('a', [1, 2, 3, 4])
+ };
+
+ const wrapper = shallowRender({
+ branchLike: mockShortLivingBranch({ name: 'asdf' }),
+ snippetGroup
+ });
+
+ wrapper.instance().expandBlock(0, 'down');
+ await waitAndUpdate(wrapper);
+
+ expect(getSources).toHaveBeenCalledWith({ branch: 'asdf', from: 5, key: 'a', to: 17 });
+});
+
it('should handle correctly open/close issue', () => {
const wrapper = shallowRender();
const sourceLine = mockSourceLine();