mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
test(spec): pin the unknown-key diagnostic to one text
The two runtimes each claimed to raise the other's message and nothing checked it. Both now render the committed text for the committed key.
This commit is contained in:
1 parent
269574706d
commit
b8bb44cf61
4 files changed
+95
-54
No files matched your search
@@ -694,6 +694,7 @@ export const __testing__ = {
|
||||
selectorFromString,
|
||||
selectorFromObject,
|
||||
SELECTOR_KEYS,
|
||||
unknownSelectorKeyMessage,
|
||||
xpathStringLiteral,
|
||||
};
|
||||
|
||||
|
||||
+44
-38
@@ -1,38 +1,44 @@
|
||||
[
|
||||
"accessibilityIdentifier",
|
||||
"accessibilityLabel",
|
||||
"accessibilityText",
|
||||
"aria-label",
|
||||
"ariaLabel",
|
||||
"bounds",
|
||||
"checked",
|
||||
"class",
|
||||
"className",
|
||||
"clickable",
|
||||
"content-desc",
|
||||
"contentDescription",
|
||||
"data-testid",
|
||||
"desc",
|
||||
"descPrefix",
|
||||
"editable",
|
||||
"elementType",
|
||||
"enabled",
|
||||
"focused",
|
||||
"hintText",
|
||||
"id",
|
||||
"idPrefix",
|
||||
"identifier",
|
||||
"label",
|
||||
"package",
|
||||
"placeholder",
|
||||
"placeholderValue",
|
||||
"resource-id",
|
||||
"scrollable",
|
||||
"selected",
|
||||
"tag",
|
||||
"testID",
|
||||
"testTag",
|
||||
"text",
|
||||
"title",
|
||||
"value"
|
||||
]
|
||||
{
|
||||
"keys": [
|
||||
"accessibilityIdentifier",
|
||||
"accessibilityLabel",
|
||||
"accessibilityText",
|
||||
"aria-label",
|
||||
"ariaLabel",
|
||||
"bounds",
|
||||
"checked",
|
||||
"class",
|
||||
"className",
|
||||
"clickable",
|
||||
"content-desc",
|
||||
"contentDescription",
|
||||
"data-testid",
|
||||
"desc",
|
||||
"descPrefix",
|
||||
"editable",
|
||||
"elementType",
|
||||
"enabled",
|
||||
"focused",
|
||||
"hintText",
|
||||
"id",
|
||||
"idPrefix",
|
||||
"identifier",
|
||||
"label",
|
||||
"package",
|
||||
"placeholder",
|
||||
"placeholderValue",
|
||||
"resource-id",
|
||||
"scrollable",
|
||||
"selected",
|
||||
"tag",
|
||||
"testID",
|
||||
"testTag",
|
||||
"text",
|
||||
"title",
|
||||
"value"
|
||||
],
|
||||
"unknownKeyExample": [
|
||||
"descripton"
|
||||
],
|
||||
"unknownKeyMessage": "selector key \"descripton\" cannot match: no element carries that attribute, and it is not one of the accepted keys: accessibilityIdentifier, accessibilityLabel, accessibilityText, aria-label, ariaLabel, bounds, checked, class, className, clickable, content-desc, contentDescription, data-testid, desc, descPrefix, editable, elementType, enabled, focused, hintText, id, idPrefix, identifier, label, package, placeholder, placeholderValue, resource-id, scrollable, selected, tag, testID, testTag, text, title, value"
|
||||
}
|
||||
@@ -5,10 +5,14 @@ import { test } from "node:test";
|
||||
|
||||
import { __testing__ } from "../src/web-runtime.ts";
|
||||
|
||||
const { SELECTOR_KEYS } = __testing__;
|
||||
const { SELECTOR_KEYS, unknownSelectorKeyMessage } = __testing__;
|
||||
|
||||
const goldenPath = fileURLToPath(new URL("./fixtures/selector-keys.json", import.meta.url));
|
||||
const golden: string[] = JSON.parse(readFileSync(goldenPath, "utf8"));
|
||||
const golden: {
|
||||
keys: string[];
|
||||
unknownKeyExample: string[];
|
||||
unknownKeyMessage: string;
|
||||
} = JSON.parse(readFileSync(goldenPath, "utf8"));
|
||||
|
||||
// Both runtimes reject an object-selector key they do not know, so the two key
|
||||
// lists have to be one list. Were they to drift, a spec would be accepted by
|
||||
@@ -17,5 +21,11 @@ const golden: string[] = JSON.parse(readFileSync(goldenPath, "utf8"));
|
||||
// internal/hierarchy/selector_keys_test.go asserts the SAME file from the
|
||||
// native side.
|
||||
test("the web key list is the cross-runtime list", () => {
|
||||
assert.deepEqual([...SELECTOR_KEYS], golden);
|
||||
assert.deepEqual([...SELECTOR_KEYS], golden.keys);
|
||||
});
|
||||
|
||||
// An author who hits this on Android and again on web must read one sentence,
|
||||
// not two dialects of it.
|
||||
test("the web diagnostic is the cross-runtime text", () => {
|
||||
assert.equal(unknownSelectorKeyMessage(golden.unknownKeyExample), golden.unknownKeyMessage);
|
||||
});
|
||||
Reference in new issue
Block a user