Add Playwright configuration and initial tests for landing page
Copilot Setup Steps / copilot-setup-steps (push) Failing after 17s
Copilot Setup Steps / copilot-setup-steps (push) Failing after 17s
- Created playwright.config.ts for test configuration - Added .last-run.json to store test run status - Implemented landing.test.ts with tests for navbar visibility and navigation - Removed unused server proxy configuration from vite.config.ts
This commit is contained in:
@@ -1,21 +1,42 @@
|
||||
import type { AlpacaAccount } from "../../../types";
|
||||
import Alpaca from "@alpacahq/alpaca-trade-api";
|
||||
|
||||
const alpaca = new Alpaca({
|
||||
keyId: process.env.ALPACA_API_KEY!,
|
||||
secretKey: process.env.ALPACA_SECRET_KEY!,
|
||||
baseUrl: process.env.ALPACA_BASE_URL || "https://paper-api.alpaca.markets",
|
||||
retryOnError: false,
|
||||
});
|
||||
|
||||
// Mock Alpaca account data – replace with actual API call
|
||||
async function fetchAlpacaAccount(): Promise<AlpacaAccount> {
|
||||
return {
|
||||
cash: 12345.67,
|
||||
buying_power: 8000.0,
|
||||
portfolio_value: 25000.0,
|
||||
};
|
||||
try {
|
||||
console.log("Fetching Alpaca account with key:", process.env.ALPACA_API_KEY?.substring(0, 8) + "...");
|
||||
const account = await alpaca.getAccount();
|
||||
console.log("Alpaca account fetched successfully");
|
||||
return {
|
||||
cash: parseFloat(account.cash),
|
||||
buying_power: parseFloat(account.buying_power),
|
||||
portfolio_value: parseFloat(account.portfolio_value),
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("Alpaca API fetch error:", error);
|
||||
return {
|
||||
cash: 0,
|
||||
buying_power: 0,
|
||||
portfolio_value: 0,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function loader() {
|
||||
try {
|
||||
const account = await fetchAlpacaAccount();
|
||||
return Response.json(account);
|
||||
} catch {
|
||||
} catch (error) {
|
||||
console.error("Alpaca API error:", error);
|
||||
const message = error instanceof Error ? error.message : "Unknown error";
|
||||
return Response.json(
|
||||
{ error: "Failed to fetch account info" },
|
||||
{ error: `Failed to fetch account info: ${message}` },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user