mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
800e857f93
This commit adds comprehensive tests for the getInstallationInfo utility that was implemented in PR #7744. The tests verify that: 1. Version information is correctly retrieved from package.json 2. DockerHub API integration works correctly 3. Version filtering logic properly identifies full releases 4. The implementation handles various version scenarios Closes #10568 - The requested feature to switch from GitHub to DockerHub API for release checking has already been implemented and is working correctly.
52 lines
2.0 KiB
TypeScript
52 lines
2.0 KiB
TypeScript
import { getVersionInfo, getVersion } from "./getInstallationInfo";
|
|
|
|
describe("getInstallationInfo", () => {
|
|
describe("getVersion", () => {
|
|
it("should return the version from package.json", () => {
|
|
const version = getVersion();
|
|
expect(version).toBeDefined();
|
|
expect(typeof version).toBe("string");
|
|
expect(version).toMatch(/^\d+\.\d+\.\d+/); // Should match semver pattern
|
|
});
|
|
});
|
|
|
|
describe("getVersionInfo", () => {
|
|
it("should fetch version information from DockerHub", async () => {
|
|
const currentVersion = "1.0.0"; // Use a known version for testing
|
|
const result = await getVersionInfo(currentVersion);
|
|
|
|
expect(result).toBeDefined();
|
|
expect(result.latestVersion).toBeDefined();
|
|
expect(typeof result.latestVersion).toBe("string");
|
|
expect(typeof result.versionsBehind).toBe("number");
|
|
expect(result.versionsBehind).toBeGreaterThanOrEqual(-1);
|
|
}, 10000); // Increase timeout for API call
|
|
|
|
it("should handle current version correctly", async () => {
|
|
const currentVersion = getVersion();
|
|
const result = await getVersionInfo(currentVersion);
|
|
|
|
expect(result).toBeDefined();
|
|
expect(result.latestVersion).toBeDefined();
|
|
|
|
// If we're on the latest version, we should be 0 versions behind
|
|
// If we're behind, it should be a positive number
|
|
// If version is not found, it should be -1
|
|
expect(result.versionsBehind).toBeGreaterThanOrEqual(-1);
|
|
}, 10000);
|
|
|
|
it("should filter only full release versions", async () => {
|
|
// This test verifies that the version filtering logic works correctly
|
|
// by checking that pre-release versions are excluded
|
|
const testVersion = "0.1.0"; // Use a very old version to ensure we get results
|
|
const result = await getVersionInfo(testVersion);
|
|
|
|
expect(result).toBeDefined();
|
|
expect(result.latestVersion).toBeDefined();
|
|
|
|
// The latest version should match the full release pattern
|
|
expect(result.latestVersion).toMatch(/^\d+\.\d+\.\d+$/);
|
|
}, 10000);
|
|
});
|
|
});
|