39 lines
961 B
JavaScript
39 lines
961 B
JavaScript
/**
|
|
* Test Domain Utilities
|
|
* Standardizes fake domain usage across all tests for multi-tenant scenarios
|
|
*/
|
|
|
|
/**
|
|
* Generate a fake domain for a tenant slug
|
|
* @param {string} tenantSlug - The tenant slug (e.g., 'test-tenant')
|
|
* @returns {string} - The fake domain (e.g., 'test-tenant.example.com')
|
|
*/
|
|
function getTenantDomain(tenantSlug) {
|
|
return `${tenantSlug}.example.com`;
|
|
}
|
|
|
|
/**
|
|
* Create a supertest request with proper tenant domain
|
|
* @param {Object} app - Express app instance
|
|
* @param {string} tenantSlug - The tenant slug
|
|
* @returns {Object} - Request object with Host header set
|
|
*/
|
|
function createTenantRequest(request, app, tenantSlug) {
|
|
return request(app).set('Host', getTenantDomain(tenantSlug));
|
|
}
|
|
|
|
/**
|
|
* Standard test tenant configurations
|
|
*/
|
|
const TEST_TENANTS = {
|
|
DEFAULT: 'test-tenant',
|
|
SECONDARY: 'test-tenant-2',
|
|
ADMIN: 'admin-tenant'
|
|
};
|
|
|
|
module.exports = {
|
|
getTenantDomain,
|
|
createTenantRequest,
|
|
TEST_TENANTS
|
|
};
|