diff --git a/.github/workflows/check-e2e.yml b/.github/workflows/check-e2e.yml index 322e3180e..205595720 100644 --- a/.github/workflows/check-e2e.yml +++ b/.github/workflows/check-e2e.yml @@ -14,8 +14,8 @@ jobs: matrix: # Disable firefox until this is fixed upstream: # https://github.com/microsoft/playwright/issues/21145 - # browser: [chromium, firefox, visual, heartwood] - browser: [chromium, visual, heartwood] + # browser: [chromium, firefox, visual] + browser: [chromium, visual] timeout-minutes: 30 runs-on: ubuntu-latest steps: @@ -59,19 +59,13 @@ jobs: - name: Start http-api test server run: | - if [ ${{ matrix.browser }} = "heartwood" ]; then - mkdir -p tests/artifacts - ./scripts/run-httpd-with-fixtures --non-interactive --download 2>&1 | tee tests/artifacts/httpd-${{ matrix.browser }}.log & - else - ./scripts/run-http-api-with-fixtures --non-interactive --detach - fi + mkdir -p tests/artifacts; + ./scripts/run-httpd-with-fixtures --non-interactive --download 2>&1 | tee tests/artifacts/httpd-${{ matrix.browser }}.log & - name: Run Playwright tests run: | if [ ${{ matrix.browser }} = "visual" ] && [ ${{ github.ref }} = "refs/heads/master" ]; then npm run test:e2e -- --project ${{ matrix.browser }} --update-snapshots; - elif [ ${{ matrix.browser }} = "heartwood" ]; then - HEARTWOOD=true npm run test:e2e -- --project chromium; else npm run test:e2e -- --project ${{ matrix.browser }}; fi diff --git a/scripts/create-seed-fixture b/scripts/create-seed-fixture index 15c58a224..376dd1b48 100755 --- a/scripts/create-seed-fixture +++ b/scripts/create-seed-fixture @@ -1,30 +1,29 @@ #!/usr/bin/env bash + +killall radicle-node +killall git-daemon + set -euo pipefail -function cleanup { - docker kill radicle-git-server-test -} -trap cleanup EXIT - - -PASSPHRASE=asdf -REV=40bdc662b2d48cbfaa87182b21457ef8f861b04a +export RAD_PASSPHRASE=asdf REPO_ROOT=$(git rev-parse --show-toplevel) -ID=$(echo $RANDOM | md5sum | head -c 8) -BASE_PATH=$REPO_ROOT/tests/tmp/create-seed-fixture-$ID +ID=$(echo $RANDOM | md5sum | head -c 4) +BASE_PATH=$REPO_ROOT/tests/tmp/seed-fixture-$ID TEST_REPO_ARCHIVE=$REPO_ROOT/tests/fixtures/repos/source-browsing.tar.bz2 TEST_REPO_NAME=source-browsing TEST_REPO_PATH=$BASE_PATH/repos/$TEST_REPO_NAME PALM_RAD_HOME=$BASE_PATH/seeds/palm +PALM_CHECKOUT=$BASE_PATH/checkout/palm ALICE_RAD_HOME=$BASE_PATH/peers/alice ALICE_CHECKOUT=$BASE_PATH/checkout/alice BOB_RAD_HOME=$BASE_PATH/peers/bob BOB_CHECKOUT=$BASE_PATH/checkout/bob mkdir -p $PALM_RAD_HOME +mkdir -p $PALM_CHECKOUT mkdir -p $ALICE_RAD_HOME mkdir -p $ALICE_CHECKOUT mkdir -p $BOB_RAD_HOME @@ -33,62 +32,89 @@ mkdir -p $TEST_REPO_PATH tar -xf $TEST_REPO_ARCHIVE -C $TEST_REPO_PATH -RAD_HOME=$PALM_RAD_HOME rad auth --init --name palm --passphrase $PASSPHRASE +### PALM NODE ### -docker run \ - --detach \ - --init \ - --publish 8778:8778 \ - --rm \ - --env RAD_HOME=/app/radicle \ - --name radicle-git-server-test \ - --volume $PALM_RAD_HOME:/app/radicle \ - "gcr.io/radicle-services/git-server:$REV" \ - --passphrase $PASSPHRASE \ - --allow-unauthorized-keys +eval $(ssh-agent) -# git-server takes a while to copy commit hooks to the monorepo -sleep 10 +export RAD_HOME=$PALM_RAD_HOME +export RAD_SEED=ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffee -GIT_AUTHOR_NAME="Alice Liddell" -GIT_AUTHOR_EMAIL="alice@radicle.xyz" -GIT_COMMITTER_NAME="Alice Liddell" -GIT_COMMITTER_EMAIL="alice@radicle.xyz" +rad auth +radicle-node --listen 0.0.0.0:3446 --git-daemon 0.0.0.0:4446 & -RAD_HOME=$ALICE_RAD_HOME rad auth --init --name alice --passphrase $PASSPHRASE +### ALICE ### + +export RAD_HOME=$ALICE_RAD_HOME +export RAD_SEED=ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + +export GIT_AUTHOR_NAME="Alice Liddell" +export GIT_AUTHOR_EMAIL="alice@radicle.xyz" +export GIT_COMMITTER_NAME="Alice Liddell" +export GIT_COMMITTER_EMAIL="alice@radicle.xyz" + +rad auth cd $ALICE_CHECKOUT git clone $TEST_REPO_PATH cd $TEST_REPO_NAME -git checkout feature/branch -git checkout orphaned-branch + git checkout main +rad init --name "source-browsing" \ + --description "Git repository for source browsing tests" \ + --default-branch "main" \ + --no-confirm -RAD_HOME=$ALICE_RAD_HOME rad init --name "source-browsing" --description "Git repository for source browsing tests" --default-branch "main" --no-confirm +git checkout feature/branch +git push rad -sleep 10 -RAD_HOME=$ALICE_RAD_HOME rad push --seed 0.0.0.0:8778 --all --sync -PROJECT_ID=$(rad .) +git checkout orphaned-branch +git push rad +radicle-node --listen 0.0.0.0:3444 --git-daemon 0.0.0.0:4444 \ + --connect z6Mkk7oqY4pPxhMmGEotDYsFo97vhCj85BLY1H256HrJmjN8@0.0.0.0:3446 & -GIT_AUTHOR_NAME="Bob Belcher" -GIT_AUTHOR_EMAIL="bob@radicle.xyz" -GIT_COMMITTER_NAME="Bob Belcher" -GIT_COMMITTER_EMAIL="bob@radicle.xyz" +sleep 1 -RAD_HOME=$BOB_RAD_HOME rad auth --init --name bob --passphrase $PASSPHRASE +### PALM CLONE ### + +cd $PALM_CHECKOUT +export RAD_HOME=$PALM_RAD_HOME +rad clone rad:zKtT7DmF9H34KkvcKj9PHW19WzjT + +### BOB ### + +export GIT_AUTHOR_NAME="Bob Belcher" +export GIT_AUTHOR_EMAIL="bob@radicle.xyz" +export GIT_COMMITTER_NAME="Bob Belcher" +export GIT_COMMITTER_EMAIL="bob@radicle.xyz" +export GIT_COMMITTER_DATE="Mon Dec 21 14:00 2022 +0100" + +export RAD_HOME=$BOB_RAD_HOME +export RAD_SEED=fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe + +rad auth +rad auth +radicle-node --listen 0.0.0.0:3445 --git-daemon 0.0.0.0:4445 \ + --connect z6Mkk7oqY4pPxhMmGEotDYsFo97vhCj85BLY1H256HrJmjN8@0.0.0.0:3446 & + +sleep 2 cd $BOB_CHECKOUT -RAD_HOME=$BOB_RAD_HOME rad clone $PROJECT_ID --seed 0.0.0.0:8778 --no-confirm +rad clone rad:zKtT7DmF9H34KkvcKj9PHW19WzjT cd $TEST_REPO_NAME echo "Updated readme" > README.md git add README.md -git commit --message "Update readme" --date "Mon Nov 21 14:00 2022 +0100" -RAD_HOME=$BOB_RAD_HOME rad push --seed 0.0.0.0:8778 -RAD_HOME=$BOB_RAD_HOME rad sync --seed 0.0.0.0:8778 --self -RAD_HOME=$BOB_RAD_HOME rad sync --seed 0.0.0.0:8778 +git commit --message "Update readme" --date "$GIT_COMMITTER_DATE" +git push rad + +### WAIT FOR SYNC WITH PALM ### + +sleep 2 cd $BASE_PATH tar -cjf palm.tar.bz2 --exclude "post-receive" --exclude "pre-receive" -C $PALM_RAD_HOME . + +killall radicle-node +killall git-daemon diff --git a/scripts/create-seed-fixture-heartwood b/scripts/create-seed-fixture-heartwood deleted file mode 100755 index 45bd91869..000000000 --- a/scripts/create-seed-fixture-heartwood +++ /dev/null @@ -1,120 +0,0 @@ -#!/usr/bin/env bash - -killall radicle-node -killall git-daemon - -set -euo pipefail - -export RAD_PASSPHRASE=asdf - -REPO_ROOT=$(git rev-parse --show-toplevel) -ID=$(echo $RANDOM | md5sum | head -c 4) -BASE_PATH=$REPO_ROOT/tests/tmp/heartwood-$ID - -TEST_REPO_ARCHIVE=$REPO_ROOT/tests/fixtures/repos/source-browsing.tar.bz2 -TEST_REPO_NAME=source-browsing -TEST_REPO_PATH=$BASE_PATH/repos/$TEST_REPO_NAME - -PALM_RAD_HOME=$BASE_PATH/seeds/palm -PALM_CHECKOUT=$BASE_PATH/checkout/palm -ALICE_RAD_HOME=$BASE_PATH/peers/alice -ALICE_CHECKOUT=$BASE_PATH/checkout/alice -BOB_RAD_HOME=$BASE_PATH/peers/bob -BOB_CHECKOUT=$BASE_PATH/checkout/bob - -mkdir -p $PALM_RAD_HOME -mkdir -p $PALM_CHECKOUT -mkdir -p $ALICE_RAD_HOME -mkdir -p $ALICE_CHECKOUT -mkdir -p $BOB_RAD_HOME -mkdir -p $BOB_CHECKOUT -mkdir -p $TEST_REPO_PATH - -tar -xf $TEST_REPO_ARCHIVE -C $TEST_REPO_PATH - -### PALM NODE ### - -eval $(ssh-agent) - -export RAD_HOME=$PALM_RAD_HOME -export RAD_SEED=ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffee - -rad auth -radicle-node --listen 0.0.0.0:3446 --git-daemon 0.0.0.0:4446 & - -### ALICE ### - -export RAD_HOME=$ALICE_RAD_HOME -export RAD_SEED=ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff - -export GIT_AUTHOR_NAME="Alice Liddell" -export GIT_AUTHOR_EMAIL="alice@radicle.xyz" -export GIT_COMMITTER_NAME="Alice Liddell" -export GIT_COMMITTER_EMAIL="alice@radicle.xyz" - -rad auth - -cd $ALICE_CHECKOUT - -git clone $TEST_REPO_PATH -cd $TEST_REPO_NAME - -git checkout main -rad init --name "source-browsing" \ - --description "Git repository for source browsing tests" \ - --default-branch "main" \ - --no-confirm - -git checkout feature/branch -git push rad - -git checkout orphaned-branch -git push rad - -radicle-node --listen 0.0.0.0:3444 --git-daemon 0.0.0.0:4444 \ - --connect z6Mkk7oqY4pPxhMmGEotDYsFo97vhCj85BLY1H256HrJmjN8@0.0.0.0:3446 & - -sleep 1 - -### PALM CLONE ### - -cd $PALM_CHECKOUT -export RAD_HOME=$PALM_RAD_HOME -rad clone rad:zKtT7DmF9H34KkvcKj9PHW19WzjT - -### BOB ### - -export GIT_AUTHOR_NAME="Bob Belcher" -export GIT_AUTHOR_EMAIL="bob@radicle.xyz" -export GIT_COMMITTER_NAME="Bob Belcher" -export GIT_COMMITTER_EMAIL="bob@radicle.xyz" -export GIT_COMMITTER_DATE="Mon Dec 21 14:00 2022 +0100" - -export RAD_HOME=$BOB_RAD_HOME -export RAD_SEED=fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe - -rad auth -rad auth -radicle-node --listen 0.0.0.0:3445 --git-daemon 0.0.0.0:4445 \ - --connect z6Mkk7oqY4pPxhMmGEotDYsFo97vhCj85BLY1H256HrJmjN8@0.0.0.0:3446 & - -sleep 2 - -cd $BOB_CHECKOUT -rad clone rad:zKtT7DmF9H34KkvcKj9PHW19WzjT - -cd $TEST_REPO_NAME -echo "Updated readme" > README.md -git add README.md -git commit --message "Update readme" --date "$GIT_COMMITTER_DATE" -git push rad - -### WAIT FOR SYNC WITH PALM ### - -sleep 2 - -cd $BASE_PATH -tar -cjf palm.tar.bz2 --exclude "post-receive" --exclude "pre-receive" -C $PALM_RAD_HOME . - -killall radicle-node -killall git-daemon diff --git a/scripts/run-http-api-with-fixtures b/scripts/run-http-api-with-fixtures deleted file mode 100755 index 461d2fff1..000000000 --- a/scripts/run-http-api-with-fixtures +++ /dev/null @@ -1,128 +0,0 @@ -#!/bin/sh -set -e - -REV=40bdc662b2d48cbfaa87182b21457ef8f861b04a - -REPO_ROOT=$(git rev-parse --show-toplevel) -FIXTURE=$REPO_ROOT/tests/fixtures/seeds/palm.tar.bz2 -WORKSPACE=$REPO_ROOT/tests/tmp/palm -PASSPHRASE=asdf -CONTAINER_NAME=radicle-http-api-with-fixtures -HTTP_API_BINARY=radicle-http-api - -show_usage() { - echo - echo "Starts a http-api backend with test fixtures." - echo - echo "USAGE:" - echo " run-http-api-with-fixtures [-b|d|h|n]" - echo - echo "OPTIONS:" - echo " -b --binary Use a ${HTTP_API_BINARY} binary that is in PATH to avoid using Docker." - echo " -d --detach Daemonize the docker process." - echo " -h --help Print this Help." - echo " -n --non-interactive Run in non-interactive mode, no user prompts." - echo -} - -prompt_workspace_removal() { - echo "This will irrevocably destroy the following directories:" - echo - echo $WORKSPACE - echo - - read -r -p "Are you sure you want to continue? [yes/no]: " confirm - case "$confirm" in - [yY][eE][sS]) - rm -rf $WORKSPACE - echo "Done" - ;; - *) - echo "Ok, I won't touch your data." - exit - ;; - esac -} - -prepare_workspace() { - echo - echo "Unpacking fixture $FIXTURE" - mkdir -p $WORKSPACE - tar -xf $FIXTURE -C $WORKSPACE -} - -run_docker() { - echo "Starting docker at container $CONTAINER_NAME at $REV" - echo " http-api --root $WORKSPACE --passphrase $PASSPHRASE" - echo - - exec docker run \ - --init \ - --publish 8777:8777 \ - --rm \ - --name $CONTAINER_NAME \ - --volume $WORKSPACE:/app/radicle \ - "$@" \ - "gcr.io/radicle-services/http-api:$REV" \ - --passphrase $PASSPHRASE -} - -run_binary() { - if ! [ -x "$(command -v $HTTP_API_BINARY)" ]; then - echo - echo "Couldn't find the $HTTP_API_BINARY binary in your PATH." - echo "You can compile it from source:" - echo " πŸ‘‰ https://github.com/radicle-dev/radicle-client-services/tree/${REV}/http-api" - echo - exit 1 - fi - - echo - echo "Starting $HTTP_API_BINARY" - echo " $HTTP_API_BINARY --listen 0.0.0.0:8777 --root ${WORKSPACE} --passphrase $PASSPHRASE" - echo - - $HTTP_API_BINARY --listen 0.0.0.0:8777 --root $WORKSPACE --passphrase $PASSPHRASE -} - -BINARY=false -NON_INTERACTIVE=false -DETACH=false - -while [ $# -ne 0 ]; do - case "$1" in - --binary | -b) - BINARY=true - ;; - --detach | -d) - DETACH=true - ;; - --non-interactive | -n) - NON_INTERACTIVE=true - ;; - *) - show_usage - exit - ;; - esac - - shift -done - -if [ "$NON_INTERACTIVE" = true ]; then - rm -rf $WORKSPACE - prepare_workspace -else - prompt_workspace_removal - prepare_workspace -fi - -if [ "$BINARY" = true ]; then - run_binary -else - if [ "$DETACH" = true ]; then - run_docker --detach - else - run_docker - fi -fi diff --git a/scripts/run-httpd-with-fixtures b/scripts/run-httpd-with-fixtures index fb92549bc..c6804cf66 100755 --- a/scripts/run-httpd-with-fixtures +++ b/scripts/run-httpd-with-fixtures @@ -4,7 +4,7 @@ set -e REV=f1de61ad8897a845f2be49e3e2b2951bc678b678 REPO_ROOT=$(git rev-parse --show-toplevel) -FIXTURE=$REPO_ROOT/tests/fixtures/seeds/palm-heartwood.tar.bz2 +FIXTURE=$REPO_ROOT/tests/fixtures/seeds/palm.tar.bz2 WORKSPACE=$REPO_ROOT/tests/tmp/palm PASSPHRASE=asdf BINARY_PATH="$REPO_ROOT/tests/tmp" diff --git a/src/App.svelte b/src/App.svelte index 7a55b0e79..2116ccb16 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -13,7 +13,7 @@ import Home from "@app/views/home/Index.svelte"; import Session from "@app/views/session/Index.svelte"; import Projects from "@app/views/projects/View.svelte"; - import Seeds from "@app/views/seeds/Routes.svelte"; + import Seeds from "@app/views/seeds/View.svelte"; const activeRouteStore = router.activeRouteStore; @@ -60,7 +60,7 @@ {#if $activeRouteStore.resource === "home"} {:else if $activeRouteStore.resource === "seeds"} - + {:else if $activeRouteStore.resource === "session"} {:else if $activeRouteStore.resource === "projects"} diff --git a/src/App/Header/Connect.svelte b/src/App/Header/Connect.svelte index 32a190ea9..eb30cabae 100644 --- a/src/App/Header/Connect.svelte +++ b/src/App/Header/Connect.svelte @@ -3,17 +3,13 @@ import { closeFocused } from "@app/components/Floating.svelte"; import { sessionStore, disconnect } from "@app/lib/session"; - import { toClipboard } from "@app/lib/utils"; + import { toClipboard, formatNodeId } from "@app/lib/utils"; import Avatar from "@app/components/Comment/Avatar.svelte"; import Button from "@app/components/Button.svelte"; import Floating from "@app/components/Floating.svelte"; import Icon from "@app/components/Icon.svelte"; - function formatId(id: string) { - return id.substring(0, 4) + " – " + id.substring(id.length - 4, id.length); - } - let icon: "clipboard-small" | "checkmark-small" = "clipboard-small"; const restoreIcon = debounce(() => { @@ -43,7 +39,7 @@ position: absolute; right: 5rem; top: 5rem; - width: 16.5rem; + width: 15rem; } .info { align-items: flex-start; @@ -118,7 +114,6 @@ font-family: var(--font-family-monospace); font-size: var(--font-size-tiny); user-select: none; - width: 11rem; word-break: break-all; } .disconnect { @@ -171,7 +166,7 @@ title={$sessionStore.publicKey} />
- {formatId($sessionStore.publicKey)} + {formatNodeId($sessionStore.publicKey)}
{:else} @@ -214,7 +209,7 @@ } }}>
- {$sessionStore.publicKey} + {formatNodeId($sessionStore.publicKey)}
diff --git a/src/App/Header/SearchResultsModal.svelte b/src/App/Header/SearchResultsModal.svelte index b8f775cf9..0b1ab2079 100644 --- a/src/App/Header/SearchResultsModal.svelte +++ b/src/App/Header/SearchResultsModal.svelte @@ -4,7 +4,7 @@ import * as modal from "@app/lib/modal"; import Link from "@app/components/Link.svelte"; import Modal from "@app/components/Modal.svelte"; - import { formatRadicleId, getSeedEmoji } from "@app/lib/utils"; + import { formatRepositoryId, getSeedEmoji } from "@app/lib/utils"; export let query: string; export let results: ProjectResult[]; @@ -48,7 +48,7 @@ {getSeedEmoji(project.seed.host)} {project.info.name} -  {formatRadicleId(project.info.id)} +  {formatRepositoryId(project.info.id)} diff --git a/src/components/Authorship.svelte b/src/components/Authorship.svelte index 7905883ee..1a4df24ab 100644 --- a/src/components/Authorship.svelte +++ b/src/components/Authorship.svelte @@ -1,11 +1,7 @@ - -
-
-
-
- - {patch.title} - - {patch.id} - - {formatObjectId(patch.id)} - -
-
- {capitalize(patch.state)} -
-
- -
- - - -
- {#if activeTab === PatchTab.Timeline} -
- - -
- {:else if activeTab === PatchTab.Diff && revision.changeset} - onBrowse(e, revision.oid)} /> - {:else if activeTab === PatchTab.Diff} - - No changeset found - - We couldn't find a changeset related to this patch or revision - - - {/if} -
-
diff --git a/src/views/projects/Patch/PatchSideBar.svelte b/src/views/projects/Patch/PatchSideBar.svelte deleted file mode 100644 index 9e9ded115..000000000 --- a/src/views/projects/Patch/PatchSideBar.svelte +++ /dev/null @@ -1,54 +0,0 @@ - - - - - diff --git a/src/views/projects/Patch/PatchTabBar.svelte b/src/views/projects/Patch/PatchTabBar.svelte deleted file mode 100644 index bd7e1f715..000000000 --- a/src/views/projects/Patch/PatchTabBar.svelte +++ /dev/null @@ -1,102 +0,0 @@ - - - - -
- { - dispatch("switchTab", e.detail); - }} - active={activeTab} /> - - - - - - - - -
diff --git a/src/views/projects/Patch/PatchTeaser.svelte b/src/views/projects/Patch/PatchTeaser.svelte deleted file mode 100644 index 07955430a..000000000 --- a/src/views/projects/Patch/PatchTeaser.svelte +++ /dev/null @@ -1,114 +0,0 @@ - - - - -
-
-
-
-
-
- - {patch.title} - {formatObjectId(patch.id)} -
- -
- {#if commentCount > 0} -
-
- πŸ’¬ - {commentCount} -
-
- {/if} -
diff --git a/src/views/projects/Patch/PatchTimeline.svelte b/src/views/projects/Patch/PatchTimeline.svelte deleted file mode 100644 index b54414995..000000000 --- a/src/views/projects/Patch/PatchTimeline.svelte +++ /dev/null @@ -1,73 +0,0 @@ - - - - -
- {#each timeline as element} - {#if element.type === TimelineType.Merge && element.inner.peer.person} -
- -
- {:else if element.type === TimelineType.Review && element.inner.author.id} -
- -
- {:else if element.type === TimelineType.Comment} -
- - {#key element.inner} - - {/key} -
- {:else if element.type === TimelineType.Thread} -
- - {#if !window.HEARTWOOD} -
- {#each element.inner.replies as comment} - - {/each} -
- {/if} -
- {/if} - {/each} -
diff --git a/src/views/projects/Patch/Review.svelte b/src/views/projects/Patch/Review.svelte deleted file mode 100644 index b635d872c..000000000 --- a/src/views/projects/Patch/Review.svelte +++ /dev/null @@ -1,31 +0,0 @@ - - - - -{#if review.comment.body} - -{:else} -
- -
-{/if} diff --git a/src/views/projects/Patches.svelte b/src/views/projects/Patches.svelte deleted file mode 100644 index a1b559a34..000000000 --- a/src/views/projects/Patches.svelte +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - -
-
- - router.updateProjectRoute({ - search: `state=${e.detail}`, - })} - active={state} /> -
- - {#if filteredPatches.length} -
- {#each filteredPatches as patch} - -
{ - router.updateProjectRoute({ - view: { resource: "patch", params: { patch: patch.id } }, - }); - }}> - -
- {/each} -
- {:else} - -
{capitalize(state)} patches
-
No patches matched the current filter
-
- {/if} -
diff --git a/src/views/projects/PeerSelector.svelte b/src/views/projects/PeerSelector.svelte index 0a1c2a609..82eef4700 100644 --- a/src/views/projects/PeerSelector.svelte +++ b/src/views/projects/PeerSelector.svelte @@ -21,24 +21,17 @@ }[] = []; function createTitle(p: Peer): string { - const name = p.person?.name ? p.person.name : p.id; + const nodeId = formatNodeId(p.id); return p.delegate - ? `${name} is a delegate of this project` - : `${name} is a peer tracked by this seed`; + ? `${nodeId} is a delegate of this project` + : `${nodeId} is a peer tracked by this node`; } onMount(() => { meta = peers.find(p => p.id === peer); items = peers.map(p => { - if (!p.person?.name) { - console.debug("Not able to resolve peer identity for: ", p.id); - } - const key = p.person?.name - ? `${p.person.name} ${p.id}` - : p.id; - return { - key, + key: formatNodeId(p.id), value: p.id, title: createTitle(p), badge: p.delegate ? "delegate" : null, @@ -91,7 +84,7 @@ {#if meta} - {meta.person?.name ?? formatNodeId(meta.id)} + {formatNodeId(meta.id)} {#if meta.delegate} delegate diff --git a/src/views/projects/ProjectMeta.svelte b/src/views/projects/ProjectMeta.svelte index bbfe3c574..351fc30ed 100644 --- a/src/views/projects/ProjectMeta.svelte +++ b/src/views/projects/ProjectMeta.svelte @@ -1,13 +1,13 @@ {#each tree.entries as entry (entry.path)} - {#if window.HEARTWOOD ? entry.kind === "tree" : entry.info.objectType === "TREE"} + {#if entry.kind === "tree"} @@ -30,7 +30,7 @@ onSelect({ detail: entry.path })} /> {/if} {/each} diff --git a/src/views/projects/Tree/Folder.svelte b/src/views/projects/Tree/Folder.svelte index ca5aa72ef..a36195d53 100644 --- a/src/views/projects/Tree/Folder.svelte +++ b/src/views/projects/Tree/Folder.svelte @@ -74,10 +74,10 @@ {:then tree} {#if tree} {#each tree.entries as entry (entry.path)} - {#if window.HEARTWOOD ? entry.kind === "tree" : entry.info.objectType === "TREE"} + {#if entry.kind === "tree"} { onSelectFile({ detail: entry.path }); }} /> diff --git a/src/views/projects/View.svelte b/src/views/projects/View.svelte index ce2fd6b4b..a3140429c 100644 --- a/src/views/projects/View.svelte +++ b/src/views/projects/View.svelte @@ -1,10 +1,8 @@ - -{#if host === "radicle.local"} - -{:else} - -{/if} diff --git a/src/views/seeds/View.svelte b/src/views/seeds/View.svelte index bedcfbbc2..da8c6ddb8 100644 --- a/src/views/seeds/View.svelte +++ b/src/views/seeds/View.svelte @@ -1,25 +1,27 @@ @@ -81,7 +83,7 @@ {hostName} -{#await Seed.lookup(host, Number(port))} +{#await Seed.lookup(seedHost)}
@@ -99,17 +101,19 @@
Address
- +
Seed ID
- {formatSeedId(seed.id)} + {formatNodeId(seed.id)}
API Port
-
{port}
+
{seed.addr.port}
Version
@@ -133,7 +137,7 @@ {:catch}
{/await} diff --git a/src/views/seeds/View/Projects.svelte b/src/views/seeds/View/Projects.svelte index bf7b95cb3..a6ca6a0a2 100644 --- a/src/views/seeds/View/Projects.svelte +++ b/src/views/seeds/View/Projects.svelte @@ -6,6 +6,7 @@ import * as router from "@app/lib/router"; import List from "@app/components/List.svelte"; import Widget from "@app/views/projects/Widget.svelte"; + import { config } from "@app/lib/config"; export let seed: Seed; export let projects: proj.ProjectInfo[]; @@ -39,9 +40,10 @@ params: { view: { resource: "tree" }, id: project.id, - seed: seed.addr.port - ? `${seed.addr.host}:${seed.addr.port}` - : seed.addr.host, + seed: + seed.addr.port === config.seeds.defaultHttpdPort + ? seed.addr.host + : `${seed.addr.host}:${seed.addr.port}`, revision: project.head ?? undefined, hash: undefined, search: undefined, diff --git a/tests/e2e/clipboard.spec.ts b/tests/e2e/clipboard.spec.ts index 2856a4167..36b68b386 100644 --- a/tests/e2e/clipboard.spec.ts +++ b/tests/e2e/clipboard.spec.ts @@ -3,7 +3,6 @@ import { expect, projectFixtureUrl, rid, - ridPrefix, seedRemote, test, } from "@tests/support/fixtures.js"; @@ -37,33 +36,43 @@ test("copy to clipboard", async ({ page, browserName, context }) => { const clipboardContent = await page.evaluate( "navigator.clipboard.readText()", ); - expect(clipboardContent).toBe(`${ridPrefix}${rid}`); + expect(clipboardContent).toBe(`${rid}`); } // `rad clone` URL. { await page.getByText("Clone").click(); - await page - .locator(`text=rad clone rad://0.0.0.0/${rid.substring(0, 6)}`) - .hover(); + await page.locator(`text=rad clone ${rid.substring(0, 6)}`).hover(); await page .locator(".clone-url-wrapper > span") .first() .locator(".clipboard") .click(); - await expectClipboard(`rad clone rad://0.0.0.0/${rid}`, page); + await expectClipboard(`rad clone ${rid}`, page); } // `git clone` URL. { await page.getByText("Clone").click(); - await page.locator(`text=https://0.0.0.0/${rid.substring(0, 6)}`).hover(); + await page + .locator( + `text=git clone https://0.0.0.0/${rid + .replace("rad:", "") + .substring(0, 10)}`, + ) + .hover(); await page .locator(".clone-url-wrapper > span") .last() .locator(".clipboard") .click(); - await expectClipboard(`https://0.0.0.0/${rid}.git`, page); + await expectClipboard( + `git clone https://0.0.0.0/${rid.replace( + "rad:", + "", + )}.git source-browsing`, + page, + ); } await page.goto("/seeds/radicle.local"); diff --git a/tests/e2e/project.spec.ts b/tests/e2e/project.spec.ts index 0e4859b2c..4b65d8d8d 100644 --- a/tests/e2e/project.spec.ts +++ b/tests/e2e/project.spec.ts @@ -6,7 +6,6 @@ import { expect, projectFixtureUrl, rid, - ridPrefix, test, } from "@tests/support/fixtures.js"; import { expectUrlPersistsReload } from "@tests/support/router"; @@ -29,7 +28,7 @@ test("navigate to project", async ({ page }) => { // Header. { const name = page.locator("text=source-browsing"); - const id = page.locator(`text=${ridPrefix}${rid}`); + const id = page.locator(`text=${rid}`); const description = page.locator( "text=Git repository for source browsing tests", ); @@ -245,10 +244,10 @@ test("clone modal", async ({ page }) => { await page.goto(projectFixtureUrl); await page.getByText("Clone").click(); + await expect(page.locator(`text=rad clone ${rid}`)).toBeVisible(); await expect( - page.locator(`text=rad clone rad://0.0.0.0/${rid}`), + page.locator(`text=https://0.0.0.0/${rid.replace("rad:", "")}.git`), ).toBeVisible(); - await expect(page.locator(`text=https://0.0.0.0/${rid}.git`)).toBeVisible(); }); test("peer and branch switching", async ({ page }) => { @@ -257,18 +256,13 @@ test("peer and branch switching", async ({ page }) => { // Alice's peer. { await page.getByTitle("Change peer").click(); - if (process.env.HEARTWOOD) { - await page.locator(`text=${aliceRemote}`).click(); - await expect(page.getByTitle("Change peer")).toHaveText( - `did:key:${aliceRemote.substring(0, 6)}…${aliceRemote.slice(-6)}`, - ); - } else { - await page.locator("text=alice").click(); - await expect(page.getByTitle("Change peer")).toHaveText("alice delegate"); - } + await page.locator(`text=${aliceRemote.substring(0, 6)}`).click(); + await expect(page.getByTitle("Change peer")).toHaveText( + `did:key:${aliceRemote.substring(0, 6)}…${aliceRemote.slice(-6)}`, + ); await expect( page.locator( - `text=source-browsing / ${aliceRemote.substring( + `text=source-browsing / did:key:${aliceRemote.substring( 0, 6, )}…${aliceRemote.slice(-6)}`, @@ -326,32 +320,19 @@ test("peer and branch switching", async ({ page }) => { // Bob's peer. { await page.getByTitle("Change peer").click(); - if (process.env.HEARTWOOD) { - await page.locator(`text=${bobRemote}`).click(); - await expect(page.getByTitle("Change peer")).toHaveText( - `did:key:${bobRemote.substring(0, 6)}…${bobRemote.slice(-6)}`, - ); - } else { - await page.locator("text=bob").click(); - await expect(page.getByTitle("Change peer")).toHaveText("bob"); - } + await page.locator(`text=${bobRemote.substring(0, 6)}`).click(); + await expect(page.getByTitle("Change peer")).toHaveText( + `did:key:${bobRemote.substring(0, 6)}…${bobRemote.slice(-6)}`, + ); await expect(page.getByTitle("Change peer")).not.toHaveText("delegate"); // Default `main` branch. { - if (process.env.HEARTWOOD) { - await expect(page.getByTitle("Current branch")).toContainText( - "main 1e0bb83", - ); - await expectCounts({ commits: 9, contributors: 2 }, page); - await expect(page.locator("text=1e0bb83 Update readme")).toBeVisible(); - } else { - await expect(page.getByTitle("Current branch")).toContainText( - "main 2b32f6f", - ); - await expectCounts({ commits: 9, contributors: 2 }, page); - await expect(page.locator("text=2b32f6f Update readme")).toBeVisible(); - } + await expect(page.getByTitle("Current branch")).toContainText( + "main 1e0bb83", + ); + await expectCounts({ commits: 9, contributors: 2 }, page); + await expect(page.locator("text=1e0bb83 Update readme")).toBeVisible(); } } }); @@ -360,11 +341,7 @@ test("only one modal can be open at a time", async ({ page }) => { await page.goto(projectFixtureUrl); await page.getByTitle("Change peer").click(); - if (process.env.HEARTWOOD) { - await page.locator(`text=${aliceRemote.substring(0, 6)}`).click(); - } else { - await page.locator(`text=alice ${aliceRemote.substring(0, 6)}`).click(); - } + await page.locator(`text=${aliceRemote.substring(0, 6)}`).click(); await page.getByText("Clone").click(); await expect(page.locator("text=Code font")).not.toBeVisible(); @@ -381,11 +358,7 @@ test("only one modal can be open at a time", async ({ page }) => { await page.getByTitle("Change peer").click(); await expect(page.locator("text=Code font")).not.toBeVisible(); await expect(page.locator("text=Use the Radicle CLI")).not.toBeVisible(); - if (process.env.HEARTWOOD) { - await expect(page.locator(`text=${bobRemote}`)).toBeVisible(); - } else { - await expect(page.locator("text=bob hyyzz9")).toBeVisible(); - } + await expect(page.locator(`text=${bobRemote.substring(0, 6)}`)).toBeVisible(); await expect(page.locator("text=feature/branch")).not.toBeVisible(); await page.locator('button[name="Settings"]').click(); @@ -398,7 +371,7 @@ test("only one modal can be open at a time", async ({ page }) => { test.describe("browser error handling", () => { test("error appears when folder can't be loaded", async ({ page }) => { await page.route( - `**/v1/projects/${ridPrefix}${rid}/tree/${aliceMainHead}/markdown/`, + `**/v1/projects/${rid}/tree/${aliceMainHead}/markdown/`, route => route.fulfill({ status: 500 }), ); @@ -413,7 +386,7 @@ test.describe("browser error handling", () => { }); test("error appears when file can't be loaded", async ({ page }) => { await page.route( - `**/v1/projects/${ridPrefix}${rid}/blob/${aliceMainHead}/.hidden`, + `**/v1/projects/${rid}/blob/${aliceMainHead}/.hidden`, route => route.fulfill({ status: 500 }), ); @@ -423,9 +396,8 @@ test.describe("browser error handling", () => { await expect(page.locator("text=Not able to load file")).toBeVisible(); }); test("error appears when README can't be loaded", async ({ page }) => { - await page.route( - `**/v1/projects/${ridPrefix}${rid}/readme/${aliceMainHead}`, - route => route.fulfill({ status: 500 }), + await page.route(`**/v1/projects/${rid}/readme/${aliceMainHead}`, route => + route.fulfill({ status: 500 }), ); await page.goto(projectFixtureUrl); @@ -435,7 +407,7 @@ test.describe("browser error handling", () => { }); test("error appears when navigating to missing file", async ({ page }) => { await page.route( - `**/v1/projects/${ridPrefix}${rid}/blob/${aliceMainHead}/.hidden`, + `**/v1/projects/${rid}/blob/${aliceMainHead}/.hidden`, route => route.fulfill({ status: 500 }), ); @@ -447,7 +419,7 @@ test.describe("browser error handling", () => { page, }) => { await page.route( - `**/v1/projects/${ridPrefix}${rid}/blob/${aliceMainHead}/src/black-square.png`, + `**/v1/projects/${rid}/blob/${aliceMainHead}/src/black-square.png`, route => route.fulfill({ status: 404 }), ); diff --git a/tests/e2e/project/commit.spec.ts b/tests/e2e/project/commit.spec.ts index adb75b59f..6e288b91c 100644 --- a/tests/e2e/project/commit.spec.ts +++ b/tests/e2e/project/commit.spec.ts @@ -5,18 +5,12 @@ import { bobRemote, } from "@tests/support/fixtures.js"; -const modifiedFileFixture = `${projectFixtureUrl}/remotes/${bobRemote}/commits/${ - process.env.HEARTWOOD - ? "1e0bb83a89b63da815f2fc24e7ae3c5ceb30e0eb" - : "2b32f6fe50090ebdb4cd7441e943330da3e6ff04" -}`; +const modifiedFileFixture = `${projectFixtureUrl}/remotes/${bobRemote}/commits/${"1e0bb83a89b63da815f2fc24e7ae3c5ceb30e0eb"}`; test("navigation from commit list", async ({ page }) => { await page.goto(projectFixtureUrl); await page.getByTitle("Change peer").click(); - await page - .locator(process.env.HEARTWOOD ? `text=${bobRemote}` : "text=bob hyyzz9") - .click(); + await page.locator(`text=${bobRemote.substring(0, 6)}`).click(); await page.locator('role=button[name="Commit count"]').click(); await page.locator("text=Update readme").click(); @@ -35,13 +29,7 @@ test("relative timestamps", async ({ page }) => { }); await page.goto(modifiedFileFixture); await expect( - page.locator( - `.commit header >> text=${ - process.env.HEARTWOOD - ? "Bob Belcher committed now" - : "bob committed 22 hours ago" - }`, - ), + page.locator(`.commit header >> text=${"Bob Belcher committed now"}`), ).toBeVisible(); }); @@ -52,16 +40,9 @@ test("modified file", async ({ page }) => { { const header = page.locator(".commit header"); await expect(header.locator("text=Update readme")).toBeVisible(); - if (!process.env.HEARTWOOD) { - await expect(header.locator("text=Verified")).toBeVisible(); - await expect( - header.locator("text=2b32f6fe50090ebdb4cd7441e943330da3e6ff04"), - ).toBeVisible(); - } else { - await expect( - header.locator("text=1e0bb83a89b63da815f2fc24e7ae3c5ceb30e0eb"), - ).toBeVisible(); - } + await expect( + header.locator("text=1e0bb83a89b63da815f2fc24e7ae3c5ceb30e0eb"), + ).toBeVisible(); } // Diff header. diff --git a/tests/e2e/project/commits.spec.ts b/tests/e2e/project/commits.spec.ts index f81da4359..b2729a9a6 100644 --- a/tests/e2e/project/commits.spec.ts +++ b/tests/e2e/project/commits.spec.ts @@ -13,15 +13,10 @@ test("peer and branch switching", async ({ page }) => { // Alice's peer. { await page.getByTitle("Change peer").click(); - if (process.env.HEARTWOOD) { - await page.locator(`text=${aliceRemote}`).click(); - await expect(page.getByTitle("Change peer")).toHaveText( - `did:key:${aliceRemote.substring(0, 6)}…${aliceRemote.slice(-6)}`, - ); - } else { - await page.locator("text=alice hybg18").click(); - await expect(page.getByTitle("Change peer")).toHaveText("alice delegate"); - } + await page.locator(`text=${aliceRemote.substring(0, 6)}`).click(); + await expect(page.getByTitle("Change peer")).toHaveText( + `did:key:${aliceRemote.substring(0, 6)}…${aliceRemote.slice(-6)}`, + ); await expect(page.getByText("Thursday, November 17, 2022")).toBeVisible(); await expect( @@ -66,20 +61,15 @@ test("peer and branch switching", async ({ page }) => { // Bob's peer. { await page.getByTitle("Change peer").click(); - if (process.env.HEARTWOOD) { - await page.locator(`text=${bobRemote}`).click(); - await expect(page.getByTitle("Change peer")).toHaveText( - `did:key:${bobRemote.substring(0, 6)}…${bobRemote.slice(-6)}`, - ); - } else { - await page.locator("text=bob hyyzz9").click(); - await expect(page.getByTitle("Change peer")).toHaveText("bob"); - } + await page.locator(`text=${bobRemote.substring(0, 6)}`).click(); + await expect(page.getByTitle("Change peer")).toHaveText( + `did:key:${bobRemote.substring(0, 6)}…${bobRemote.slice(-6)}`, + ); await expect(page.getByText("Tuesday, December 20, 2022")).toBeVisible(); await expect( page.locator(".commit-group-headers").first().locator(".commit-teaser"), - ).toHaveCount(process.env.HEARTWOOD ? 1 : 3); + ).toHaveCount(1); await expect(page.getByText("Thursday, November 17, 2022")).toBeVisible(); await expect( @@ -88,13 +78,8 @@ test("peer and branch switching", async ({ page }) => { await page.pause(); const latestCommit = page.locator(".commit-teaser").first(); - if (process.env.HEARTWOOD) { - await expect(latestCommit).toContainText("Update readme"); - await expect(latestCommit).toContainText("1e0bb83"); - } else { - await expect(latestCommit).toContainText("Update readme"); - await expect(latestCommit).toContainText("2b32f6f"); - } + await expect(latestCommit).toContainText("Update readme"); + await expect(latestCommit).toContainText("1e0bb83"); const earliestCommit = page.locator(".commit-teaser").last(); await expect(earliestCommit).toContainText( @@ -104,30 +89,6 @@ test("peer and branch switching", async ({ page }) => { } }); -test("verified badge", async ({ page }) => { - await page.goto(projectFixtureUrl); - await page.locator('role=button[name="Commit count"]').click(); - - await page.getByTitle("Change peer").click(); - if (process.env.HEARTWOOD) { - await page.locator(`text=${bobRemote}`).click(); - await expect(page.getByTitle("Change peer")).toHaveText( - `did:key:${bobRemote.substring(0, 6)}…${bobRemote.slice(-6)}`, - ); - } else { - await page.locator("text=bob hyyzz9").click(); - await expect(page.getByTitle("Change peer")).toHaveText("bob"); - // not applicable to heartwood? - await page.locator("text=Verified").hover(); - await expect( - page.locator( - "text=This commit was signed with the committer's radicle key.", - ), - ).toBeVisible(); - await expect(page.locator(`text=bob committed ${bobRemote}`)).toBeVisible(); - } -}); - test("relative timestamps", async ({ page }) => { await page.addInitScript(() => { window.initializeTestStubs = () => { @@ -143,22 +104,13 @@ test("relative timestamps", async ({ page }) => { await page.locator('role=button[name="Commit count"]').click(); await page.getByTitle("Change peer").click(); - if (process.env.HEARTWOOD) { - await page.locator(`text=${bobRemote}`).click(); - await expect(page.getByTitle("Change peer")).toHaveText( - `did:key:${bobRemote.substring(0, 6)}…${bobRemote.slice(-6)}`, - ); - const latestCommit = page.locator(".commit-teaser").first(); - await expect(latestCommit).toContainText("Bob Belcher committed now"); - await expect(latestCommit).toContainText("1e0bb83"); - } else { - await page.locator("text=bob hyyzz9").click(); - await expect(page.getByTitle("Change peer")).toHaveText("bob"); - const latestCommit = page.locator(".commit-teaser").first(); - await expect(latestCommit).toContainText("bob committed 22 hours ago"); - await expect(latestCommit).toContainText("2b32f6f"); - } - + await page.locator(`text=${bobRemote.substring(0, 6)}`).click(); + await expect(page.getByTitle("Change peer")).toHaveText( + `did:key:${bobRemote.substring(0, 6)}…${bobRemote.slice(-6)}`, + ); + const latestCommit = page.locator(".commit-teaser").first(); + await expect(latestCommit).toContainText("Bob Belcher committed now"); + await expect(latestCommit).toContainText("1e0bb83"); const earliestCommit = page.locator(".commit-teaser").last(); await expect(earliestCommit).toContainText( "Alice Liddell committed last month", diff --git a/tests/e2e/search.spec.ts b/tests/e2e/search.spec.ts index f0d0071ba..5e64f3a8a 100644 --- a/tests/e2e/search.spec.ts +++ b/tests/e2e/search.spec.ts @@ -2,7 +2,6 @@ import { test, expect, rid, - ridPrefix, projectFixtureUrl, } from "@tests/support/fixtures.js"; @@ -10,11 +9,11 @@ test("navigate to existing project", async ({ page }) => { await page.goto("/"); const searchInput = page.getByPlaceholder("Search a name…"); await searchInput.click(); - await searchInput.fill(`${ridPrefix}${rid}`); + await searchInput.fill(`${rid}`); await searchInput.press("Enter"); await expect(page).toHaveURL(`${projectFixtureUrl}/tree`); - await expect(searchInput).not.toHaveValue(`${ridPrefix}${rid}`); + await expect(searchInput).not.toHaveValue(`${rid}`); }); test("navigate to a project that does not exist", async ({ page }) => { @@ -22,7 +21,7 @@ test("navigate to a project that does not exist", async ({ page }) => { const searchInput = page.getByPlaceholder("Search a name…"); await searchInput.click(); - const nonExistantId = `${ridPrefix}:zt${rid.substring(2)}`; + const nonExistantId = "rad:zAAAAAAAAAAAAAAAAAAAAAAAAAAA"; await searchInput.fill(nonExistantId); await searchInput.press("Enter"); diff --git a/tests/e2e/seed.spec.ts b/tests/e2e/seed.spec.ts index 88440d873..b4d79bc30 100644 --- a/tests/e2e/seed.spec.ts +++ b/tests/e2e/seed.spec.ts @@ -2,7 +2,6 @@ import { aliceMainHead, expect, rid, - ridPrefix, seedPort, seedRemote, seedVersion, @@ -44,8 +43,8 @@ test("seed projects", async ({ page }) => { // Show project ID on hover. { - await expect(project.locator(`text=${ridPrefix}${rid}`)).not.toBeVisible(); + await expect(project.locator(`text=${rid}`)).not.toBeVisible(); await project.hover(); - await expect(project.locator(`text=${ridPrefix}${rid}`)).toBeVisible(); + await expect(project.locator(`text=${rid}`)).toBeVisible(); } }); diff --git a/tests/fixtures/seeds/palm-heartwood.tar.bz2 b/tests/fixtures/seeds/palm-heartwood.tar.bz2 deleted file mode 100644 index e492b95ab..000000000 Binary files a/tests/fixtures/seeds/palm-heartwood.tar.bz2 and /dev/null differ diff --git a/tests/fixtures/seeds/palm.tar.bz2 b/tests/fixtures/seeds/palm.tar.bz2 index f3a741854..e492b95ab 100644 Binary files a/tests/fixtures/seeds/palm.tar.bz2 and b/tests/fixtures/seeds/palm.tar.bz2 differ diff --git a/tests/support/fixtures.ts b/tests/support/fixtures.ts index 43bd001dd..48d1f7867 100644 --- a/tests/support/fixtures.ts +++ b/tests/support/fixtures.ts @@ -49,6 +49,9 @@ export const test = base.extend<{ window.APP_CONFIG = { reactions: [], seeds: { + defaultHttpdPort: 8080, + defaultHttpdScheme: "http", + defaultNodePort: 8776, pinned: [{ host: "0.0.0.0", emoji: "πŸš€" }], }, projects: { pinned: [] }, @@ -124,14 +127,13 @@ function log(text: string, label: string, outputLog: Stream.Writable) { } } -export const appConfigWithFixture = process.env.HEARTWOOD - ? configFixtureHeartwood - : configFixture; - export function configFixture() { window.APP_CONFIG = { reactions: [], seeds: { + defaultHttpdPort: 8080, + defaultHttpdScheme: "http", + defaultNodePort: 8776, pinned: [{ host: "0.0.0.0", emoji: "πŸš€" }], }, projects: { @@ -146,10 +148,13 @@ export function configFixture() { }; } -export function configFixtureHeartwood() { +export function appConfigWithFixture() { window.APP_CONFIG = { reactions: [], seeds: { + defaultHttpdPort: 8080, + defaultHttpdScheme: "http", + defaultNodePort: 8776, pinned: [{ host: "0.0.0.0", emoji: "πŸš€" }], }, projects: { @@ -165,19 +170,10 @@ export function configFixtureHeartwood() { } export const aliceMainHead = "fcc929424b82984b7cbff9c01d2e20d9b1249842"; -export const aliceRemote = process.env.HEARTWOOD - ? "z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi" - : "hybg18bc4cu8z9xtj44skxperfdpxpp1wp8zygyzti5kfiggdizfxy"; -export const bobRemote = process.env.HEARTWOOD - ? "z6MksMTThc1aDU2Ztc43jJUivuyBLNWiLsDf4X65rABe7HbA" - : "hyyzz9w4ffg16zftjki3enajm4mkqkayb5ch1p6ns3f83np1hqkrp6"; -export const rid = process.env.HEARTWOOD - ? "zKtT7DmF9H34KkvcKj9PHW19WzjT" - : "hnrkdi8be7n4hhqoz9rpzrgd68u9dr3zsxgmy"; -export const ridPrefix = process.env.HEARTWOOD ? "rad:" : "rad:git:"; -export const projectFixtureUrl = `/seeds/0.0.0.0/${ridPrefix}${rid}`; -export const seedPort = process.env.HEARTWOOD ? 8080 : "8777"; -export const seedVersion = process.env.HEARTWOOD ? "0.1.0" : "0.2.0"; -export const seedRemote = process.env.HEARTWOOD - ? "z6Mkk7oqY4pPxhMmGEotDYsFo97vhCj85BLY1H256HrJmjN8" - : "hybuytx44z9cfsm5739wecia9j4b7expgc15qkazph59szp57m4d3o"; +export const aliceRemote = "z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi"; +export const bobRemote = "z6MksMTThc1aDU2Ztc43jJUivuyBLNWiLsDf4X65rABe7HbA"; +export const rid = "rad:zKtT7DmF9H34KkvcKj9PHW19WzjT"; +export const projectFixtureUrl = `/seeds/0.0.0.0/${rid}`; +export const seedPort = 8080; +export const seedVersion = "0.1.0"; +export const seedRemote = "z6Mkk7oqY4pPxhMmGEotDYsFo97vhCj85BLY1H256HrJmjN8"; diff --git a/tests/support/globalSetup.ts b/tests/support/globalSetup.ts index 60cca10ee..b47ebe3ac 100644 --- a/tests/support/globalSetup.ts +++ b/tests/support/globalSetup.ts @@ -11,28 +11,20 @@ export default async function globalSetup(_config: FullConfig): Promise { async function assertHttpApiRunning(): Promise { const notRunningMessage = "The http-api server with test fixtures needs to be running.\n" + - (process.env.HEARTWOOD - ? "πŸ‘‰ You can start it with `./scripts/run-httpd-with-fixtures`\n" - : "πŸ‘‰ You can start it with `./scripts/run-http-api-with-fixtures`\n"); + "πŸ‘‰ You can start it with `./scripts/run-httpd-with-fixtures`\n"; - let peerId: string | undefined = undefined; + let nodeId: string | undefined = undefined; try { - if (process.env.HEARTWOOD) { - const response = await fetch(`http://0.0.0.0:${seedPort}/api`); - const data = await response.json(); - peerId = data.node.id; - } else { - const response = await fetch(`http://0.0.0.0:${seedPort}`); - const data = await response.json(); - peerId = data.peer.id; - } + const response = await fetch(`http://0.0.0.0:${seedPort}/api`); + const data = await response.json(); + nodeId = data.node.id; } catch (err) { console.error(err); throw new Error(notRunningMessage); } - if (peerId !== seedRemote) { + if (nodeId !== seedRemote) { const wrongSeedMessage = `The server on port ${seedPort} doesn't have the right fixtures.\n`; throw new Error(wrongSeedMessage + notRunningMessage); } diff --git a/tests/unit/utils.test.ts b/tests/unit/utils.test.ts index 411ad12d0..4afd9d28a 100644 --- a/tests/unit/utils.test.ts +++ b/tests/unit/utils.test.ts @@ -9,6 +9,15 @@ describe("Format functions", () => { expect(utils.formatLocationHash(hash)).toEqual(expected); }); + test.each([ + { + id: "rad:zKtT7DmF9H34KkvcKj9PHW19WzjT", + expected: "rad:zKtT7D…19WzjT", + }, + ])("formatRepositoryId $id => $expected", ({ id, expected }) => { + expect(utils.formatRepositoryId(id)).toEqual(expected); + }); + test.each([ { id: "did:key:z6MkmzRwg47UWQxczLLLFfkEwpBGitjzJ1vKPE8U9ymd6fz6", @@ -22,22 +31,17 @@ describe("Format functions", () => { expect(utils.formatNodeId(id)).toEqual(expected); }); - test("formatRadicleId", () => { - if (process.env.HEARTWOOD) { - expect(utils.formatRadicleId("rad:zKtT7DmF9H34KkvcKj9PHW19WzjT")).toEqual( - "rad:zKtT7D…19WzjT", - ); - } else { - expect( - utils.formatRadicleId("rad:git:hnrkemobagsicpf9sr95o3g551otspcd84c9o"), - ).toEqual("rad:git:hnrkem…d84c9o"); - } - }); - - test("formatRadicleId throw when wrong ID", () => { - expect(() => - utils.formatRadicleId("hnrkemobagsicpf9sr95o3g551otspcd84c9o"), - ).toThrow(); + test.each([ + { + id: "rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5", + expected: "rad:z4V1sj…p4DtH5", + }, + { + id: "z4V1sjrXqjvFdnCUbxPFqd5p4DtH5", + expected: "rad:z4V1sj…p4DtH5", + }, + ])("formatRepositoryId $id => $expected", ({ id, expected }) => { + expect(utils.formatRepositoryId(id)).toEqual(expected); }); test.each([ @@ -67,19 +71,40 @@ describe("String Assertions", () => { }); test.each([ - process.env.HEARTWOOD - ? { id: "rad:zKtT7DmF9H34KkvcKj9PHW19WzjT", expected: true } - : { id: "rad:git:hnrkemobagsicpf9sr95o3g551otspcd84c9o", expected: true }, + { id: "rad:zKtT7DmF9H34KkvcKj9PHW19WzjT", expected: true }, + { id: "z2H9aHDurxd8Uvx2jsvW4e5mamy5S", expected: true }, + { id: "rad:BBBBBBBBBBBBBBBBBBBBBBBBBBBB", expected: false }, { id: "0x1234567890123456789012345678901234567890", expected: false }, - ])("isRadicleId $id => $expected", ({ id, expected }) => { - expect(utils.isRadicleId(id)).toEqual(expected); + { + id: "did:key:z6MkwPUeUS2fJMfc2HZN1RQTQcTTuhw4HhPySB8JeUg2mVvx", + expected: false, + }, + { + id: "z6MkwPUeUS2fJMfc2HZN1RQTQcTTuhw4HhPySB8JeUg2mVvx", + expected: false, + }, + ])("isRepositoryId $id => $expected", ({ id, expected }) => { + expect(utils.isRepositoryId(id)).toEqual(expected); }); test.each([ - { id: "hnrkj4c35uoyceb3d1dsscx8qq55cikrd1aio", expected: true }, + { + id: "did:key:z6MkwPUeUS2fJMfc2HZN1RQTQcTTuhw4HhPySB8JeUg2mVvx", + expected: true, + }, + { + id: "z6MkwPUeUS2fJMfc2HZN1RQTQcTTuhw4HhPySB8JeUg2mVvx", + expected: true, + }, + { + id: "did:key:CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC", + expected: false, + }, + { id: "rad:zKtT7DmF9H34KkvcKj9PHW19WzjT", expected: false }, + { id: "z2H9aHDurxd8Uvx2jsvW4e5mamy5S", expected: false }, { id: "0x1234567890123456789012345678901234567890", expected: false }, - ])("isPeerId $id => $expected", ({ id, expected }) => { - expect(utils.isPeerId(id)).toEqual(expected); + ])("isNodeId $id => $expected", ({ id, expected }) => { + expect(utils.isNodeId(id)).toEqual(expected); }); test.each([ @@ -131,8 +156,8 @@ describe("Parse Functions", () => { pubkey: "z6MkmzRwg47UWQxczLLLFfkEwpBGitjzJ1vKPE8U9ymd6fz6", }, }, - ])("parseNid", ({ input, expected }) => { - expect(utils.parseNid(input)).toEqual(expected); + ])("parseNodeId", ({ input, expected }) => { + expect(utils.parseNodeId(input)).toEqual(expected); }); }); diff --git a/vite.config.ts b/vite.config.ts index 320702dba..667b667c1 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -12,7 +12,6 @@ function defineConstants() { const constants = { VITEST: process.env.VITEST !== undefined, PLAYWRIGHT: process.env.PLAYWRIGHT_TEST_BASE_URL !== undefined, - HEARTWOOD: process.env.HEARTWOOD !== undefined, }; // Don't overwrite HASH_ROUTING in Playwright tests, so we can control it