Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep last results until test result finishes #7

Merged
merged 3 commits into from
May 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 7 additions & 1 deletion server/api/workspace/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,13 @@ export default class WorkspaceResolver {
): Promise<TestFileResult> {
const payload = event.payload;
const result = new TestFileResult();
if (event.id === Events.TEST_RESULT) {
if (event.id === Events.TEST_START) {
const existingResults = this.results.getResult(path);
if (existingResults) {
result.testResults = existingResults.testResults;
}
}
else if (event.id === Events.TEST_RESULT) {
result.path = path;
result.failureMessage = payload.failureMessage;
result.numPassingTests = payload.numPassingTests;
Expand Down
2 changes: 1 addition & 1 deletion server/api/workspace/test-result/file-result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class TestFileResult {
failureMessage: string;

@Field(returns => TestItemResult, { nullable: true })
testResults: TestItemResult[];
testResults: TestItemResult[] | null;

@Field(returns => ConsoleLog, { nullable: true })
consoleLogs: ConsoleLog[];
Expand Down
6 changes: 2 additions & 4 deletions server/services/results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ export interface CoverageSummary {
export default class Results {
private projectRoot: string = "";
private results: {
[path: string]: {
report?: any;
};
[path: string]: TestFileResult;
} = {};

private testStatus: {
Expand Down Expand Up @@ -102,7 +100,7 @@ export default class Results {
}
}

public getResult(path: string) {
public getResult(path: string): TestFileResult | null {
return this.results[path] || null;
}

Expand Down
6 changes: 5 additions & 1 deletion ui/test-file/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ const Container = styled.div<any>`
const Content = styled.div`
overflow: auto;
height: calc(100vh - 118px);

${({ dim }: any) => dim && `
opacity: .5;
`}
`;

const TestItemsContainer = styled.div`
Expand Down Expand Up @@ -127,7 +131,7 @@ function TestFile({ selectedFilePath, isRunning, projectRoot, onStop }: Props) {
updateSnapshot();
}}
/>
<Content>
<Content dim={isUpdating}>
{result && result.testResults && result.testResults.length === 0 && (
<ErrorPanel failureMessage={result && result.failureMessage} />
)}
Expand Down