Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>browserstack-demo</title>
<meta name="description" content="Browserstack Demo Project" />
<meta name="description" content="Test Case Selection Demo Project" />
<meta name="author" content="cia-dev" />

<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta property="og:title" content="Browserstack Demo" />
<meta property="og:description" content="Browserstack Demo Project" />
<link rel="icon" type="image/svg+xml" href="./favicon.svg" />
<meta property="og:title" content="Test Case Selection Demo" />
<meta property="og:description" content="Test Case Selection Demo Project" />
<meta property="og:type" content="website" />
<meta property="og:image" content="/favicon.svg" />
<meta property="og:image" content="./favicon.svg" />

<!-- GitHub Pages SPA redirect handling -->
<script>
Expand All @@ -30,6 +30,6 @@

<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
<script type="module" src="./src/main.tsx"></script>
</body>
</html>
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
{
"name": "browserstack-demo-app",
"name": "test-selection-demo-app-browserstack",
"version": "0.0.0",
"type": "module",
"homepage": "https://browserstack.github.io/browserstack-demo-app",
"homepage": "https://browserstack.github.io/test-selection-demo-app-browserstack/",
"scripts": {
"predeploy": "npm run build",
"deploy": "gh-pages -d dist",
"dev": "vite",
"build": "vite build",
"build:dev": "vite build --mode development",
"build:v1": "cross-env VITE_BASE_PATH=/browserstack-demo-app/v1/ vite build",
"build:v2": "cross-env VITE_BASE_PATH=/browserstack-demo-app/v2/ vite build",
"build:v3": "cross-env VITE_BASE_PATH=/browserstack-demo-app/v3/ vite build",
"lint": "eslint .",
"preview": "vite preview"
},
Expand Down
32 changes: 17 additions & 15 deletions public/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,26 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Loading...</title>
<title>Redirecting...</title>
<script>
// Surge serves 404.html for unknown routes unless a 200 fallback is provided.
// Instead of mutating the URL (which produced /?/… redirects), load the main
// SPA shell in-place so React Router can hydrate the correct route.
fetch('/index.html', { credentials: 'same-origin' })
.then((response) => response.text())
.then((html) => {
document.open();
document.write(html);
document.close();
})
.catch(() => {
window.location.replace('/');
});
// SPA redirect for GitHub Pages: move path into query so index.html can restore it
(function () {
var l = window.location;
// derive base path like /owner/repo or /repo depending on hosting
var parts = l.pathname.split('/').filter(Boolean);
// assume repo is the first path segment when hosted on browserstack.github.io
var repoIndex = parts.indexOf('test-selection-demo-app-browserstack');
var base = '/test-selection-demo-app-browserstack/';
// If repo not found, fall back to root
if (repoIndex === -1) {
base = '/';
}
var newPath = base + '?/' + l.pathname.slice(base.length).replace(/&/g, '~and~') + (l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') + l.hash;
l.replace(l.protocol + '//' + l.host + newPath);
})();
</script>
</head>
<body>
<p>Loading the application…</p>
<p>Redirecting to the app...</p>
</body>
</html>
1 change: 0 additions & 1 deletion public/_redirects

This file was deleted.

2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ const App = () => (
<CartProvider>
<QueryClientProvider client={queryClient}>
<TooltipProvider>
<BrowserRouter>
<BrowserRouter basename={import.meta.env.BASE_URL}>
<AppContent />
</BrowserRouter>
</TooltipProvider>
Expand Down
6 changes: 4 additions & 2 deletions src/contexts/CartContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ const CartProviderComponent = ({ children }: { children: ReactNode }) => {
localStorage.setItem('cart-items', JSON.stringify(cart));
}, [cart]);

const addToCart = (item: Omit<CartItem, 'quantity'>, quantity: number = 1) => {
dispatch({ type: 'ADD', item: { ...item, quantity } });
// NOTE: Always adds 1-5 random units of an item to the cart
const addToCart = (item: Omit<CartItem, 'quantity'>, _quantity?: number) => {
const randomQuantity = Math.floor(Math.random() * 5) + 1;
dispatch({ type: 'ADD', item: { ...item, quantity: randomQuantity } });
};
const decrementFromCart = (id: number) => {
dispatch({ type: 'DECREMENT', id });
Expand Down
Loading