chore(react-router): improving continuous testability

This commit is contained in:
ShaneK
2025-11-24 09:08:29 -08:00
parent 383ec04cc4
commit 10c31eda6c
6 changed files with 80 additions and 6 deletions

3
package-lock.json generated
View File

@@ -9288,8 +9288,7 @@
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/@octokit/plugin-request-log/-/plugin-request-log-1.0.4.tgz",
"integrity": "sha512-mLUsMkgP7K/cnFEw07kWqXGF5LKrOkD+lhCrKvPHXWDywAwuDUeDwWBpc69XK3pNX0uKiVt8g5z96PJ6z9xCFA==",
"dev": true,
"requires": {}
"dev": true
},
"@octokit/plugin-rest-endpoint-methods": {
"version": "6.6.2",

View File

@@ -0,0 +1,69 @@
#!/bin/bash
set -x
# Change to script's directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
# Inside core
echo "Building core..."
cd ../../../core
npm run build
# Inside packages/react
echo "Building packages/react..."
cd ../packages/react
npm ci
npm run sync
npm run build
# Inside packages/react-router
echo "Building packages/react-router..."
cd ../react-router
npm ci
npm run sync
npm run build
# Inside packages/react-router/test
echo "Building test app..."
cd ./test
rm -rf build/reactrouter6 || true
sh ./build.sh reactrouter6
cd build/reactrouter6
echo "Installing dependencies..."
npm install --legacy-peer-deps > npm_install.log 2>&1
npm run sync
echo "Cleaning up port 3000..."
lsof -ti:3000 | xargs kill -9 || true
echo "Starting server..."
# Start server in background and save PID
npm start > server.log 2>&1 &
SERVER_PID=$!
# Ensure server is killed on script exit
trap "kill $SERVER_PID" EXIT
echo "Waiting for server to start (30s)..."
sleep 30
echo "Checking server status..."
SERVER_RESPONSE=$(curl -s -v http://localhost:3000 2>&1)
if echo "$SERVER_RESPONSE" | grep -q "Child compilation failed"; then
echo "Server started but has compilation errors. Exiting."
echo "$SERVER_RESPONSE"
exit 1
fi
if ! echo "$SERVER_RESPONSE" | grep -q "200 OK"; then
echo "Server did not return 200 OK. Exiting."
echo "$SERVER_RESPONSE"
exit 1
fi
echo "Server is healthy."
echo "Running Cypress tests..."
# Run specific failing tests first
npm run cypress -- --spec "tests/e2e/specs/swipe-to-go-back.cy.js"

View File

@@ -235,6 +235,7 @@ export class StackManager extends React.PureComponent<StackManagerProps, StackMa
console.log(
`[StackManager] handlePageTransition in outlet ${this.id}: pathname=${routeInfo.pathname}, entering=${enteringViewItem?.id}, leaving=${leavingViewItem?.id}`
);
console.log(`[StackManager] routeInfo: action=${routeInfo.routeAction}, direction=${routeInfo.routeDirection}, pushedBy=${routeInfo.pushedByRoute}`);
/**
* If we don't have a leaving view item, but the route info indicates
@@ -682,8 +683,7 @@ export class StackManager extends React.PureComponent<StackManagerProps, StackMa
// Find the view item for the route we are going back to
const enteringViewItem = this.context.findViewItemByRouteInfo(propsToUse, this.id, false);
return (
!!enteringViewItem &&
const canStartSwipe = !!enteringViewItem &&
/**
* The root url '/' is treated as
* the first view item (but is never mounted),
@@ -699,8 +699,10 @@ export class StackManager extends React.PureComponent<StackManagerProps, StackMa
* Make sure that we are not swiping back to the same
* instances of a view.
*/
enteringViewItem.routeData.match.pattern.path !== routeInfo.pathname
);
enteringViewItem.routeData.match.pattern.path !== routeInfo.pathname;
console.log(`[StackManager] canStart swipe in outlet ${this.id}: ${canStartSwipe}, pathname=${routeInfo.pathname}, enteringView=${enteringViewItem?.id}, pushedBy=${routeInfo.pushedByRoute}`);
return canStartSwipe;
};
const onStart = async () => {

View File

@@ -52,6 +52,7 @@
"devDependencies": {
"concurrently": "^6.3.0",
"cypress": "^13.2.0",
"cypress-terminal-report": "^5.3.0",
"serve": "^14.0.1",
"wait-on": "^6.0.0",
"webpack-cli": "^4.9.1"

View File

@@ -18,4 +18,5 @@
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
require('cypress-terminal-report/src/installLogsPrinter')(on);
};

View File

@@ -18,3 +18,5 @@ import './commands';
// Alternatively you can use CommonJS syntax:
// require('./commands')
require('cypress-terminal-report/src/installLogsCollector')();