test: add test ensuring we don't bail against proxima stamps when requesting feature flags

This commit is contained in:
Fotis Koutoulakis (@NlightNFotis) 2024-10-25 17:02:28 +01:00
parent 1a02ac9a03
commit 65117851a6
3 changed files with 46 additions and 1 deletions

View file

@ -53,6 +53,21 @@ const testRepositoryNwo = (0, repository_1.parseRepositoryNwo)("github/example")
"Not running against github.com. Disabling all toggleable features.") !== undefined);
});
});
(0, ava_1.default)(`Features work when run against GHES_dotcom as an environment (proxima stamp)`, async (t) => {
await (0, util_1.withTmpDir)(async (tmpDir) => {
const loggedMessages = [];
const features = setUpFeatureFlagTests(tmpDir, (0, testing_utils_1.getRecordingLogger)(loggedMessages), { type: util_1.GitHubVariant.GHE_DOTCOM });
(0, testing_utils_1.mockFeatureFlagApiEndpoint)(200, initializeFeatures(true));
for (const feature of Object.values(feature_flags_1.Feature)) {
// Ensure we have gotten a response value back from the Mock API
t.assert(await features.getValue(feature, includeCodeQlIfRequired(feature)));
}
// And that we haven't bailed preemptively.
t.assert(loggedMessages.find((v) => v.type === "debug" &&
v.message ===
"Not running against github.com. Disabling all toggleable features.") === undefined);
});
});
(0, ava_1.default)("API response missing and features use default value", async (t) => {
await (0, util_1.withTmpDir)(async (tmpDir) => {
const loggedMessages = [];

File diff suppressed because one or more lines are too long

View file

@ -60,6 +60,36 @@ test(`All features are disabled if running against GHES`, async (t) => {
});
});
test(`Features work when run against GHES_dotcom as an environment (proxima stamp)`, async (t) => {
await withTmpDir(async (tmpDir) => {
const loggedMessages = [];
const features = setUpFeatureFlagTests(
tmpDir,
getRecordingLogger(loggedMessages),
{ type: GitHubVariant.GHE_DOTCOM },
);
mockFeatureFlagApiEndpoint(200, initializeFeatures(true));
for (const feature of Object.values(Feature)) {
// Ensure we have gotten a response value back from the Mock API
t.assert(
await features.getValue(feature, includeCodeQlIfRequired(feature)),
);
}
// And that we haven't bailed preemptively.
t.assert(
loggedMessages.find(
(v: LoggedMessage) =>
v.type === "debug" &&
v.message ===
"Not running against github.com. Disabling all toggleable features.",
) === undefined,
);
});
});
test("API response missing and features use default value", async (t) => {
await withTmpDir(async (tmpDir) => {
const loggedMessages: LoggedMessage[] = [];