Skip to content

Commit

Permalink
chore(app-testing): Smoke test
Browse files Browse the repository at this point in the history
  • Loading branch information
greg-in-a-box committed Nov 8, 2024
1 parent 8191ea6 commit 6c583d3
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ test/videos
test/dev.html
yarn-debug.log
yarn-error.log
verdaccio
86 changes: 82 additions & 4 deletions scripts/app-testing/app_testing_main.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,95 @@
#!/bin/bash


set -e

VERDACCIO_PORT=4873
VERDACCIO_REGISTRY="http://localhost:$VERDACCIO_PORT"
PACKAGE_NAME="box-ui-elements"
TEST_APP_NAME="test-app"
TEST_APP_PORT=3000

echo "Setting up..."
npm install -g verdaccio
npm install -g create-next-app --registry https://registry.npmjs.org/
npm install -g verdaccio --registry https://registry.npmjs.org/
verdaccio --version

echo "Starting Verdaccio..."
verdaccio --config scripts/app-testing/verdaccio.yaml &
verdaccio --config ./scripts/app-testing/verdaccio.yaml &
VERDACCIO_PID=$!
echo "Verdaccio is running on PID: $VERDACCIO_PID"

echo "Setting npm registry to Verdaccio..."
echo "registry=$VERDACCIO_REGISTRY" > .npmrc
echo "npm registry is set to: "
npm get registry

echo "registry \"$VERDACCIO_REGISTRY\"" > .yarnrc
echo "yarn registry is set to: "
yarn config get registry

echo "Adding user to Verdaccio..."
expect -c "
spawn npm adduser --registry $VERDACCIO_REGISTRY
expect \"Username:\" { send \"testuser\r\"; exp_continue }
expect \"Password:\" { send \"testpass\r\"; exp_continue }
expect \"Email: \" { send \"[email protected]\r\"; exp_continue }
"
npm whoami --registry $VERDACCIO_REGISTRY

echo "Publishing package to Verdaccio..."
yarn install --force
yarn build:npm
npm publish --registry $VERDACCIO_REGISTRY
mkdir -p ~/test-apps
cd ~/test-apps
pwd

echo "Create test app..."
pwd
create-next-app $TEST_APP_NAME --yes
cd ./$TEST_APP_NAME
pwd
echo "registry=$VERDACCIO_REGISTRY" > .npmrc
echo "registry \"$VERDACCIO_REGISTRY\"" > .yarnrc
yarn add $PACKAGE_NAME

echo "Modify test app..."
pwd
cat > ./src/app/page.js <<EOL
import styles from "./page.module.css";
export default function Home() {
return (
<div className={styles.page}>
<main className={styles.main}>
HELLO WORLD
</main>
</div>
);
}
EOL

echo "Building test app..."
pwd
yarn build

echo "Starting test app..."
pwd
yarn start &
APP_PID=$!

sleep 10

echo "Verifying test app..."
curl --fail http://localhost:$TEST_APP_PORT || (echo "Test app failed to start" && exit 1)

echo "Resetting npm registry..."
npm set registry https://registry.npmjs.org/
yarn config set registry https://registry.yarnpkg.com/

echo "Stopping test app..."
kill $APP_PID

echo "Stopping Verdaccio..."
kill $VERDACCIO_PID

echo "Complete successfully!"
6 changes: 6 additions & 0 deletions scripts/app-testing/clean_app_testing.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

echo "Cleaning up..."
rm -rf ./scripts/app-testing/verdaccio
rm -rf ~/test-apps
npm cache clean --force || true
19 changes: 19 additions & 0 deletions scripts/app-testing/verdaccio.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
storage: ./verdaccio/storage

uplinks:
npmjs:
url: https://registry.npmjs.org/
auth:
htpasswd:
file: ./verdaccio/htpasswd
max_users: 1
packages:
'**':
access: $all
publish: $all
proxy: npmjs
allow_offline_publish: true
log:
- { type: stdout, format: pretty, level: http }

max_body_size: 100mb

0 comments on commit 6c583d3

Please sign in to comment.