- Install Jest for unit testing with React Testing Library - Install Playwright for end-to-end testing - Configure Jest with proper TypeScript support and module mapping - Create test setup files and utilities for both unit and e2e tests Components: * Jest configuration with coverage thresholds * Playwright configuration with browser automation * Unit tests for LoginForm, AuthContext, and useSocketIO hook * E2E tests for authentication, dashboard, and agents workflows * GitHub Actions workflow for automated testing * Mock data and API utilities for consistent testing * Test documentation with best practices Testing features: - Unit tests with 70% coverage threshold - E2E tests with API mocking and user journey testing - CI/CD integration for automated test runs - Cross-browser testing support with Playwright - Authentication system testing end-to-end 🚀 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
39 lines
1.0 KiB
JavaScript
39 lines
1.0 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.cache = void 0;
|
|
exports.sha1 = sha1;
|
|
const crypto_1 = require("crypto");
|
|
/**
|
|
* @internal
|
|
*/
|
|
// stores hashes made out of only one argument being a string
|
|
exports.cache = Object.create(null);
|
|
/**
|
|
* @internal
|
|
*/
|
|
function sha1(...data) {
|
|
const canCache = data.length === 1 && typeof data[0] === 'string';
|
|
// caching
|
|
let cacheKey;
|
|
if (canCache) {
|
|
cacheKey = data[0];
|
|
if (cacheKey in exports.cache) {
|
|
return exports.cache[cacheKey];
|
|
}
|
|
}
|
|
// we use SHA1 because it's the fastest provided by node
|
|
// and we are not concerned about security here
|
|
const hash = (0, crypto_1.createHash)('sha1');
|
|
data.forEach((item) => {
|
|
if (typeof item === 'string')
|
|
hash.update(item, 'utf8');
|
|
else
|
|
hash.update(item);
|
|
});
|
|
const res = hash.digest('hex').toString();
|
|
if (canCache) {
|
|
exports.cache[cacheKey] = res;
|
|
}
|
|
return res;
|
|
}
|