25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

502 satır
21KB

  1. <!--#include file="../App/ViewModels/KitViewModels.asp"-->
  2. <!--#include file="../App/DAL/lib.DAL.asp"-->
  3. <!--#include file="../App/DomainModels/JurisdictionRepository.asp"-->
  4. <!--#include file="../App/DomainModels/KitRepository.asp"-->
  5. <!--#include file="../App/DomainModels/InkjetRecordsRepository.asp"-->
  6. <!--#include file="../App/DomainModels/PurpleEnvelopeReportHelper.asp"-->
  7. <%
  8. Class PurpleEnvelopeReport_Tests
  9. Private m_tempDbPath
  10. Public Sub Setup
  11. m_tempDbPath = CreateDisposableDatabaseCopy()
  12. UseDisposableDatabase m_tempDbPath
  13. EnsureDeliveryLabelPageTable
  14. End Sub
  15. Public Sub Teardown
  16. ResetDisposableDatabase
  17. End Sub
  18. Public Function TestCaseNames
  19. TestCaseNames = Array( _
  20. "Test_FormatElectionLabel_Returns_Mon_YYYY_For_Valid_Date", _
  21. "Test_FormatElectionLabel_Returns_Trimmed_Raw_Value_For_Invalid_Date", _
  22. "Test_SortPrecinctColorRows_Handles_Zero_Padded_And_Lettered_Precincts", _
  23. "Test_SortPrecinctBallotRangeRows_Preserves_Ranges_While_Sorting", _
  24. "Test_GetPrecinctBallotRangesByKitId_Uses_Seeded_Data", _
  25. "Test_UpdateColorForKit_Updates_All_Seeded_Rows_For_The_Target_Kit", _
  26. "Test_UpdateColorForPrecinct_Updates_Only_The_Targeted_Precinct", _
  27. "Test_SwitchBoardPurpleEnvelopeEditFindById_Returns_Seeded_Header_Data", _
  28. "Test_SaveDeliveryLabelPages_Persists_Seeded_Page_Data", _
  29. "Test_SaveDeliveryLabelPages_Replaces_Existing_Pages_For_The_Kit", _
  30. "Test_DeleteDeliveryLabelPages_Removes_All_Staged_Pages_For_The_Kit", _
  31. "Test_KitController_Post_Actions_Still_Delegate_To_Color_Update_Repositories", _
  32. "Test_Report_View_Keeps_Print_Only_CSS_Contract", _
  33. "Test_Report_View_Keeps_No_Data_Row_And_Page_Spacer", _
  34. "Test_Report_View_Only_Shows_Delivery_Paperwork_Link_When_Kit_Is_Done", _
  35. "Test_KitController_Declares_PrintDeliveryPaperwork_Action" _
  36. )
  37. End Function
  38. Private Sub Destroy(ByRef o)
  39. On Error Resume Next
  40. o.Close
  41. On Error GoTo 0
  42. Set o = Nothing
  43. End Sub
  44. Private Function CreatePrecinctColorRecordset(ByVal rows)
  45. dim rs : set rs = Server.CreateObject("ADODB.Recordset")
  46. With rs.Fields
  47. .Append "PRECINCT", adVarChar, 50
  48. .Append "ColorId", adVarChar, 50
  49. End With
  50. rs.Open
  51. dim i
  52. For i = 0 To UBound(rows)
  53. rs.AddNew
  54. rs("PRECINCT") = rows(i)(0)
  55. If IsNull(rows(i)(1)) Then
  56. rs("ColorId") = Null
  57. Else
  58. rs("ColorId") = rows(i)(1)
  59. End If
  60. rs.Update
  61. Next
  62. rs.MoveFirst
  63. set CreatePrecinctColorRecordset = rs
  64. End Function
  65. Private Function CreateBallotRangeRecordset(ByVal rows)
  66. dim rs : set rs = Server.CreateObject("ADODB.Recordset")
  67. With rs.Fields
  68. .Append "PRECINCT", adVarChar, 50
  69. .Append "LowBallotNumber", adInteger
  70. .Append "HighBallotNumber", adInteger
  71. End With
  72. rs.Open
  73. dim i
  74. For i = 0 To UBound(rows)
  75. rs.AddNew
  76. rs("PRECINCT") = rows(i)(0)
  77. rs("LowBallotNumber") = rows(i)(1)
  78. rs("HighBallotNumber") = rows(i)(2)
  79. rs.Update
  80. Next
  81. rs.MoveFirst
  82. set CreateBallotRangeRecordset = rs
  83. End Function
  84. Private Function PrecinctListToCsv(ByVal list)
  85. dim values()
  86. dim idx : idx = -1
  87. dim it : set it = list.Iterator()
  88. dim row
  89. Do While it.HasNext
  90. set row = it.GetNext()
  91. idx = idx + 1
  92. ReDim Preserve values(idx)
  93. values(idx) = row.PRECINCT
  94. Loop
  95. If idx = -1 Then
  96. PrecinctListToCsv = ""
  97. Else
  98. PrecinctListToCsv = Join(values, ",")
  99. End If
  100. End Function
  101. Private Function ReadAllText(ByVal relativePath)
  102. dim fso : set fso = Server.CreateObject("Scripting.FileSystemObject")
  103. dim fileHandle : set fileHandle = fso.OpenTextFile(Server.MapPath(relativePath), 1, False)
  104. ReadAllText = fileHandle.ReadAll()
  105. fileHandle.Close
  106. Set fileHandle = Nothing
  107. Set fso = Nothing
  108. End Function
  109. Private Function CreateDisposableDatabaseCopy()
  110. dim fso : set fso = Server.CreateObject("Scripting.FileSystemObject")
  111. dim tempFolderPath : tempFolderPath = Server.MapPath("Temp")
  112. If Not fso.FolderExists(tempFolderPath) Then
  113. fso.CreateFolder tempFolderPath
  114. End If
  115. dim sourcePath : sourcePath = Server.MapPath("../Data/webdata - Copy.mdb")
  116. dim guidValue : guidValue = Mid(CreateObject("Scriptlet.TypeLib").Guid, 2, 36)
  117. guidValue = Replace(guidValue, "-", "")
  118. CreateDisposableDatabaseCopy = tempFolderPath & "\purple-envelope-tests-" & guidValue & ".mdb"
  119. fso.CopyFile sourcePath, CreateDisposableDatabaseCopy, True
  120. Set fso = Nothing
  121. End Function
  122. Private Sub UseDisposableDatabase(ByVal dbPath)
  123. Set DAL__Singleton = Nothing
  124. set DAL__Singleton = new Database_Class
  125. DAL__Singleton.Initialize "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=5;Data Source=" & dbPath & ";"
  126. End Sub
  127. Private Sub EnsureDeliveryLabelPageTable()
  128. On Error Resume Next
  129. DAL.Execute "CREATE TABLE [DeliveryLabelPage] (" & _
  130. "[ID] COUNTER CONSTRAINT [PrimaryKey] PRIMARY KEY, " & _
  131. "[KitID] LONG NOT NULL, " & _
  132. "[PageNum] INTEGER NOT NULL, " & _
  133. "[Label1] MEMO, " & _
  134. "[Label2] MEMO, " & _
  135. "[Label3] MEMO, " & _
  136. "[Label4] MEMO, " & _
  137. "[Label5] MEMO, " & _
  138. "[Label6] MEMO);", empty
  139. Err.Clear
  140. On Error GoTo 0
  141. End Sub
  142. Private Sub ResetDisposableDatabase()
  143. dim tempPath : tempPath = m_tempDbPath
  144. Set DAL__Singleton = Nothing
  145. If Len(tempPath) > 0 Then
  146. dim fso : set fso = Server.CreateObject("Scripting.FileSystemObject")
  147. If fso.FileExists(tempPath) Then
  148. fso.DeleteFile tempPath, True
  149. End If
  150. Set fso = Nothing
  151. End If
  152. m_tempDbPath = ""
  153. End Sub
  154. Private Function NextSeedKey(ByVal prefix)
  155. NextSeedKey = prefix & Replace(Replace(Replace(CStr(Now()), "/", ""), ":", ""), " ", "") & CStr(Int((Rnd() * 1000000) + 1))
  156. End Function
  157. Private Function NextJurisdictionCode()
  158. dim guidValue : guidValue = Mid(CreateObject("Scriptlet.TypeLib").Guid, 2, 8)
  159. NextJurisdictionCode = "J" & Replace(guidValue, "-", "")
  160. End Function
  161. Private Function SeedJurisdiction(ByVal jCode, ByVal name)
  162. DAL.Execute "INSERT INTO [Jurisdiction] ([JCode], [Name], [Mailing_Address], [CSZ], [IMB], [IMB_Digits]) VALUES (?,?,?,?,?,?)", _
  163. Array(jCode, name, "123 Test St", "Lansing, MI 48933", "IMB", "123456789")
  164. SeedJurisdiction = jCode
  165. End Function
  166. Private Function SeedPurpleEnvelopeKit(ByVal jobNumber, ByVal jCode, ByVal status)
  167. DAL.Execute "INSERT INTO [Kit] ([JobNumber], [Jcode], [CreatedOn], [InkJetJob], [JobType], [Cass], [Status], [OutboundSTID], [InboundSTID], [OfficeCopiesAmount]) VALUES (?,?,?,?,?,?,?,?,?,?)", _
  168. Array(jobNumber, jCode, Now(), False, "Purple Envelopes", False, status, "", "", Null)
  169. SeedPurpleEnvelopeKit = QueryScalar("SELECT TOP 1 [ID] FROM [Kit] WHERE [JobNumber] = ? ORDER BY [ID] DESC", jobNumber)
  170. End Function
  171. Private Sub SeedInkjetRecord(ByVal kitId, ByVal precinct, ByVal ballotNumber, ByVal colorId)
  172. DAL.Execute "INSERT INTO [InkjetRecords] ([KitID], [PRECINCT], [BALLOT_NUMBER], [ColorId]) VALUES (?,?,?,?)", _
  173. Array(kitId, precinct, ballotNumber, colorId)
  174. End Sub
  175. Private Function QueryScalar(ByVal sql, ByVal params)
  176. dim rs : set rs = DAL.Query(sql, params)
  177. QueryScalar = rs(0).Value
  178. Destroy rs
  179. End Function
  180. Private Function QueryPrecinctColorMap(ByVal kitId)
  181. dim map : set map = Server.CreateObject("Scripting.Dictionary")
  182. dim rs : set rs = DAL.Query("SELECT [PRECINCT], [ColorId] FROM [InkjetRecords] WHERE [KitID] = ? ORDER BY [PRECINCT]", kitId)
  183. Do Until rs.EOF
  184. If IsNull(rs("ColorId")) Then
  185. map(rs("PRECINCT") & "") = ""
  186. Else
  187. map(rs("PRECINCT") & "") = CStr(rs("ColorId"))
  188. End If
  189. rs.MoveNext
  190. Loop
  191. Destroy rs
  192. set QueryPrecinctColorMap = map
  193. End Function
  194. Private Function BuildDeliveryLabelPage(ByVal pageNum, ByVal label1, ByVal label2, ByVal label3, ByVal label4, ByVal label5, ByVal label6)
  195. dim page : set page = new DeliveryLabelPage_Class
  196. page.PageNum = pageNum
  197. page.Label1 = label1
  198. page.Label2 = label2
  199. page.Label3 = label3
  200. page.Label4 = label4
  201. page.Label5 = label5
  202. page.Label6 = label6
  203. set BuildDeliveryLabelPage = page
  204. End Function
  205. Public Sub Test_FormatElectionLabel_Returns_Mon_YYYY_For_Valid_Date(T)
  206. T.AssertEqual "May-2026", PurpleEnvelopeReportHelper().FormatElectionLabel("5/26/2026"), "Expected valid dates to render as Mon-YYYY."
  207. End Sub
  208. Public Sub Test_FormatElectionLabel_Returns_Trimmed_Raw_Value_For_Invalid_Date(T)
  209. T.AssertEqual "not a date", PurpleEnvelopeReportHelper().FormatElectionLabel(" not a date "), "Expected invalid election dates to fall back to trimmed raw text."
  210. T.AssertEqual "", PurpleEnvelopeReportHelper().FormatElectionLabel(""), "Expected empty election dates to stay empty."
  211. End Sub
  212. Public Sub Test_SortPrecinctColorRows_Handles_Zero_Padded_And_Lettered_Precincts(T)
  213. dim rs : set rs = CreatePrecinctColorRecordset(Array( _
  214. Array("12B", "2"), _
  215. Array("0003", ""), _
  216. Array("A1", "4"), _
  217. Array("12A", "3"), _
  218. Array("3", "5"), _
  219. Array("0001", "1"), _
  220. Array("12", "6") _
  221. ))
  222. dim sorted : set sorted = PurpleEnvelopeReportHelper().SortPrecinctColorRows(rs)
  223. T.AssertEqual "0001,0003,3,12,12A,12B,A1", PrecinctListToCsv(sorted), "Expected mixed-format precincts to sort in the current ascending order."
  224. Destroy rs
  225. Destroy sorted
  226. End Sub
  227. Public Sub Test_SortPrecinctBallotRangeRows_Preserves_Ranges_While_Sorting(T)
  228. dim rs : set rs = CreateBallotRangeRecordset(Array( _
  229. Array("12A", 20, 29), _
  230. Array("0003", 1, 10), _
  231. Array("12", 11, 19), _
  232. Array("A1", 30, 39) _
  233. ))
  234. dim sorted : set sorted = PurpleEnvelopeReportHelper().SortPrecinctBallotRangeRows(rs)
  235. dim it : set it = sorted.Iterator()
  236. dim row
  237. T.AssertEqual "0003,12,12A,A1", PrecinctListToCsv(sorted), "Expected report rows to follow the same precinct order as the color table."
  238. set row = it.GetNext()
  239. T.AssertEqual 1, row.LowBallotNumber, "Expected the low ballot number to stay attached to precinct 0003."
  240. T.AssertEqual 10, row.HighBallotNumber, "Expected the high ballot number to stay attached to precinct 0003."
  241. Destroy rs
  242. Destroy sorted
  243. End Sub
  244. Public Sub Test_GetPrecinctBallotRangesByKitId_Uses_Seeded_Data(T)
  245. Randomize
  246. dim jCode : jCode = NextJurisdictionCode()
  247. dim jobNumber : jobNumber = NextSeedKey("JOB")
  248. Call SeedJurisdiction(jCode, "City of Lansing")
  249. dim kitId : kitId = SeedPurpleEnvelopeKit(jobNumber, jCode, "Ready To Assign STIDS")
  250. SeedInkjetRecord kitId, "12A", "29", Null
  251. SeedInkjetRecord kitId, "0003", "10", Null
  252. SeedInkjetRecord kitId, "12A", "20", Null
  253. SeedInkjetRecord kitId, "0003", "1", Null
  254. SeedInkjetRecord kitId, "A1", "30", Null
  255. dim rs : set rs = InkjetRecordsRepository.GetPrecinctBallotRangesByKitId(kitId)
  256. dim sorted : set sorted = PurpleEnvelopeReportHelper().SortPrecinctBallotRangeRows(rs)
  257. dim it : set it = sorted.Iterator()
  258. dim firstRow, secondRow, thirdRow
  259. set firstRow = it.GetNext()
  260. set secondRow = it.GetNext()
  261. set thirdRow = it.GetNext()
  262. T.AssertEqual "0003,12A,A1", PrecinctListToCsv(sorted), "Expected seeded ballot ranges to sort in the current report order."
  263. T.AssertEqual 1, firstRow.LowBallotNumber, "Expected precinct 0003 to use the seeded minimum ballot number."
  264. T.AssertEqual 10, firstRow.HighBallotNumber, "Expected precinct 0003 to use the seeded maximum ballot number."
  265. T.AssertEqual 20, secondRow.LowBallotNumber, "Expected precinct 12A to use the seeded minimum ballot number."
  266. T.AssertEqual 29, secondRow.HighBallotNumber, "Expected precinct 12A to use the seeded maximum ballot number."
  267. T.AssertEqual 30, thirdRow.LowBallotNumber, "Expected single-row precincts to keep their ballot number as the low value."
  268. T.AssertEqual 30, thirdRow.HighBallotNumber, "Expected single-row precincts to keep their ballot number as the high value."
  269. Destroy rs
  270. Destroy sorted
  271. Set firstRow = Nothing
  272. Set secondRow = Nothing
  273. Set thirdRow = Nothing
  274. End Sub
  275. Public Sub Test_UpdateColorForKit_Updates_All_Seeded_Rows_For_The_Target_Kit(T)
  276. Randomize
  277. dim jCode : jCode = NextJurisdictionCode()
  278. Call SeedJurisdiction(jCode, "City of Lansing")
  279. dim targetKitId : targetKitId = SeedPurpleEnvelopeKit(NextSeedKey("JOB"), jCode, "Ready To Assign STIDS")
  280. dim otherKitId : otherKitId = SeedPurpleEnvelopeKit(NextSeedKey("JOB"), jCode, "Ready To Assign STIDS")
  281. SeedInkjetRecord targetKitId, "0003", "1", 1
  282. SeedInkjetRecord targetKitId, "12A", "2", Null
  283. SeedInkjetRecord otherKitId, "9", "3", 4
  284. InkjetRecordsRepository.UpdateColorForKit targetKitId, 7
  285. dim targetMap : set targetMap = QueryPrecinctColorMap(targetKitId)
  286. dim otherMap : set otherMap = QueryPrecinctColorMap(otherKitId)
  287. T.AssertEqual "7", targetMap("0003"), "Expected kit-wide color updates to touch every row in the targeted kit."
  288. T.AssertEqual "7", targetMap("12A"), "Expected kit-wide color updates to touch every row in the targeted kit."
  289. T.AssertEqual "4", otherMap("9"), "Expected kit-wide color updates to leave other kits unchanged."
  290. Set targetMap = Nothing
  291. Set otherMap = Nothing
  292. End Sub
  293. Public Sub Test_UpdateColorForPrecinct_Updates_Only_The_Targeted_Precinct(T)
  294. Randomize
  295. dim jCode : jCode = NextJurisdictionCode()
  296. Call SeedJurisdiction(jCode, "City of Lansing")
  297. dim kitId : kitId = SeedPurpleEnvelopeKit(NextSeedKey("JOB"), jCode, "Ready To Assign STIDS")
  298. SeedInkjetRecord kitId, "0003", "1", 1
  299. SeedInkjetRecord kitId, "12A", "2", 2
  300. SeedInkjetRecord kitId, "A1", "3", Null
  301. InkjetRecordsRepository.UpdateColorForPrecinct kitId, "12A", 9
  302. dim colorMap : set colorMap = QueryPrecinctColorMap(kitId)
  303. T.AssertEqual "1", colorMap("0003"), "Expected non-targeted precincts to keep their original color."
  304. T.AssertEqual "9", colorMap("12A"), "Expected the targeted precinct to receive the new color."
  305. T.AssertEqual "", colorMap("A1"), "Expected non-targeted blank colors to remain blank."
  306. Set colorMap = Nothing
  307. End Sub
  308. Public Sub Test_SwitchBoardPurpleEnvelopeEditFindById_Returns_Seeded_Header_Data(T)
  309. Randomize
  310. dim jCode : jCode = NextJurisdictionCode()
  311. dim jobNumber : jobNumber = NextSeedKey("JOB")
  312. Call SeedJurisdiction(jCode, "City of Lansing")
  313. dim kitId : kitId = SeedPurpleEnvelopeKit(jobNumber, jCode, "Ready To Assign STIDS")
  314. SeedInkjetRecord kitId, "0003", "1", Null
  315. SeedInkjetRecord kitId, "12A", "2", Null
  316. dim model : set model = KitRepository.SwitchBoardPurpleEnvelopeEditFindById(kitId)
  317. T.AssertEqual kitId, model.ID, "Expected the seeded purple-envelope kit to be returned."
  318. T.AssertEqual jobNumber, model.JobNumber, "Expected the seeded job number to be returned."
  319. T.AssertEqual jCode, model.JCode, "Expected the seeded jurisdiction code to be returned."
  320. T.AssertEqual "City of Lansing", model.Jurisdiction, "Expected the seeded jurisdiction name to be returned."
  321. T.AssertEqual 2, model.LabelCount, "Expected the seeded inkjet row count to flow into the label count."
  322. T.AssertEqual "Ready To Assign STIDS", model.Status, "Expected the seeded status to be returned."
  323. Set model = Nothing
  324. End Sub
  325. Public Sub Test_SaveDeliveryLabelPages_Persists_Seeded_Page_Data(T)
  326. Randomize
  327. dim jCode : jCode = NextJurisdictionCode()
  328. Call SeedJurisdiction(jCode, "City of Lansing")
  329. dim kitId : kitId = SeedPurpleEnvelopeKit(NextSeedKey("JOB"), jCode, "Done")
  330. dim pages : set pages = new LinkedList_Class
  331. pages.Push BuildDeliveryLabelPage(1, "Jurisdiction A" & vbCrLf & "Box 1 of 2", "Jurisdiction A" & vbCrLf & "Box 2 of 2", "", "", "", "")
  332. KitRepository.SaveDeliveryLabelPages kitId, pages
  333. T.AssertEqual 1, QueryScalar("SELECT COUNT(*) FROM [DeliveryLabelPage] WHERE [KitID] = ?", kitId), "Expected one staged page row for the seeded kit."
  334. dim rs : set rs = DAL.Query("SELECT [PageNum], [Label1], [Label2], [Label3], [Label4], [Label5], [Label6] FROM [DeliveryLabelPage] WHERE [KitID] = ? ORDER BY [PageNum]", kitId)
  335. T.Assert Not rs.EOF, "Expected the seeded staged-page row to be present."
  336. T.AssertEqual 1, rs("PageNum"), "Expected staged page numbers to persist."
  337. T.AssertEqual "Jurisdiction A" & vbCrLf & "Box 1 of 2", rs("Label1"), "Expected Label1 to persist exactly."
  338. T.AssertEqual "Jurisdiction A" & vbCrLf & "Box 2 of 2", rs("Label2"), "Expected Label2 to persist exactly."
  339. T.AssertEqual "", rs("Label3"), "Expected unused label slots to persist as empty strings."
  340. Destroy rs
  341. Set pages = Nothing
  342. End Sub
  343. Public Sub Test_SaveDeliveryLabelPages_Replaces_Existing_Pages_For_The_Kit(T)
  344. Randomize
  345. dim jCode : jCode = NextJurisdictionCode()
  346. Call SeedJurisdiction(jCode, "City of Lansing")
  347. dim kitId : kitId = SeedPurpleEnvelopeKit(NextSeedKey("JOB"), jCode, "Done")
  348. dim firstRunPages : set firstRunPages = new LinkedList_Class
  349. firstRunPages.Push BuildDeliveryLabelPage(1, "Run1-Page1-Label1", "", "", "", "", "")
  350. firstRunPages.Push BuildDeliveryLabelPage(2, "Run1-Page2-Label1", "", "", "", "", "")
  351. KitRepository.SaveDeliveryLabelPages kitId, firstRunPages
  352. dim secondRunPages : set secondRunPages = new LinkedList_Class
  353. secondRunPages.Push BuildDeliveryLabelPage(1, "Run2-OnlyPage-Label1", "Run2-OnlyPage-Label2", "", "", "", "")
  354. KitRepository.SaveDeliveryLabelPages kitId, secondRunPages
  355. T.AssertEqual 1, QueryScalar("SELECT COUNT(*) FROM [DeliveryLabelPage] WHERE [KitID] = ?", kitId), "Expected the second save to replace all prior staged rows for the same kit."
  356. dim rs : set rs = DAL.Query("SELECT [PageNum], [Label1], [Label2] FROM [DeliveryLabelPage] WHERE [KitID] = ? ORDER BY [PageNum]", kitId)
  357. T.Assert Not rs.EOF, "Expected a replacement staged row after the second save."
  358. T.AssertEqual 1, rs("PageNum"), "Expected replacement rows to keep their explicit page numbers."
  359. T.AssertEqual "Run2-OnlyPage-Label1", rs("Label1"), "Expected replacement data to overwrite prior Label1 values."
  360. T.AssertEqual "Run2-OnlyPage-Label2", rs("Label2"), "Expected replacement data to overwrite prior Label2 values."
  361. Destroy rs
  362. Set firstRunPages = Nothing
  363. Set secondRunPages = Nothing
  364. End Sub
  365. Public Sub Test_DeleteDeliveryLabelPages_Removes_All_Staged_Pages_For_The_Kit(T)
  366. Randomize
  367. dim jCode : jCode = NextJurisdictionCode()
  368. Call SeedJurisdiction(jCode, "City of Lansing")
  369. dim kitId : kitId = SeedPurpleEnvelopeKit(NextSeedKey("JOB"), jCode, "Done")
  370. dim pages : set pages = new LinkedList_Class
  371. pages.Push BuildDeliveryLabelPage(1, "Delete-Label1", "", "", "", "", "")
  372. pages.Push BuildDeliveryLabelPage(2, "Delete-Label2", "", "", "", "", "")
  373. KitRepository.SaveDeliveryLabelPages kitId, pages
  374. KitRepository.DeleteDeliveryLabelPages kitId
  375. T.AssertEqual 0, QueryScalar("SELECT COUNT(*) FROM [DeliveryLabelPage] WHERE [KitID] = ?", kitId), "Expected DeleteDeliveryLabelPages to remove all staged rows for the kit."
  376. Set pages = Nothing
  377. End Sub
  378. Public Sub Test_KitController_Post_Actions_Still_Delegate_To_Color_Update_Repositories(T)
  379. dim controllerSource : controllerSource = ReadAllText("../App/Controllers/Kit/KitController.asp")
  380. T.Assert InStr(controllerSource, "Public Sub AssignKitColorPost") > 0, "Expected the kit-wide color POST action to remain present."
  381. T.Assert InStr(controllerSource, "InkjetRecordsRepository.UpdateColorForKit CLng(ID), CLng(Request.Form(""KitColorId""))") > 0, "Expected AssignKitColorPost to keep delegating to the kit-wide color repository update."
  382. T.Assert InStr(controllerSource, "Public Sub AssignPrecinctColorsPost") > 0, "Expected the precinct color POST action to remain present."
  383. T.Assert InStr(controllerSource, "InkjetRecordsRepository.UpdateColorForPrecinct CLng(ID), precinct, CLng(colorId)") > 0, "Expected AssignPrecinctColorsPost to keep delegating to the precinct-specific color repository update."
  384. End Sub
  385. Public Sub Test_Report_View_Keeps_Print_Only_CSS_Contract(T)
  386. dim viewSource : viewSource = ReadAllText("../App/Views/Kit/SwitchBoardPurpleEnvelopeEdit.asp")
  387. T.Assert InStr(viewSource, "id=""purple-envelope-report-print""") > 0, "Expected the report print wrapper id to remain in the view."
  388. T.Assert InStr(viewSource, "body * {") > 0, "Expected print CSS to hide non-report content."
  389. T.Assert InStr(viewSource, "font-size: 10pt;") > 0, "Expected the reduced report font size to remain unchanged."
  390. T.Assert InStr(viewSource, "padding: 0.45in 0.25in 0.25in 0.25in;") > 0, "Expected the print top buffer padding to remain unchanged."
  391. End Sub
  392. Public Sub Test_Report_View_Keeps_No_Data_Row_And_Page_Spacer(T)
  393. dim viewSource : viewSource = ReadAllText("../App/Views/Kit/SwitchBoardPurpleEnvelopeEdit.asp")
  394. T.Assert InStr(viewSource, "class=""print-page-spacer""") > 0, "Expected the repeated-page spacer row to remain in the report header."
  395. T.Assert InStr(viewSource, "No precinct ballot data found for this kit.") > 0, "Expected the empty-state report message to remain unchanged."
  396. End Sub
  397. Public Sub Test_Report_View_Only_Shows_Delivery_Paperwork_Link_When_Kit_Is_Done(T)
  398. dim viewSource : viewSource = ReadAllText("../App/Views/Kit/SwitchBoardPurpleEnvelopeEdit.asp")
  399. T.Assert InStr(viewSource, "Model.Kit.Status = ""Done""") > 0, "Expected the delivery paperwork button to remain gated by Done status."
  400. T.Assert InStr(viewSource, "PrintDeliveryPaperwork") > 0, "Expected the delivery paperwork link target to remain in the view."
  401. End Sub
  402. Public Sub Test_KitController_Declares_PrintDeliveryPaperwork_Action(T)
  403. dim controllerSource : controllerSource = ReadAllText("../App/Controllers/Kit/KitController.asp")
  404. T.Assert InStr(controllerSource, "Public Sub PrintDeliveryPaperwork") > 0, "Expected KitController to expose the PrintDeliveryPaperwork action."
  405. End Sub
  406. End Class
  407. %>

Powered by TurnKey Linux.