web: re-enable the test suite; add a test for /journal (#1390)
This commit is contained in:
parent
b76a88aa81
commit
290428f9d4
2
hie.yaml
2
hie.yaml
@ -41,3 +41,5 @@ cradle:
|
|||||||
component: "hledger-web:lib"
|
component: "hledger-web:lib"
|
||||||
- path: "hledger-web/app/"
|
- path: "hledger-web/app/"
|
||||||
component: "hledger-web:exe:hledger-web"
|
component: "hledger-web:exe:hledger-web"
|
||||||
|
- path: "hledger-web/test/"
|
||||||
|
component: "hledger-web:test:test"
|
||||||
|
|||||||
@ -4,7 +4,7 @@ cabal-version: 1.12
|
|||||||
--
|
--
|
||||||
-- see: https://github.com/sol/hpack
|
-- see: https://github.com/sol/hpack
|
||||||
--
|
--
|
||||||
-- hash: 1d9dc492e44eb37e5c5db8a8d8d21ca089c3035b4f4fa72d95696d51613400be
|
-- hash: 929ce1d9b5d6a14f13fa77dd3a21d8772a58c1e13310e4940510878718fa4d96
|
||||||
|
|
||||||
name: hledger-web
|
name: hledger-web
|
||||||
version: 1.19.99
|
version: 1.19.99
|
||||||
@ -222,3 +222,22 @@ executable hledger-web
|
|||||||
if flag(threaded)
|
if flag(threaded)
|
||||||
ghc-options: -threaded
|
ghc-options: -threaded
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
|
||||||
|
test-suite test
|
||||||
|
type: exitcode-stdio-1.0
|
||||||
|
main-is: test.hs
|
||||||
|
hs-source-dirs:
|
||||||
|
test
|
||||||
|
ghc-options: -Wall -fwarn-tabs -Wcompat -Wincomplete-uni-patterns -Wincomplete-record-updates -Wredundant-constraints
|
||||||
|
cpp-options: -DVERSION="1.19.99"
|
||||||
|
build-depends:
|
||||||
|
base
|
||||||
|
, hledger-web
|
||||||
|
, hspec
|
||||||
|
, yesod
|
||||||
|
, yesod-test
|
||||||
|
if (flag(dev)) || (flag(library-only))
|
||||||
|
cpp-options: -DDEVELOPMENT
|
||||||
|
if flag(dev)
|
||||||
|
ghc-options: -O0
|
||||||
|
default-language: Haskell2010
|
||||||
|
|||||||
@ -158,15 +158,15 @@ executables:
|
|||||||
- condition: flag(threaded)
|
- condition: flag(threaded)
|
||||||
ghc-options: -threaded
|
ghc-options: -threaded
|
||||||
|
|
||||||
# 2018/06 not building and not testing anything useful, disabled for now
|
tests:
|
||||||
# tests:
|
test:
|
||||||
# test:
|
source-dirs: test
|
||||||
# source-dirs: test
|
main: test.hs
|
||||||
# main: test.hs
|
other-modules: [] # prevent double compilation, https://github.com/sol/hpack/issues/188
|
||||||
# other-modules: [] # prevent double compilation, https://github.com/sol/hpack/issues/188
|
cpp-options: -DVERSION="1.19.99"
|
||||||
# cpp-options: -DVERSION="1.19.99"
|
dependencies:
|
||||||
# dependencies:
|
- base
|
||||||
# - base
|
- hledger-web
|
||||||
# - hledger-web
|
- hspec
|
||||||
# - hspec
|
- yesod
|
||||||
# - yesod-test
|
- yesod-test
|
||||||
|
|||||||
@ -1,25 +0,0 @@
|
|||||||
{-# LANGUAGE OverloadedStrings #-}
|
|
||||||
module HomeTest
|
|
||||||
( homeSpecs
|
|
||||||
) where
|
|
||||||
|
|
||||||
import TestImport
|
|
||||||
|
|
||||||
homeSpecs :: Specs
|
|
||||||
homeSpecs =
|
|
||||||
ydescribe "Some hledger-web tests" $
|
|
||||||
|
|
||||||
yit "serves a reasonable-looking register page" $ do
|
|
||||||
get RegisterR
|
|
||||||
statusIs 200
|
|
||||||
bodyContains "accounts"
|
|
||||||
|
|
||||||
-- post "/" $ do
|
|
||||||
-- addNonce
|
|
||||||
-- fileByLabel "Choose a file" "tests/main.hs" "text/plain" -- talk about self-reference
|
|
||||||
-- byLabel "What's on the file?" "Some Content"
|
|
||||||
|
|
||||||
-- statusIs 200
|
|
||||||
-- htmlCount ".message" 1
|
|
||||||
-- htmlAllContain ".message" "Some Content"
|
|
||||||
-- htmlAllContain ".message" "text/plain"
|
|
||||||
@ -1,12 +0,0 @@
|
|||||||
{-# LANGUAGE OverloadedStrings #-}
|
|
||||||
module TestImport
|
|
||||||
( module Yesod.Test
|
|
||||||
, module Foundation
|
|
||||||
, Specs
|
|
||||||
) where
|
|
||||||
|
|
||||||
import Yesod.Test
|
|
||||||
|
|
||||||
import Foundation
|
|
||||||
|
|
||||||
type Specs = YesodSpec App
|
|
||||||
@ -7,21 +7,44 @@ module Main where
|
|||||||
-- cabal missing-home-modules workaround from hledger-lib needed here ?
|
-- cabal missing-home-modules workaround from hledger-lib needed here ?
|
||||||
-- {-# LANGUAGE PackageImports #-}
|
-- {-# LANGUAGE PackageImports #-}
|
||||||
|
|
||||||
import Import
|
import Test.Hspec (hspec)
|
||||||
import Yesod.Default.Config
|
import Yesod.Default.Config
|
||||||
import Yesod.Test
|
import Yesod.Test
|
||||||
import Test.Hspec (hspec)
|
import Hledger.Web.Application (makeFoundation)
|
||||||
import Application (makeFoundation)
|
import Hledger.Web.Foundation
|
||||||
|
import Hledger.Web.Settings (parseExtra)
|
||||||
import Hledger.Web.WebOptions (defwebopts)
|
import Hledger.Web.WebOptions (defwebopts)
|
||||||
|
|
||||||
import HomeTest
|
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
conf <- Yesod.Default.Config.loadConfig $ (configSettings Testing)
|
conf <- Yesod.Default.Config.loadConfig $
|
||||||
{ csParseExtra = parseExtra
|
(configSettings Testing){ csParseExtra = parseExtra }
|
||||||
}
|
|
||||||
foundation <- makeFoundation conf defwebopts
|
foundation <- makeFoundation conf defwebopts
|
||||||
hspec $ do
|
hspec $ yesodSpec foundation specs
|
||||||
yesodSpec foundation $ do
|
|
||||||
homeSpecs
|
-- https://hackage.haskell.org/package/yesod-test/docs/Yesod-Test.html
|
||||||
|
|
||||||
|
specs :: YesodSpec App
|
||||||
|
specs = do
|
||||||
|
ydescribe "hledger-web basic functionality" $ do
|
||||||
|
|
||||||
|
yit "serves a reasonable-looking journal page" $ do
|
||||||
|
get JournalR
|
||||||
|
statusIs 200
|
||||||
|
bodyContains "Add a transaction"
|
||||||
|
|
||||||
|
yit "serves a reasonable-looking register page" $ do
|
||||||
|
get RegisterR
|
||||||
|
statusIs 200
|
||||||
|
bodyContains "accounts"
|
||||||
|
|
||||||
|
-- post "/" $ do
|
||||||
|
-- addNonce
|
||||||
|
-- fileByLabel "Choose a file" "tests/main.hs" "text/plain" -- talk about self-reference
|
||||||
|
-- byLabel "What's on the file?" "Some Content"
|
||||||
|
|
||||||
|
-- statusIs 200
|
||||||
|
-- htmlCount ".message" 1
|
||||||
|
-- htmlAllContain ".message" "Some Content"
|
||||||
|
-- htmlAllContain ".message" "text/plain"
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user