Skip to content

Commit 31073a3

Browse files
committed
MQE-1644: Add ability to see JS log in Allure
- Unit test + static check fixes
1 parent dc0bf75 commit 31073a3

File tree

2 files changed

+78
-2
lines changed

2 files changed

+78
-2
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace tests\unit\Magento\FunctionalTestFramework\Extension;
8+
9+
use Magento\FunctionalTestingFramework\Util\MagentoTestCase;
10+
use Magento\FunctionalTestingFramework\Extension\BrowserLogUtil;
11+
12+
class BrowserLogUtilTest extends MagentoTestCase
13+
{
14+
public function testGetLogsOfType()
15+
{
16+
$entryOne = [
17+
"level" => "WARNING",
18+
"message" => "warningMessage",
19+
"source" => "console-api",
20+
"timestamp" => 1234567890
21+
];
22+
$entryTwo = [
23+
"level" => "ERROR",
24+
"message" => "errorMessage",
25+
"source" => "other",
26+
"timestamp" => 1234567890
27+
];
28+
$entryThree = [
29+
"level" => "LOG",
30+
"message" => "logMessage",
31+
"source" => "javascript",
32+
"timestamp" => 1234567890
33+
];
34+
$log = [
35+
$entryOne,
36+
$entryTwo,
37+
$entryThree
38+
];
39+
40+
$actual = BrowserLogUtil::getLogsOfType($log, 'console-api');
41+
42+
self::assertEquals($entryOne, $actual[0]);
43+
}
44+
45+
public function testFilterLogsOfType()
46+
{
47+
$entryOne = [
48+
"level" => "WARNING",
49+
"message" => "warningMessage",
50+
"source" => "console-api",
51+
"timestamp" => 1234567890
52+
];
53+
$entryTwo = [
54+
"level" => "ERROR",
55+
"message" => "errorMessage",
56+
"source" => "other",
57+
"timestamp" => 1234567890
58+
];
59+
$entryThree = [
60+
"level" => "LOG",
61+
"message" => "logMessage",
62+
"source" => "javascript",
63+
"timestamp" => 1234567890
64+
];
65+
$log = [
66+
$entryOne,
67+
$entryTwo,
68+
$entryThree
69+
];
70+
71+
$actual = BrowserLogUtil::filterLogsOfType($log, 'console-api');
72+
73+
self::assertEquals($entryTwo, $actual[0]);
74+
self::assertEquals($entryThree, $actual[1]);
75+
}
76+
}

src/Magento/FunctionalTestingFramework/Extension/BrowserLogUtil.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public static function logErrors($module, $stepEvent)
3939
/**
4040
* Loops through given log and returns entries of the given type.
4141
*
42-
* @param array $log
42+
* @param array $log
4343
* @param string $type
4444
* @return array
4545
*/
@@ -57,7 +57,7 @@ public static function getLogsOfType($log, $type)
5757
/**
5858
* Loops through given log and filters entries of the given type.
5959
*
60-
* @param array $log
60+
* @param array $log
6161
* @param string $type
6262
* @return array
6363
*/

0 commit comments

Comments
 (0)