mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-20 01:07:18 +03:00
Add an integration test for daml new ... create-daml-app (#5389)
The test calls `daml new ... create-daml-app`, builds the DAR, runs the TypeScript codegen, lints and builds the React app. We should also run the tests for the React app but since that's most likely tricky, I'll leave that for a followup PR so that we can land at least some sanity checks now. There's also a bit of cleanup to do around setting up a yarn workspace to bring our TypeScript libraries into scope. Other test already solve a similar problem in a way that is not general enough for this test. I'll unify the setup in a followup PR as well. CHANGELOG_BEGIN CHANGELOG_END
This commit is contained in:
parent
1bedfaa151
commit
9c086c71ee
@ -68,6 +68,12 @@ genrule(
|
||||
""".format(mvn = mvn_version),
|
||||
)
|
||||
|
||||
ts_libraries = [
|
||||
"//language-support/ts/daml-types:npm_package",
|
||||
"//language-support/ts/daml-ledger:npm_package",
|
||||
"//language-support/ts/daml-react:npm_package",
|
||||
]
|
||||
|
||||
da_haskell_test(
|
||||
name = "integration-tests",
|
||||
timeout = "long",
|
||||
@ -89,7 +95,7 @@ da_haskell_test(
|
||||
"//compiler/damlc/tests:generate-simple-dalf",
|
||||
"@mvn_dev_env//:mvn",
|
||||
"@tar_dev_env//:tar",
|
||||
] + ([] if is_windows else ["//language-support/ts/daml-types:npm_package"]),
|
||||
] + ([] if is_windows else ts_libraries),
|
||||
# I’m sure the mvn stuff will be flaky.
|
||||
flaky = True,
|
||||
hackage_deps = [
|
||||
|
@ -9,6 +9,8 @@ import Control.Exception
|
||||
import Control.Monad
|
||||
import Control.Monad.Fail (MonadFail)
|
||||
import qualified Data.Aeson as Aeson
|
||||
import Data.Aeson ((.=), object)
|
||||
import qualified Data.ByteString.Lazy as BSL
|
||||
import qualified Data.Conduit.Tar.Extra as Tar.Conduit.Extra
|
||||
import qualified Data.Conduit.Zlib as Zlib
|
||||
import Data.List.Extra
|
||||
@ -73,6 +75,7 @@ tests tmpDir damlTypesDir = withSdkResource $ \_ -> testGroup "Integration tests
|
||||
, cleanTests cleanDir
|
||||
, templateTests
|
||||
, codegenTests codegenDir damlTypesDir
|
||||
, createDamlAppTests
|
||||
]
|
||||
where quickstartDir = tmpDir </> "q-u-i-c-k-s-t-a-r-t"
|
||||
cleanDir = tmpDir </> "clean"
|
||||
@ -551,6 +554,38 @@ codegenTests codegenDir damlTypes = testGroup "daml codegen" (
|
||||
contents <- listDirectory outDir
|
||||
assertBool "bindings were written" (not $ null contents)
|
||||
|
||||
createDamlAppTests :: TestTree
|
||||
createDamlAppTests = testGroup "create-daml-app" [gettingStartedGuideTest | not isWindows]
|
||||
where
|
||||
gettingStartedGuideTest = testCase "Getting Started Guide" $
|
||||
withTempDir $ \tmpDir -> do
|
||||
let tsLibs = ["daml-types", "daml-ledger", "daml-react"]
|
||||
forM_ tsLibs $ \tsLib -> do
|
||||
srcDir <- locateRunfiles $ mainWorkspace </> "language-support" </> "ts" </> tsLib </> "npm_package"
|
||||
copyDirectory srcDir (tmpDir </> tsLib)
|
||||
BSL.writeFile (tmpDir </> "package.json") $ Aeson.encode $ object
|
||||
[ "private" .= True
|
||||
, "workspaces" .= ["create-daml-app/daml-ts", "create-daml-app/ui" :: String]
|
||||
, "resolutions" .= object
|
||||
[ pkgName .= ("file:" ++ tsLib)
|
||||
| tsLib <- tsLibs, let pkgName = "@" <> T.replace "-" "/" (T.pack tsLib)
|
||||
]
|
||||
]
|
||||
withCurrentDirectory tmpDir $ do
|
||||
callCommandSilent "daml new create-daml-app create-daml-app"
|
||||
let cdaDir = tmpDir </> "create-daml-app"
|
||||
withCurrentDirectory cdaDir $ do
|
||||
callCommandSilent "daml build"
|
||||
callCommandSilent "daml codegen ts -o daml-ts .daml/dist/create-daml-app-0.1.0.dar"
|
||||
doesFileExist (cdaDir </> "ui" </> "build" </> "index.html") >>=
|
||||
assertBool "ui/build/index.html does not yet exist" . not
|
||||
withCurrentDirectory (cdaDir </> "ui") $ do
|
||||
callCommandSilent "yarn install"
|
||||
callCommandSilent "yarn lint --max-warnings 0"
|
||||
callCommandSilent "yarn build"
|
||||
doesFileExist (cdaDir </> "ui" </> "build" </> "index.html") >>=
|
||||
assertBool "ui/build/index.html has been produced"
|
||||
|
||||
damlInstallerName :: String
|
||||
damlInstallerName
|
||||
| isWindows = "daml.exe"
|
||||
|
Loading…
Reference in New Issue
Block a user