-
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathservice-host-editor-template.test.js
More file actions
60 lines (56 loc) · 1.71 KB
/
service-host-editor-template.test.js
File metadata and controls
60 lines (56 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
"use strict";
// This file is about the editor-side Service Host experience.
// It checks that the config UI still exposes the typed-input behavior we rely on for API keys and related fields.
const assert = require("node:assert/strict");
const fs = require("node:fs");
const path = require("node:path");
const test = require("node:test");
const templatePath = path.join(__dirname, "..", "src", "node.html");
const template = fs.readFileSync(templatePath, "utf8");
test("service host API key editor uses native typedInput cred handling", () => {
assert.match(
template,
/types: \["cred", "env", "msg", "flow", "global"\],/
);
assert.match(
template,
/<input type="text" id="node-config-input-secureApiKeyValue" placeholder="" \/>/
);
assert.match(
template,
/<input\s+type="text"\s+id="node-config-input-secureApiKeyHeaderOrQueryName"\s+placeholder="Authorization"\s+\/>/
);
assert.match(
template,
/<input type="text" id="node-config-input-secureAdminApiKeyValue" placeholder="" \/>/
);
assert.match(
template,
/function initializeCredentialTypedInput\(fieldName\) \{/
);
assert.match(
template,
/function saveCredentialTypedInput\(fieldName\) \{/
);
assert.match(
template,
/initializeCredentialTypedInput\("secureApiKeyValue"\);/
);
assert.match(
template,
/initializeCredentialTypedInput\("secureAdminApiKeyValue"\);/
);
assert.match(
template,
/saveCredentialTypedInput\("secureApiKeyValue"\);/
);
assert.match(
template,
/saveCredentialTypedInput\("secureAdminApiKeyValue"\);/
);
assert.match(
template,
/<span data-i18n="OpenaiApi.label.adminApiKey"><\/span>/
);
assert.ok(!/\.prop\("type"/.test(template));
});