Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ export class DebuggerEffects {
return (
runId !== null &&
fileContent !== null &&
fileContent.loadState !== DataLoadState.LOADING
fileContent.loadState === DataLoadState.NOT_LOADED
);
}),
tap(({lineSpec}) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,50 @@ describe('Debugger effects', () => {
]);
});

for (const loadState of [DataLoadState.LOADED, DataLoadState.LOADING]) {
it('skips loading a loaded or loeading source file', () => {
Copy link
Contributor

@psybuzz psybuzz Mar 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use a test spec title that varies depending on the loadstate. That way, one can read the Karma test results and know which one failed. e.g. perhaps something like

for (const spec of [{loadState: DataLoadState.Loaded, name: 'loaded'}, ...]) {
  it(`skips loading a source file that is ${spec.name}`, () => {
    // ... use spec.loadState
  });
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! Thanks for catching it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

const runId = '__default_debugger_run__';
const fileIndex = 2;
const fileContentC: SourceFileResponse = {
...fileSpecC,
lines: [''],
};
const fetchSourceFileSpy = createFetchSourceFileSpy(
runId,
fileIndex,
fileContentC.host_name,
fileContentC.file_path,
fileContentC.lines
);
store.overrideSelector(getActiveRunId, runId);
store.overrideSelector(getSourceFileList, [
fileSpecA,
fileSpecB,
fileSpecC,
]);
store.overrideSelector(getFocusedSourceFileIndex, fileIndex);
store.overrideSelector(getFocusedSourceFileContent, {
loadState,
lines: null,
});
store.refreshState();

action.next(
sourceLineFocused({
sourceLineSpec: {
...fileSpecC,
lineno: 42,
},
})
);

// Due to the LOADED or LOADING state of the file, no request should
// have been made for the content of the file.
expect(fetchSourceFileSpy).not.toHaveBeenCalled();
expect(dispatchedActions).toEqual([]);
});
}

it('does not load a file being loaded', () => {
const runId = '__default_debugger_run__';
const fileIndex = 2;
Expand Down