mirror of
https://github.com/foss42/apidash.git
synced 2025-12-05 20:40:02 +08:00
Merge branch 'add-feature-header-env-suggestions' of https://github.com/DenserMeerkat/apidash into pr/573
This commit is contained in:
@@ -115,7 +115,6 @@ void main() {
|
||||
label.style?.color,
|
||||
equals(Theme.of(tester.element(find.byKey(testKey)))
|
||||
.colorScheme
|
||||
.onSurface
|
||||
.withOpacity(0.65)));
|
||||
.onSurfaceVariant));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -48,10 +48,13 @@ const globalVars = [
|
||||
EnvironmentVariableModel(key: "num", value: "5670000"),
|
||||
EnvironmentVariableModel(key: "token", value: "token"),
|
||||
];
|
||||
final globalVarsMap = {for (var item in globalVars) item.key: item.value};
|
||||
const activeEnvVars = [
|
||||
EnvironmentVariableModel(key: "url", value: "api.apidash.dev"),
|
||||
EnvironmentVariableModel(key: "num", value: "8940000"),
|
||||
];
|
||||
final activeEnvVarsMap = {for (var item in activeEnvVars) item.key: item.value};
|
||||
final combinedEnvVarsMap = mergeMaps(globalVarsMap, activeEnvVarsMap);
|
||||
|
||||
void main() {
|
||||
group("Testing getEnvironmentTitle function", () {
|
||||
@@ -125,66 +128,45 @@ void main() {
|
||||
group("Testing substituteVariables function", () {
|
||||
test("Testing substituteVariables with null", () {
|
||||
String? input;
|
||||
Map<String?, List<EnvironmentVariableModel>> envMap = {};
|
||||
String? activeEnvironmentId;
|
||||
expect(substituteVariables(input, envMap, activeEnvironmentId), null);
|
||||
Map<String, String> envMap = {};
|
||||
expect(substituteVariables(input, envMap), null);
|
||||
});
|
||||
|
||||
test("Testing substituteVariables with empty input", () {
|
||||
String input = "";
|
||||
Map<String?, List<EnvironmentVariableModel>> envMap = {};
|
||||
String? activeEnvironmentId;
|
||||
expect(substituteVariables(input, envMap, activeEnvironmentId), "");
|
||||
Map<String, String> envMap = {};
|
||||
expect(substituteVariables(input, envMap), "");
|
||||
});
|
||||
|
||||
test("Testing substituteVariables with empty envMap", () {
|
||||
String input = "{{url}}/humanize/social?num={{num}}";
|
||||
Map<String?, List<EnvironmentVariableModel>> envMap = {};
|
||||
String? activeEnvironmentId;
|
||||
String expected = "/humanize/social?num=";
|
||||
expect(substituteVariables(input, envMap, activeEnvironmentId), expected);
|
||||
Map<String, String> envMap = {};
|
||||
String expected = "{{url}}/humanize/social?num={{num}}";
|
||||
expect(substituteVariables(input, envMap), expected);
|
||||
});
|
||||
|
||||
test("Testing substituteVariables with empty activeEnvironmentId", () {
|
||||
String input = "{{url}}/humanize/social?num={{num}}";
|
||||
Map<String?, List<EnvironmentVariableModel>> envMap = {
|
||||
kGlobalEnvironmentId: globalVars,
|
||||
};
|
||||
String expected = "api.foss42.com/humanize/social?num=5670000";
|
||||
expect(substituteVariables(input, envMap, null), expected);
|
||||
expect(substituteVariables(input, globalVarsMap), expected);
|
||||
});
|
||||
|
||||
test("Testing substituteVariables with non-empty activeEnvironmentId", () {
|
||||
String input = "{{url}}/humanize/social?num={{num}}";
|
||||
Map<String?, List<EnvironmentVariableModel>> envMap = {
|
||||
kGlobalEnvironmentId: globalVars,
|
||||
"activeEnvId": activeEnvVars,
|
||||
};
|
||||
String? activeEnvId = "activeEnvId";
|
||||
String expected = "api.apidash.dev/humanize/social?num=8940000";
|
||||
expect(substituteVariables(input, envMap, activeEnvId), expected);
|
||||
expect(substituteVariables(input, combinedEnvVarsMap), expected);
|
||||
});
|
||||
|
||||
test("Testing substituteVariables with incorrect paranthesis", () {
|
||||
String input = "{{url}}}/humanize/social?num={{num}}";
|
||||
Map<String?, List<EnvironmentVariableModel>> envMap = {
|
||||
kGlobalEnvironmentId: globalVars,
|
||||
"activeEnvId": activeEnvVars,
|
||||
};
|
||||
String? activeEnvId = "activeEnvId";
|
||||
String expected = "api.apidash.dev}/humanize/social?num=8940000";
|
||||
expect(substituteVariables(input, envMap, activeEnvId), expected);
|
||||
expect(substituteVariables(input, combinedEnvVarsMap), expected);
|
||||
});
|
||||
|
||||
test("Testing substituteVariables function with unavailable variables", () {
|
||||
String input = "{{url1}}/humanize/social?num={{num}}";
|
||||
Map<String?, List<EnvironmentVariableModel>> envMap = {
|
||||
kGlobalEnvironmentId: globalVars,
|
||||
"activeEnvId": activeEnvVars,
|
||||
};
|
||||
String? activeEnvironmentId = "activeEnvId";
|
||||
String expected = "/humanize/social?num=8940000";
|
||||
expect(substituteVariables(input, envMap, activeEnvironmentId), expected);
|
||||
String expected = "{{url1}}/humanize/social?num=8940000";
|
||||
expect(substituteVariables(input, combinedEnvVarsMap), expected);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -251,9 +233,9 @@ void main() {
|
||||
};
|
||||
String? activeEnvironmentId = "activeEnvId";
|
||||
const expected = HttpRequestModel(
|
||||
url: "/humanize/social",
|
||||
url: "{{url1}}/humanize/social",
|
||||
headers: [
|
||||
NameValueModel(name: "Authorization", value: "Bearer "),
|
||||
NameValueModel(name: "Authorization", value: "Bearer {{token1}}"),
|
||||
],
|
||||
params: [
|
||||
NameValueModel(name: "num", value: "8940000"),
|
||||
|
||||
@@ -71,77 +71,115 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
group("Testing getAPIColor function", () {
|
||||
HTTPVerb methodGet = HTTPVerb.get;
|
||||
Color colMethodGetDarkModeExpected = getDarkModeColor(kColorHttpMethodGet);
|
||||
test('Test getAPIColor for GET method dark mode', () {
|
||||
expect(
|
||||
getAPIColor(
|
||||
APIType.rest,
|
||||
method: methodGet,
|
||||
brightness: dark,
|
||||
),
|
||||
colMethodGetDarkModeExpected);
|
||||
});
|
||||
|
||||
HTTPVerb methodHead = HTTPVerb.head;
|
||||
Color colMethodHeadDarkModeExpected =
|
||||
getDarkModeColor(kColorHttpMethodHead);
|
||||
test('Test getHTTPMethodColor for HEAD Method dark mode', () {
|
||||
expect(
|
||||
getAPIColor(
|
||||
APIType.rest,
|
||||
method: methodHead,
|
||||
brightness: dark,
|
||||
),
|
||||
colMethodHeadDarkModeExpected);
|
||||
});
|
||||
|
||||
HTTPVerb methodPatch = HTTPVerb.patch;
|
||||
Color colMethodPatchDarkModeExpected =
|
||||
getDarkModeColor(kColorHttpMethodPatch);
|
||||
test('Test getHTTPMethodColor for PATCH Method dark mode', () {
|
||||
expect(
|
||||
getAPIColor(
|
||||
APIType.rest,
|
||||
method: methodPatch,
|
||||
brightness: dark,
|
||||
),
|
||||
colMethodPatchDarkModeExpected);
|
||||
});
|
||||
|
||||
HTTPVerb methodPut = HTTPVerb.put;
|
||||
Color colMethodPutDarkModeExpected = getDarkModeColor(kColorHttpMethodPut);
|
||||
test('Test getHTTPMethodColor for PUT Method dark mode', () {
|
||||
expect(
|
||||
getAPIColor(
|
||||
APIType.rest,
|
||||
method: methodPut,
|
||||
brightness: dark,
|
||||
),
|
||||
colMethodPutDarkModeExpected);
|
||||
});
|
||||
|
||||
HTTPVerb methodPost = HTTPVerb.post;
|
||||
Color colMethodPostDarkModeExpected =
|
||||
getDarkModeColor(kColorHttpMethodPost);
|
||||
test('Test getHTTPMethodColor for POST Method dark mode', () {
|
||||
expect(
|
||||
getAPIColor(
|
||||
APIType.rest,
|
||||
method: methodPost,
|
||||
brightness: dark,
|
||||
),
|
||||
colMethodPostDarkModeExpected);
|
||||
});
|
||||
|
||||
HTTPVerb methodDelete = HTTPVerb.delete;
|
||||
Color colMethodDeleteDarkModeExpected =
|
||||
getDarkModeColor(kColorHttpMethodDelete);
|
||||
test('Test getHTTPMethodColor for DELETE Method dark mode', () {
|
||||
expect(
|
||||
getAPIColor(
|
||||
APIType.rest,
|
||||
method: methodDelete,
|
||||
brightness: dark,
|
||||
),
|
||||
colMethodDeleteDarkModeExpected);
|
||||
});
|
||||
});
|
||||
|
||||
group("Testing getHTTPMethodColor function", () {
|
||||
HTTPVerb methodGet = HTTPVerb.get;
|
||||
test('Test getHTTPMethodColor for GET method', () {
|
||||
expect(getHTTPMethodColor(methodGet), kColorHttpMethodGet);
|
||||
});
|
||||
|
||||
Color colMethodGetDarkModeExpected = getDarkModeColor(kColorHttpMethodGet);
|
||||
test('Test getHTTPMethodColor for GET method dark mode', () {
|
||||
expect(getHTTPMethodColor(methodGet, brightness: dark),
|
||||
colMethodGetDarkModeExpected);
|
||||
});
|
||||
|
||||
HTTPVerb methodHead = HTTPVerb.head;
|
||||
test('Test getHTTPMethodColor for HEAD Method', () {
|
||||
expect(getHTTPMethodColor(methodHead), kColorHttpMethodHead);
|
||||
});
|
||||
|
||||
Color colMethodHeadDarkModeExpected =
|
||||
getDarkModeColor(kColorHttpMethodHead);
|
||||
test('Test getHTTPMethodColor for HEAD Method dark mode', () {
|
||||
expect(getHTTPMethodColor(methodHead, brightness: dark),
|
||||
colMethodHeadDarkModeExpected);
|
||||
});
|
||||
|
||||
HTTPVerb methodPatch = HTTPVerb.patch;
|
||||
test('Test getHTTPMethodColor for PATCH Method', () {
|
||||
expect(getHTTPMethodColor(methodPatch), kColorHttpMethodPatch);
|
||||
});
|
||||
|
||||
Color colMethodPatchDarkModeExpected =
|
||||
getDarkModeColor(kColorHttpMethodPatch);
|
||||
test('Test getHTTPMethodColor for PATCH Method dark mode', () {
|
||||
expect(getHTTPMethodColor(methodPatch, brightness: dark),
|
||||
colMethodPatchDarkModeExpected);
|
||||
});
|
||||
|
||||
HTTPVerb methodPut = HTTPVerb.put;
|
||||
test('Test getHTTPMethodColor for PUT Method', () {
|
||||
expect(getHTTPMethodColor(methodPut), kColorHttpMethodPut);
|
||||
});
|
||||
|
||||
Color colMethodPutDarkModeExpected = getDarkModeColor(kColorHttpMethodPut);
|
||||
test('Test getHTTPMethodColor for PUT Method dark mode', () {
|
||||
expect(getHTTPMethodColor(methodPut, brightness: dark),
|
||||
colMethodPutDarkModeExpected);
|
||||
});
|
||||
|
||||
HTTPVerb methodPost = HTTPVerb.post;
|
||||
|
||||
test('Test getHTTPMethodColor for POST Method', () {
|
||||
expect(getHTTPMethodColor(methodPost), kColorHttpMethodPost);
|
||||
});
|
||||
|
||||
Color colMethodPostDarkModeExpected =
|
||||
getDarkModeColor(kColorHttpMethodPost);
|
||||
test('Test getHTTPMethodColor for POST Method dark mode', () {
|
||||
expect(getHTTPMethodColor(methodPost, brightness: dark),
|
||||
colMethodPostDarkModeExpected);
|
||||
});
|
||||
|
||||
HTTPVerb methodDelete = HTTPVerb.delete;
|
||||
test('Test getHTTPMethodColor for DELETE Method', () {
|
||||
expect(getHTTPMethodColor(methodDelete), kColorHttpMethodDelete);
|
||||
});
|
||||
|
||||
Color colMethodDeleteDarkModeExpected =
|
||||
getDarkModeColor(kColorHttpMethodDelete);
|
||||
test('Test getHTTPMethodColor for DELETE Method dark mode', () {
|
||||
expect(getHTTPMethodColor(methodDelete, brightness: dark),
|
||||
colMethodDeleteDarkModeExpected);
|
||||
});
|
||||
});
|
||||
|
||||
group('Testing getScaffoldKey function', () {
|
||||
|
||||
Reference in New Issue
Block a user