diff --git a/e2e/tests-dfx/assetscanister.bash b/e2e/tests-dfx/assetscanister.bash index 93e78bab35..d5af8d162f 100644 --- a/e2e/tests-dfx/assetscanister.bash +++ b/e2e/tests-dfx/assetscanister.bash @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/e2e/tests-dfx/error_diagnosis.bash b/e2e/tests-dfx/error_diagnosis.bash index 92f76177f7..cf3bf1ce8d 100644 --- a/e2e/tests-dfx/error_diagnosis.bash +++ b/e2e/tests-dfx/error_diagnosis.bash @@ -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 diff --git a/e2e/tests-dfx/frontend.bash b/e2e/tests-dfx/frontend.bash index a4cf0c601d..e50a510997 100644 --- a/e2e/tests-dfx/frontend.bash +++ b/e2e/tests-dfx/frontend.bash @@ -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 @@ -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 @@ -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" } diff --git a/e2e/tests-icx-asset/icx-asset.bash b/e2e/tests-icx-asset/icx-asset.bash index 786887aea2..f06b1d20b6 100644 --- a/e2e/tests-icx-asset/icx-asset.bash +++ b/e2e/tests-icx-asset/icx-asset.bash @@ -11,7 +11,7 @@ setup() { standard_setup - dfx_new_frontend + dfx_new_assets dfx_start assert_command dfx deploy diff --git a/src/dfx/assets/project_templates/svelte/src/__project_name___frontend/src/app.html b/src/dfx/assets/project_templates/svelte/src/__project_name___frontend/src/app.html index 6a8aed0e25..dfae06cc73 100644 --- a/src/dfx/assets/project_templates/svelte/src/__project_name___frontend/src/app.html +++ b/src/dfx/assets/project_templates/svelte/src/__project_name___frontend/src/app.html @@ -5,6 +5,7 @@ + IC Hello Starter %sveltekit.head% diff --git a/src/dfx/assets/project_templates/vanilla_js/src/__project_name___frontend/index.html b/src/dfx/assets/project_templates/vanilla_js/src/__project_name___frontend/index.html index 03d5d91e4b..6c1db68a54 100644 --- a/src/dfx/assets/project_templates/vanilla_js/src/__project_name___frontend/index.html +++ b/src/dfx/assets/project_templates/vanilla_js/src/__project_name___frontend/index.html @@ -5,7 +5,7 @@ - Vite + JS + Motoko + IC Hello Starter diff --git a/src/dfx/assets/project_templates/vanilla_js_tests/src/__project_name___frontend/vite.config.js.patch b/src/dfx/assets/project_templates/vanilla_js_tests/src/__project_name___frontend/vite.config.js.patch index 71bbe6e1ca..dce9050f78 100644 --- a/src/dfx/assets/project_templates/vanilla_js_tests/src/__project_name___frontend/vite.config.js.patch +++ b/src/dfx/assets/project_templates/vanilla_js_tests/src/__project_name___frontend/vite.config.js.patch @@ -3,9 +3,9 @@ @@ -1,1 +1,2 @@ +/// import { defineConfig } from 'vite'; -@@ -34,1 +34,5 @@ +@@ -32,1 +32,5 @@ + test: { + environment: 'jsdom', -+ setupFiles: 'setupTests.js', ++ setupFiles: 'src/setupTests.js', + }, resolve: { diff --git a/src/dfx/assets/project_templates/vue/src/__project_name___frontend/index.html b/src/dfx/assets/project_templates/vue/src/__project_name___frontend/index.html index afa1fecbba..6e80f94528 100644 --- a/src/dfx/assets/project_templates/vue/src/__project_name___frontend/index.html +++ b/src/dfx/assets/project_templates/vue/src/__project_name___frontend/index.html @@ -6,7 +6,7 @@ - Vue Hello IC + IC Hello Starter