Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamspofford-dfinity committed Jan 12, 2024
1 parent 610a97e commit 92933e0
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 27 deletions.
4 changes: 4 additions & 0 deletions e2e/tests-dfx/assetscanister.bash
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ check_permission_failure() {
PREPARE_PRINCIPAL=$(dfx identity get-principal --identity prepare)
COMMIT_PRINCIPAL=$(dfx identity get-principal --identity commit)

rm src/e2e_project_frontend/assets/.ic-assets.json5
install_asset assetscanister
# Prep for a DeleteAsset operation
echo "to-be-deleted" >src/e2e_project_frontend/assets/to-be-deleted.txt
Expand Down Expand Up @@ -196,6 +197,7 @@ check_permission_failure() {
PREPARE_PRINCIPAL=$(dfx identity get-principal --identity prepare)
COMMIT_PRINCIPAL=$(dfx identity get-principal --identity commit)

rm src/e2e_project_frontend/assets/.ic-assets.json5
install_asset assetscanister
dfx_start
mkdir tmp
Expand Down Expand Up @@ -1622,6 +1624,7 @@ WARN: {
}

@test "asset configuration via .ic-assets.json5 - pretty printing when deploying" {
rm src/e2e_project_frontend/assets/.ic-assets.json5
install_asset assetscanister

dfx_start
Expand Down Expand Up @@ -1664,6 +1667,7 @@ WARN: {
}

@test "syncs asset properties when redeploying" {
rm src/e2e_project_frontend/assets/.ic-assets.json5
install_asset assetscanister
dfx_start
assert_command dfx deploy
Expand Down
14 changes: 0 additions & 14 deletions e2e/tests-dfx/error_diagnosis.bash
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,6 @@ teardown() {
standard_teardown
}

@test "Duplicate assets in dist/ from src/" {
dfx_new_frontend hello
install_asset greet
dfx_start
assert_command dfx deploy

# simulate previous deploy with CopyPlugin step
cp src/hello_frontend/assets/* src/hello_frontend/dist

assert_command_fail dfx deploy
assert_contains "Remove the CopyPlugin step from webpack.config.js"
assert_contains "Delete all files from the dist/ directory"
}

@test "HTTP 403 has a full diagnosis" {
dfx_new hello
install_asset greet
Expand Down
16 changes: 8 additions & 8 deletions e2e/tests-dfx/frontend.bash
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ teardown() {
assert_match "Connection refused"
}

@test "dfx uses .ic-assets.json file provided in src/__project_name__frontend/src" {
echo '[{"match": "*", "headers": {"x-key": "x-value"}}]' > src/e2e_project_frontend/src/.ic-assets.json
@test "dfx uses .ic-assets.json file provided in src/__project_name__frontend/assets" {
echo '[{"match": "*", "headers": {"x-key": "x-value"}}]' > src/e2e_project_frontend/assets/.ic-assets.json5

dfx_start
dfx canister create --all
Expand All @@ -77,14 +77,14 @@ teardown() {
PORT=$(get_webserver_port)
assert_command curl -vv http://localhost:"$PORT"/?canisterId="$ID"
assert_match "< x-key: x-value"
assert_command curl -vv http://localhost:"$PORT"/index.js?canisterId="$ID"
assert_command curl -vv http://localhost:"$PORT"/favicon.ico?canisterId="$ID"
assert_match "< x-key: x-value"
}

@test "dfx uses a custom build command if one is provided" {
jq '.canisters.e2e_project_frontend.source = ["dist/e2e_project_frontend/"]' dfx.json | sponge dfx.json
jq '.canisters.e2e_project_frontend.build = ["npm run custom-build"]' dfx.json | sponge dfx.json
jq '.scripts["custom-build"] = "mkdir -p ./dist/e2e_project_frontend/assets/ && cp -r ./src/e2e_project_frontend/assets/* ./dist/e2e_project_frontend"' package.json | sponge package.json
jq '.canisters.e2e_project_frontend.source = ["src/e2e_project_frontend/dist2"]' dfx.json | sponge dfx.json
jq '.canisters.e2e_project_frontend.build = ["npm run custom-build --workspace e2e_project_frontend"]' dfx.json | sponge dfx.json
jq '.scripts["custom-build"] = "npm run build && mkdir -p ./dist2/ && cp -r ./dist/* ./dist2"' src/e2e_project_frontend/package.json | sponge src/e2e_project_frontend/package.json

dfx_start
dfx canister create --all
Expand All @@ -94,6 +94,6 @@ teardown() {
ID=$(dfx canister id e2e_project_frontend)
PORT=$(get_webserver_port)

assert_command curl -vv http://localhost:"$PORT"/sample-asset.txt?canisterId="$ID"
assert_match "This is a sample asset!"
assert_command curl -vv http://localhost:"$PORT"/index.html?canisterId="$ID"
assert_match "IC Hello Starter"
}
2 changes: 1 addition & 1 deletion e2e/tests-icx-asset/icx-asset.bash
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ setup() {

standard_setup

dfx_new_frontend
dfx_new_assets
dfx_start

assert_command dfx deploy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.ico" />
<meta name="viewport" content="width=device-width" />
<title>IC Hello Starter</title>
%sveltekit.head%
</head>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + JS + Motoko</title>
<title>IC Hello Starter</title>
</head>

<body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
@@ -1,1 +1,2 @@
+/// <reference types="vitest" />
import { defineConfig } from 'vite';
@@ -34,1 +34,5 @@
@@ -32,1 +32,5 @@
+ test: {
+ environment: 'jsdom',
+ setupFiles: 'setupTests.js',
+ setupFiles: 'src/setupTests.js',
+ },
resolve: {
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<link rel="icon" href="/favicon.ico" />
<title>Vue Hello IC</title>
<title>IC Hello Starter</title>
</head>

<body>
Expand Down

0 comments on commit 92933e0

Please sign in to comment.