-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove invite code from tests #22
Conversation
WalkthroughThe pull request modifies the test setup for API functions by removing the Changes
Poem
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/lib/signing.test.ts (2)
11-26
: Consider a more robust approach for token verification.The addition of token verification is good, but the arbitrary 100ms delay might be fragile. Consider using a polling mechanism with timeout instead.
Here's a more robust implementation:
async function setupTestUser() { // Clear any existing tokens first window.localStorage.clear(); // Get fresh tokens const { access_token, refresh_token } = await fetchLogin(TEST_EMAIL!, TEST_PASSWORD!); window.localStorage.setItem("access_token", access_token); window.localStorage.setItem("refresh_token", refresh_token); - // Add a small delay to ensure tokens are properly set - await new Promise(resolve => setTimeout(resolve, 100)); - - // Verify tokens were set correctly - const storedToken = window.localStorage.getItem("access_token"); - if (!storedToken) { - throw new Error("Failed to set access token"); - } + // Poll for token with timeout + const timeout = 1000; // 1 second timeout + const startTime = Date.now(); + while (Date.now() - startTime < timeout) { + const storedToken = window.localStorage.getItem("access_token"); + if (storedToken === access_token) { + return; + } + await new Promise(resolve => setTimeout(resolve, 10)); + } + throw new Error("Failed to verify access token after 1 second"); }
111-112
: Remove redundant localStorage clear.The localStorage.clear() call is redundant here since the beforeEach hook already handles clearing localStorage before each test.
- // Clear any existing tokens and set up fresh ones - window.localStorage.clear(); await setupTestUser();
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/lib/signing.test.ts
(3 hunks)
🔇 Additional comments (1)
src/lib/signing.test.ts (1)
29-32
: LGTM! Good test isolation practice.The beforeEach hook ensures each test starts with a clean localStorage state, preventing test interference.
Summary by CodeRabbit