-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Modernize e2e-tests
#3114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Modernize e2e-tests
#3114
Changes from 99 commits
Commits
Show all changes
123 commits
Select commit
Hold shift + click to select a range
94cc3a8
consistency
FranjoMindek a4807aa
Merge branch 'main' into franjo/cli-testing
FranjoMindek 32365a4
current
FranjoMindek 257f648
kitchen sink works?
FranjoMindek 81bc121
rel path
FranjoMindek 7a8b90b
change name
FranjoMindek 8870801
simplify
FranjoMindek 8081572
HEAD -> working dir copy
FranjoMindek b271345
rename
FranjoMindek 302dd36
changes
FranjoMindek c8b722f
remove test-outputs changes
FranjoMindek 9706ac3
remove new
FranjoMindek c1d586b
change
FranjoMindek 3d1a643
Revert "change"
FranjoMindek 7ba2c51
move path stuff to common
FranjoMindek c346af2
naming
FranjoMindek 02a23c9
changes
FranjoMindek 5e62209
revert
FranjoMindek b575677
db
FranjoMindek 638ccef
naming changes
FranjoMindek 3eeaa8b
formatting
FranjoMindek b9bbed1
test docker build in CI without || true
FranjoMindek b4ec6f8
Merge branch 'main' into franjo/cli-testing
FranjoMindek d80cc08
fix + remove unused exports
FranjoMindek e740f1f
add checks
FranjoMindek 164bcf5
comment
FranjoMindek acdaf5d
fix docker ommands
FranjoMindek 0382c81
refactor paths, soruce changes
FranjoMindek 7ed86d0
temp
FranjoMindek 19a3d61
context test
FranjoMindek 7715132
move
FranjoMindek d717706
comments
FranjoMindek befdafb
changes
FranjoMindek c809039
naming
FranjoMindek 12998db
namings
FranjoMindek e895321
naming
FranjoMindek 60e66d3
comments
FranjoMindek 3ec1a2e
remove duplication
FranjoMindek 25fd3cc
changes
FranjoMindek 1740ca3
new structure
FranjoMindek fc3a63d
changes
FranjoMindek 7e872fa
changes
FranjoMindek f6f43be
renaming to snapshot test
FranjoMindek 02d4f4f
simplify
FranjoMindek a1d8515
comments
FranjoMindek 1c14199
Merge branch 'main' into franjo/cli-testing
FranjoMindek 5d6132a
naming
FranjoMindek 55a641e
comment
FranjoMindek 1868302
rename file
FranjoMindek 285876c
common to filesystem
FranjoMindek 4e56bbe
operators
FranjoMindek f6b9efa
siumplify
FranjoMindek 47cb581
naming consistency
FranjoMindek 2d5067f
break
FranjoMindek 04f8262
changes
FranjoMindek e0d1090
different approach
FranjoMindek f521dc2
fix
FranjoMindek 4ae3bfc
use abs path
FranjoMindek 7f46150
name
FranjoMindek ba9deaa
make wasp app typesafe
FranjoMindek b1874e0
update readme
FranjoMindek 82429f6
readme 2
FranjoMindek 178a56d
remove project
FranjoMindek 2455bf8
add current prefix
FranjoMindek 68f1fe2
fix mistake
FranjoMindek d7e2b88
dot
FranjoMindek c9bdaa0
comment
FranjoMindek 2a0ae9c
func to where
FranjoMindek 830d827
name change
FranjoMindek 9bb3c6b
cd instead of pushd popd
FranjoMindek c276219
extract
FranjoMindek fe0e4ea
rename
FranjoMindek e776ece
remove comment
FranjoMindek 0cbee5c
refactor look
FranjoMindek ee2613c
back to array
FranjoMindek ad6d062
rename
FranjoMindek 2293ff2
rename
FranjoMindek 44b5ee6
explain file structure better
FranjoMindek cc9d56e
rename operator
FranjoMindek c197c3f
change context
FranjoMindek 461f61f
renames
FranjoMindek 521988e
renames
FranjoMindek c18717c
remove abs
FranjoMindek ba7ffbe
extract snapshot type
FranjoMindek 961b395
remove conversion vars + rename
FranjoMindek dab6a41
towards StrongPath
FranjoMindek f8b1f00
yay type safety
FranjoMindek d90b68e
desc
FranjoMindek 10cfe2f
sort out formatPackageJsonFiles
FranjoMindek eb74fa0
refactor work
FranjoMindek 98952da
work
FranjoMindek d6d88d9
fix cd bug
FranjoMindek 95fc787
refactor
FranjoMindek b19087f
name
FranjoMindek 50aeca2
remove unused
FranjoMindek 199791e
fix exports
FranjoMindek bac33d5
fix cabal files
FranjoMindek 4bb574c
use existing file system for wasp app
FranjoMindek 2926a56
rename WaspApp to WaspProject
FranjoMindek f9f17fe
improvements
FranjoMindek 1548f2a
remove mnetion of wasp-app
FranjoMindek 35594d6
simplify snapshot test a bit more
FranjoMindek ee2b480
change test-outputs for snapshots
FranjoMindek e4093bc
Merge branch 'main' into franjo/cli-testing
FranjoMindek 67d528a
use od
FranjoMindek 653ee4a
be explicit about the flag
FranjoMindek 5e38035
readme
FranjoMindek 5e45c7f
format
FranjoMindek c6d9b1e
log disk usage
FranjoMindek fe6429a
Merge branch 'main' into franjo/cli-testing
FranjoMindek 6b9e903
Merge remote-tracking branch 'origin/main' into franjo/cli-testing
FranjoMindek 7de0491
change
FranjoMindek 4396db9
gitignore
FranjoMindek a5def3a
dont content check .env files (we random gen database on postgres)
FranjoMindek 4427392
fix
FranjoMindek 87502e0
format
FranjoMindek 760a42c
MINOR FORMATTING
FranjoMindek a64ca50
format
FranjoMindek 3cd8121
test
FranjoMindek ff6500f
Merge remote-tracking branch 'origin/main' into franjo/cli-testing
FranjoMindek 9ddfb0c
no GHC no ormolu I sad
FranjoMindek 1381c9e
Merge remote-tracking branch 'origin/main' into franjo/cli-testing
FranjoMindek 1714812
update version in snapshots
FranjoMindek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Martinsos marked this conversation as resolved.
Show resolved
Hide resolved
FranjoMindek marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
module FileSystem | ||
( GitRepositoryRoot, | ||
WaspcDir, | ||
E2eTestsDir, | ||
waspcDirInGitRoot, | ||
getWaspcDirPath, | ||
e2eTestsDirInWaspcDir, | ||
getE2eTestsDir, | ||
) | ||
where | ||
|
||
import Control.Monad (unless) | ||
import StrongPath (Abs, Dir, Path', Rel, reldir, (</>)) | ||
import qualified StrongPath as SP | ||
import System.Directory (getCurrentDirectory) | ||
import System.FilePath (takeFileName) | ||
|
||
data GitRepositoryRoot | ||
|
||
data WaspcDir | ||
|
||
data E2eTestsDir | ||
|
||
waspcDirInGitRoot :: Path' (Rel GitRepositoryRoot) (Dir WaspcDir) | ||
waspcDirInGitRoot = [reldir|waspc|] | ||
|
||
getWaspcDirPath :: IO (Path' Abs (Dir WaspcDir)) | ||
getWaspcDirPath = do | ||
-- NOTE: Cabal launches `cabal test` from root of the project, so this should always be some absolute path to waspc. | ||
absCwd <- getCurrentDirectory | ||
-- Just a little extra safeguard here since we are doing destructive file ops. | ||
Martinsos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
unless (takeFileName absCwd == "waspc") (error "Expecting test process to be invoked from waspc dir") | ||
SP.parseAbsDir absCwd | ||
|
||
e2eTestsDirInWaspcDir :: Path' (Rel WaspcDir) (Dir E2eTestsDir) | ||
e2eTestsDirInWaspcDir = [reldir|e2e-tests|] | ||
|
||
getE2eTestsDir :: IO (Path' Abs (Dir E2eTestsDir)) | ||
getE2eTestsDir = (</> e2eTestsDirInWaspcDir) <$> getWaspcDirPath |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,27 @@ | ||
import GoldenTest (runGoldenTest) | ||
import SnapshotTest (runSnapshotTest) | ||
import System.Info (os) | ||
import Test.Tasty (TestTree, defaultMain, testGroup) | ||
import Tests.WaspBuildTest (waspBuild) | ||
import Tests.WaspCompileTest (waspCompile) | ||
import Tests.WaspComplexTest (waspComplexTest) | ||
import Tests.WaspJobTest (waspJob) | ||
import Tests.WaspMigrateTest (waspMigrate) | ||
import Tests.WaspNewTest (waspNew) | ||
import Tests.KitchenSinkSnapshotTest (kitchenSinkSnapshotTest) | ||
import Tests.WaspBuildSnapshotTest (waspBuildSnapshotTest) | ||
import Tests.WaspCompileSnapshotTest (waspCompileSnapshotTest) | ||
import Tests.WaspMigrateSnapshotTest (waspMigrateSnapshotTest) | ||
import Tests.WaspNewSnapshotTest (waspNewSnapshotTest) | ||
|
||
main :: IO () | ||
main = do | ||
if os == "mingw32" | ||
then putStrLn "Skipping end-to-end tests on Windows due to tests using *nix-only commands" | ||
else tests >>= defaultMain | ||
|
||
-- TODO: Add more tests to simulate full Todo app tutorial. | ||
-- Some of this requires waspStart and stdout parsing. | ||
-- TODO: Investigate automatically discovering the tests. | ||
tests :: IO TestTree | ||
tests = do | ||
testGroup "All Golden Dir Tests" | ||
tests = | ||
testGroup "Snapshot Tests" | ||
FranjoMindek marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<$> mapM | ||
runGoldenTest | ||
[ waspNew, | ||
waspCompile, | ||
waspMigrate, | ||
waspBuild, | ||
waspJob, | ||
waspComplexTest | ||
runSnapshotTest | ||
[ waspNewSnapshotTest, | ||
waspCompileSnapshotTest, | ||
waspBuildSnapshotTest, | ||
waspMigrateSnapshotTest, | ||
kitchenSinkSnapshotTest | ||
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# End-to-End tests for `waspc` | ||
|
||
The purpose of these `e2e-tests` is to verify the functionality of the **`waspc` binary**. | ||
We are not concerned with the internal implementation of the binary, only its interface and outputs. | ||
|
||
## More on purpose | ||
|
||
**Interface** is exposed through the Wasp CLI. We want to test the behavior of all of the Wasp CLI commands. These tests test behavior at the command level, rather than the internal implementation details. | ||
|
||
The main **outputs** of the `waspc` binary are Wasp applications. We want to validate that CLI commands correctly generate or modify applications in line with expectations. | ||
In addition to applications, we also cover secondary outputs, such as the installation and uninstallation of the CLI itself, `bash` completions, and more. | ||
|
||
## Snapshot tests | ||
|
||
We primarily test the `waspc` binary outputs using snapshot tests. | ||
Snapshot tests compare the current test outputs (`current` snapshot) against the expected test outputs (`golden` snapshot). | ||
|
||
Snapshots are compared in two ways: | ||
|
||
1. **By existence**: a file must exists in both the `current` and the `golden` snapshot. | ||
2. **By content**: the file contents must be identical in both the `current` and the `golden` snapshot. | ||
|
||
For more details, check out the `waspc/e2e-tests/SnapshotTest.hs` file. | ||
|
||
Snapshots are saved in the `waspc/e2e-tests/snapshots/` directory. | ||
While the exact files within a snapshot aren’t strictly defined, they usually have the following structure: | ||
|
||
```yaml | ||
# Where: | ||
# `<name>` = the snapshot test's name. | ||
# `<snapshot-type>` = `current` or `golden`. | ||
|
||
e2e-tests/ | ||
└── snapshots/ | ||
└── <name>-<snapshot-type>/ # snapshot dirctory, e.g. `wasp-build-current`, `wasp-build-golden` | ||
├── wasp-app/ | ||
Martinsos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
└── snapshot-file-list.manifest | ||
``` | ||
|
||
`wasp-app` contains the Wasp app for that snapshot. | ||
`snapshot-file-list.manifest` lists the files that should exist in the snapshot directory. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.