1- import { getLogType } from "../../components/dashboard/docker/logs/utils" ;
21import { describe , expect , test } from "vitest" ;
2+ import { getLogType } from "../../components/dashboard/docker/logs/utils" ;
33
44describe ( "getLogType" , ( ) => {
55 describe ( "Structured error patterns" , ( ) => {
66 test ( "should detect [ERROR] format" , ( ) => {
7- expect ( getLogType ( "[ERROR] Database connection failed" ) . type ) . toBe ( "error" ) ;
7+ expect ( getLogType ( "[ERROR] Database connection failed" ) . type ) . toBe (
8+ "error" ,
9+ ) ;
810 } ) ;
911
1012 test ( "should detect ERROR: format" , ( ) => {
1113 expect ( getLogType ( "ERROR: Connection refused" ) . type ) . toBe ( "error" ) ;
1214 } ) ;
1315
1416 test ( "should detect level=error format" , ( ) => {
15- expect ( getLogType ( 'level=error msg="Database connection failed"' ) . type ) . toBe ( "error" ) ;
17+ expect (
18+ getLogType ( 'level=error msg="Database connection failed"' ) . type ,
19+ ) . toBe ( "error" ) ;
1620 } ) ;
1721
1822 test ( "should detect error emojis" , ( ) => {
@@ -31,7 +35,9 @@ describe("getLogType", () => {
3135 } ) ;
3236
3337 test ( "should detect 'X failed with' patterns" , ( ) => {
34- expect ( getLogType ( "Token exchange failed with status: 400" ) . type ) . toBe ( "error" ) ;
38+ expect ( getLogType ( "Token exchange failed with status: 400" ) . type ) . toBe (
39+ "error" ,
40+ ) ;
3541 } ) ;
3642
3743 test ( "should detect HTTP error codes" , ( ) => {
@@ -40,18 +46,24 @@ describe("getLogType", () => {
4046 } ) ;
4147
4248 test ( "should detect stack trace lines" , ( ) => {
43- expect ( getLogType ( " at Object.<anonymous> (/app/server.js:123:45)" ) . type ) . toBe ( "error" ) ;
49+ expect (
50+ getLogType ( " at Object.<anonymous> (/app/server.js:123:45)" ) . type ,
51+ ) . toBe ( "error" ) ;
4452 } ) ;
4553 } ) ;
4654
4755 describe ( "False positives - should NOT be detected as errors" , ( ) => {
4856 test ( "should not flag 'Failed=0' as error" , ( ) => {
49- const result = getLogType ( 'time="2025-11-20T08:19:13Z" level=info msg="Session done" Failed=0 Scanned=1' ) ;
57+ const result = getLogType (
58+ 'time="2025-11-20T08:19:13Z" level=info msg="Session done" Failed=0 Scanned=1' ,
59+ ) ;
5060 expect ( result . type ) . toBe ( "info" ) ;
5161 } ) ;
5262
5363 test ( "should not flag '0 failed' as error" , ( ) => {
54- expect ( getLogType ( "0 practices builds failed, and 0 uploads failed." ) . type ) . toBe ( "info" ) ;
64+ expect (
65+ getLogType ( "0 practices builds failed, and 0 uploads failed." ) . type ,
66+ ) . toBe ( "info" ) ;
5567 } ) ;
5668
5769 test ( "should not flag negative contexts as error" , ( ) => {
@@ -65,15 +77,19 @@ describe("getLogType", () => {
6577
6678 describe ( "Warning patterns" , ( ) => {
6779 test ( "should detect [WARN] format" , ( ) => {
68- expect ( getLogType ( "[WARN] API rate limit approaching" ) . type ) . toBe ( "warning" ) ;
80+ expect ( getLogType ( "[WARN] API rate limit approaching" ) . type ) . toBe (
81+ "warning" ,
82+ ) ;
6983 } ) ;
7084
7185 test ( "should detect WARNING: format" , ( ) => {
7286 expect ( getLogType ( "WARNING: Disk space low" ) . type ) . toBe ( "warning" ) ;
7387 } ) ;
7488
7589 test ( "should detect warning emojis" , ( ) => {
76- expect ( getLogType ( "⚠️ Token exchange failed with status: 400 Bad Request" ) . type ) . not . toBe ( "info" ) ;
90+ expect (
91+ getLogType ( "⚠️ Token exchange failed with status: 400 Bad Request" ) . type ,
92+ ) . not . toBe ( "info" ) ;
7793 } ) ;
7894
7995 test ( "should detect deprecated warnings" , ( ) => {
@@ -91,7 +107,9 @@ describe("getLogType", () => {
91107 } ) ;
92108
93109 test ( "should detect 'successfully' patterns" , ( ) => {
94- expect ( getLogType ( "Successfully connected to database" ) . type ) . toBe ( "success" ) ;
110+ expect ( getLogType ( "Successfully connected to database" ) . type ) . toBe (
111+ "success" ,
112+ ) ;
95113 } ) ;
96114
97115 test ( "should detect success emojis" , ( ) => {
0 commit comments