Skip to content

Commit

Permalink
Only store different error message on recording bug
Browse files Browse the repository at this point in the history
  • Loading branch information
tienvx committed Apr 16, 2022
1 parent 76802f8 commit 2b7e054
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/Service/Bug/BugHelper.php
Expand Up @@ -96,7 +96,9 @@ public function recordVideo(int $bugId): void
$this->bugRepository->startRecording($bug);
$bug->setDebug(true);
$this->stepsRunner->run($bug->getSteps(), $bug, function (Throwable $throwable) use ($bug) {
$bug->getVideo()->setErrorMessage($throwable->getMessage());
$bug->getVideo()->setErrorMessage(
$throwable->getMessage() !== $bug->getMessage() ? $throwable->getMessage() : null
);
});
$this->bugRepository->stopRecording($bug);
}
Expand Down
4 changes: 3 additions & 1 deletion tests/Service/Bug/BugHelperTest.php
Expand Up @@ -72,6 +72,7 @@ protected function setUp(): void
$this->progress->setProcessed(9);
$this->bug = new Bug();
$this->bug->setProgress($this->progress);
$this->bug->setMessage('Something wrong');
$this->bug->setId(123);
$this->bug->setSteps([
$this->createMock(StepInterface::class),
Expand Down Expand Up @@ -257,7 +258,7 @@ public function testRecordVideo(?Throwable $exception): void
$this->bugRepository->expects($this->once())->method('stopRecording')->with($this->bug);
$this->helper->recordVideo(123);
$this->assertTrue($this->bug->isDebug());
if ($exception) {
if ($exception && $exception->getMessage() !== $this->bug->getMessage()) {
$this->assertSame($exception->getMessage(), $this->bug->getVideo()->getErrorMessage());
} else {
$this->assertNull($this->bug->getVideo()->getErrorMessage());
Expand All @@ -269,6 +270,7 @@ public function exceptionProvider(): array
return [
[null],
[new Exception('Something wrong')],
[new Exception('Something else wrong')],
];
}
}

0 comments on commit 2b7e054

Please sign in to comment.