@@ -39,13 +39,14 @@ export const extract_csa: EvalFunction = async ({
39
39
await stagehand . close ( ) ;
40
40
41
41
const publications = result . publications ;
42
- const expectedLength = 15 ;
42
+ const expectedLength = 14 ;
43
43
44
44
const expectedFirstItem = {
45
- publication_date : "01-09-2025 " ,
45
+ publication_date : "11-30-2024 " ,
46
46
session_type : "Regular Session" ,
47
47
publication_type : "Assembly Weekly History" ,
48
- annotation : "" ,
48
+ annotation :
49
+ "2024 -- This publication includes the complete histories of second-year bills. The complete electronic history of all bills is always available at leginfo.legislature.ca.gov" ,
49
50
} ;
50
51
51
52
const expectedLastItem = {
@@ -55,13 +56,13 @@ export const extract_csa: EvalFunction = async ({
55
56
annotation : "" ,
56
57
} ;
57
58
58
- if ( publications . length !== expectedLength ) {
59
+ if ( publications . length < expectedLength ) {
59
60
logger . error ( {
60
61
message : "Incorrect number of publications extracted" ,
61
62
level : 0 ,
62
63
auxiliary : {
63
64
expected : {
64
- value : expectedLength . toString ( ) ,
65
+ value : `>= ${ expectedLength } ` ,
65
66
type : "integer" ,
66
67
} ,
67
68
actual : {
@@ -78,64 +79,67 @@ export const extract_csa: EvalFunction = async ({
78
79
sessionUrl,
79
80
} ;
80
81
}
81
- const firstItemMatches =
82
- publications [ 0 ] . publication_date === expectedFirstItem . publication_date &&
83
- publications [ 0 ] . session_type === expectedFirstItem . session_type &&
84
- publications [ 0 ] . publication_type === expectedFirstItem . publication_type &&
85
- publications [ 0 ] . annotation === expectedFirstItem . annotation ;
86
82
87
- if ( ! firstItemMatches ) {
83
+ const hasExpectedFirstItem = publications . some ( ( publication ) => {
84
+ return (
85
+ publication . publication_date === expectedFirstItem . publication_date &&
86
+ publication . session_type === expectedFirstItem . session_type &&
87
+ publication . publication_type === expectedFirstItem . publication_type &&
88
+ publication . annotation === expectedFirstItem . annotation
89
+ ) ;
90
+ } ) ;
91
+
92
+ if ( ! hasExpectedFirstItem ) {
88
93
logger . error ( {
89
- message : "First publication extracted does not match expected " ,
94
+ message : "Expected 'first' item not found in publications " ,
90
95
level : 0 ,
91
96
auxiliary : {
92
97
expected : {
93
98
value : JSON . stringify ( expectedFirstItem ) ,
94
99
type : "object" ,
95
100
} ,
96
101
actual : {
97
- value : JSON . stringify ( publications [ 0 ] ) ,
102
+ value : JSON . stringify ( publications ) ,
98
103
type : "object" ,
99
104
} ,
100
105
} ,
101
106
} ) ;
102
107
return {
103
108
_success : false ,
104
- error : "First publication extracted does not match expected " ,
109
+ error : "Expected 'first' item not found in publications " ,
105
110
logs : logger . getLogs ( ) ,
106
111
debugUrl,
107
112
sessionUrl,
108
113
} ;
109
114
}
110
115
111
- const lastItemMatches =
112
- publications [ publications . length - 1 ] . publication_date ===
113
- expectedLastItem . publication_date &&
114
- publications [ publications . length - 1 ] . session_type ===
115
- expectedLastItem . session_type &&
116
- publications [ publications . length - 1 ] . publication_type ===
117
- expectedLastItem . publication_type &&
118
- publications [ publications . length - 1 ] . annotation ===
119
- expectedLastItem . annotation ;
116
+ const hasExpectedLastItem = publications . some ( ( publication ) => {
117
+ return (
118
+ publication . publication_date === expectedLastItem . publication_date &&
119
+ publication . session_type === expectedLastItem . session_type &&
120
+ publication . publication_type === expectedLastItem . publication_type &&
121
+ publication . annotation === expectedLastItem . annotation
122
+ ) ;
123
+ } ) ;
120
124
121
- if ( ! lastItemMatches ) {
125
+ if ( ! hasExpectedLastItem ) {
122
126
logger . error ( {
123
- message : "Last publication extracted does not match expected " ,
127
+ message : "Expected 'last' item not found in publications " ,
124
128
level : 0 ,
125
129
auxiliary : {
126
130
expected : {
127
131
value : JSON . stringify ( expectedLastItem ) ,
128
132
type : "object" ,
129
133
} ,
130
134
actual : {
131
- value : JSON . stringify ( publications [ publications . length - 1 ] ) ,
135
+ value : JSON . stringify ( publications ) ,
132
136
type : "object" ,
133
137
} ,
134
138
} ,
135
139
} ) ;
136
140
return {
137
141
_success : false ,
138
- error : "Last publication extracted does not match expected " ,
142
+ error : "Expected 'last' item not found in publications " ,
139
143
logs : logger . getLogs ( ) ,
140
144
debugUrl,
141
145
sessionUrl,
0 commit comments