|
1 | 1 | (ns agiladmin.view-timesheet-test |
2 | 2 | (:require [agiladmin.view-timesheet :as view-timesheet] |
| 3 | + [clojure.java.io :as io] |
3 | 4 | [hiccup.core :as hiccup] |
4 | 5 | [failjure.core] |
| 6 | + [me.raynes.fs :as fs] |
5 | 7 | [midje.sweet :refer :all])) |
6 | 8 |
|
7 | 9 | (fact "Timesheet upload form uses HTMX for progressive enhancement" |
|
171 | 173 | (:body response) => (contains "This is a new timesheet, no historical information available to compare") |
172 | 174 | (:body response) => (contains "Uploaded: upload.xlsx")))) |
173 | 175 |
|
| 176 | +(fact "Timesheet upload accepts a real xlsx workbook fixture" |
| 177 | + (let [temp-root (.toFile (java.nio.file.Files/createTempDirectory "agiladmin-upload-test" |
| 178 | + (make-array java.nio.file.attribute.FileAttribute 0))) |
| 179 | + upload-path (str temp-root "/fixture-upload.xlsx") |
| 180 | + budgets-path (str temp-root "/budgets/")] |
| 181 | + (.mkdirs (io/file budgets-path)) |
| 182 | + (io/copy (io/file "test/assets/2016_timesheet_Luca-Pacioli.xlsx") |
| 183 | + (io/file upload-path)) |
| 184 | + (try |
| 185 | + (let [response (view-timesheet/upload |
| 186 | + {:params {:file {:size (.length (io/file upload-path)) |
| 187 | + :filename "2016_timesheet_Luca-Pacioli.xlsx" |
| 188 | + :tempfile (io/file upload-path)}}} |
| 189 | + {:agiladmin {:budgets {:path budgets-path}}} |
| 190 | + {:name "Admin User" |
| 191 | + :role "admin"})] |
| 192 | + (:body response) => (contains "Uploaded: 2016_timesheet_Luca-Pacioli.xlsx") |
| 193 | + (:body response) => (contains "Contents of the new timesheet") |
| 194 | + (:body response) => (contains "Differences: old (to the left) and new (to the right)") |
| 195 | + (:body response) => (contains "This is a new timesheet, no historical information available to compare") |
| 196 | + (:body response) =not=> (contains "Error parsing timesheet")) |
| 197 | + (finally |
| 198 | + (fs/delete-dir temp-root))))) |
| 199 | + |
174 | 200 | (fact "Timesheet submit explains when the budgets directory is missing" |
175 | 201 | (with-redefs [clojure.java.io/file |
176 | 202 | (fn [path] |
|
0 commit comments