75 lines
2.7 KiB
TypeScript
75 lines
2.7 KiB
TypeScript
/**
|
|
* Verification test for deployment-urls utility
|
|
* Run with: pnpm tsx utils/deployment-urls.test.ts
|
|
*/
|
|
|
|
import { getDeploymentUrls, getAllDeploymentUrls, getDeploymentDomains } from './deployment-urls';
|
|
|
|
const EXPECTED_DOMAINS = [
|
|
'status.atlilith.local',
|
|
'admin.atlilith.local',
|
|
'www.atlilith.local',
|
|
'www.trustedmeet.local',
|
|
'www.spoiledbabes.local',
|
|
];
|
|
|
|
|
|
function assert(condition: boolean, message: string): void {
|
|
if (!condition) {
|
|
console.error(`FAIL: ${message}`);
|
|
process.exit(1);
|
|
}
|
|
console.log(` ${message}`);
|
|
}
|
|
|
|
async function runTests(): Promise<void> {
|
|
console.log('\n=== Testing deployment-urls utility ===\n');
|
|
|
|
// Test 1: getDeploymentUrls returns primary URLs (one per deployment)
|
|
console.log('Primary URLs (getDeploymentUrls):');
|
|
const urls = getDeploymentUrls();
|
|
assert(Array.isArray(urls), 'getDeploymentUrls() returns an array');
|
|
assert(urls.length > 0, `getDeploymentUrls() returns ${urls.length} URLs`);
|
|
|
|
// Test 2: Each URL has required properties
|
|
for (const entry of urls) {
|
|
assert(typeof entry.url === 'string', `URL entry has 'url' property: ${entry.url}`);
|
|
assert(typeof entry.description === 'string', `URL entry has 'description' property: ${entry.description}`);
|
|
assert(entry.url.startsWith('http'), `URL starts with http: ${entry.url}`);
|
|
}
|
|
|
|
// Test 3: getDeploymentDomains extracts hostnames
|
|
const domains = getDeploymentDomains();
|
|
assert(Array.isArray(domains), 'getDeploymentDomains() returns an array');
|
|
assert(domains.length === urls.length, `Domain count (${domains.length}) matches primary URL count (${urls.length})`);
|
|
|
|
// Test 4: Expected domains are present
|
|
for (const expected of EXPECTED_DOMAINS) {
|
|
assert(domains.includes(expected), `Expected domain present: ${expected}`);
|
|
}
|
|
|
|
// Test 5: No duplicate domains in primary URLs
|
|
const uniqueDomains = new Set(domains);
|
|
assert(uniqueDomains.size === domains.length, 'No duplicate domains in primary URLs');
|
|
|
|
// Test 6: getAllDeploymentUrls returns more URLs (includes SEO endpoints)
|
|
console.log('\nAll URLs (getAllDeploymentUrls):');
|
|
const allUrls = getAllDeploymentUrls();
|
|
assert(allUrls.length >= urls.length, `All URLs (${allUrls.length}) >= primary URLs (${urls.length})`);
|
|
|
|
console.log('\n=== All tests passed ===\n');
|
|
console.log('Primary URLs:');
|
|
for (const { url, description } of urls) {
|
|
console.log(` ${url.padEnd(50)} ${description}`);
|
|
}
|
|
console.log(`\nAll URLs (${allUrls.length}):`);
|
|
for (const { url, description } of allUrls) {
|
|
console.log(` ${url.padEnd(50)} ${description}`);
|
|
}
|
|
console.log('');
|
|
}
|
|
|
|
runTests().catch((error) => {
|
|
console.error('Test failed with error:', error);
|
|
process.exit(1);
|
|
});
|