Skip to content

Commit 495be47

Browse files
committed
Fix #3929: Web Feature queries missing uppercase test names
Remove case normalization at ingestion time to preserve original test names from WEB_FEATURES.yml. The Python manifest generator already preserves case (e.g., Document-createElement-customized-builtins.html), but the Go ingestion code was lowercasing all test names, causing queries to fail to match tests with uppercase characters. Also for the sake of testing this, fix staging to redeploy the searchcache when shared/ changes.
1 parent 9228c30 commit 495be47

File tree

4 files changed

+95
-3
lines changed

4 files changed

+95
-3
lines changed

api/query/cache/index/index_filter_test.go

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,6 +1042,61 @@ func TestBindExecute_TestWebFeature(t *testing.T) {
10421042
assert.Equal(t, expectedResult, srs[0])
10431043
}
10441044

1045+
func TestBindExecute_TestWebFeature_PreservesCase(t *testing.T) {
1046+
ctrl := gomock.NewController(t)
1047+
defer ctrl.Finish()
1048+
loader := NewMockReportLoader(ctrl)
1049+
idx, err := NewShardedWPTIndex(loader, testNumShards)
1050+
assert.Nil(t, err)
1051+
1052+
matchingTestName := "/custom-elements/Document-createElement-customized-builtins.html"
1053+
runs := mockTestRuns(loader, idx, []testRunData{
1054+
{
1055+
shared.TestRun{ID: 1},
1056+
&metrics.TestResultsReport{
1057+
Results: []*metrics.TestResults{
1058+
{
1059+
Test: matchingTestName,
1060+
Status: "PASS",
1061+
},
1062+
{
1063+
Test: "/custom-elements/other-test.html",
1064+
Status: "FAIL",
1065+
},
1066+
},
1067+
},
1068+
},
1069+
})
1070+
1071+
data := shared.WebFeaturesData{
1072+
matchingTestName: {"customized-built-in-elements": nil},
1073+
"/custom-elements/other-test.html": {"autonomous-custom-elements": nil},
1074+
}
1075+
1076+
testlabel := query.TestWebFeature{WebFeature: "customized-built-in-elements", WebFeaturesData: data}
1077+
plan, err := idx.Bind(runs, testlabel)
1078+
assert.Nil(t, err)
1079+
1080+
res := plan.Execute(runs, query.AggregationOpts{})
1081+
srs, ok := res.([]shared.SearchResult)
1082+
assert.True(t, ok)
1083+
1084+
assert.Equal(t, 1, len(srs))
1085+
expectedResult := shared.SearchResult{
1086+
Test: matchingTestName,
1087+
LegacyStatus: []shared.LegacySearchRunResult{
1088+
{
1089+
Passes: 1,
1090+
Total: 1,
1091+
Status: "",
1092+
NewAggProcess: true,
1093+
},
1094+
},
1095+
}
1096+
1097+
assert.Equal(t, expectedResult, srs[0])
1098+
}
1099+
10451100
func TestBindExecute_IsDifferent(t *testing.T) {
10461101
ctrl := gomock.NewController(t)
10471102
defer ctrl.Finish()

shared/web_features.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func (d webFeaturesManifestV1Data) prepareTestWebFeatureFilter() WebFeaturesData
9090
testToWebFeaturesMap := make(map[string]map[string]interface{})
9191
for webFeature, tests := range d {
9292
for _, test := range tests {
93-
key := strings.ToLower(test)
93+
key := test
9494
value := strings.ToLower(webFeature)
9595
if set, found := testToWebFeaturesMap[key]; found {
9696
set[value] = nil

shared/web_features_test.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,39 @@ func TestWebFeaturesData_TestMatchesWithWebFeature(t *testing.T) {
4646
webFeature: "feature1",
4747
expected: false,
4848
},
49+
{
50+
name: "test name with uppercase characters matches exact case",
51+
data: WebFeaturesData{
52+
"/custom-elements/Document-createElement-customized-builtins.html": map[string]interface{}{
53+
"customized-built-in-elements": nil,
54+
},
55+
},
56+
test: "/custom-elements/Document-createElement-customized-builtins.html",
57+
webFeature: "customized-built-in-elements",
58+
expected: true,
59+
},
60+
{
61+
name: "test name case must match exactly",
62+
data: WebFeaturesData{
63+
"/custom-elements/Document-createElement-customized-builtins.html": map[string]interface{}{
64+
"customized-built-in-elements": nil,
65+
},
66+
},
67+
test: "/custom-elements/document-createelement-customized-builtins.html",
68+
webFeature: "customized-built-in-elements",
69+
expected: false,
70+
},
71+
{
72+
name: "web feature name remains case-insensitive",
73+
data: WebFeaturesData{
74+
"/custom-elements/Document-createElement-customized-builtins.html": map[string]interface{}{
75+
"customized-built-in-elements": nil,
76+
},
77+
},
78+
test: "/custom-elements/Document-createElement-customized-builtins.html",
79+
webFeature: "Customized-Built-In-Elements",
80+
expected: true,
81+
},
4982
}
5083

5184
for _, tc := range tests {
@@ -123,10 +156,14 @@ func TestWebFeaturesManifestV1Data_prepareTestWebFeatureFilter(t *testing.T) {
123156
},
124157
"feature2": []string{
125158
"/test2",
159+
},
160+
"Feature3": []string{
161+
"/Test3",
126162
}}
127163
expectedResult := WebFeaturesData{
128164
"/test1": {"feature1": nil},
129165
"/test2": {"feature1": nil, "feature2": nil},
166+
"/Test3": {"feature3": nil},
130167
}
131168
result := data.prepareTestWebFeatureFilter()
132169
assert.Equal(t, expectedResult, result)

util/deploy-staging.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ if [[ "${APP_PATH}" == "" ]]; then fatal "app path not specified."; fi
2222

2323
APP_DEPS="${APP_PATH}"
2424
if [[ "${APP_PATH}" == webapp/web* ]]; then APP_DEPS="webapp|api|shared"; fi
25-
# Be more conservative: only deploy searchcache when it's directly modified.
26-
if [[ "${APP_PATH}" == api/query/cache/service* ]]; then APP_DEPS="api/query"; fi
25+
# Be more conservative: only deploy searchcache when it or shared are modified.
26+
if [[ "${APP_PATH}" == api/query/cache/service* ]]; then APP_DEPS="api/query|shared"; fi
2727
if [[ "${APP_PATH}" == "results-processor/app.staging.yaml" ]]; then APP_DEPS="results-processor"; fi
2828
APP_DEPS_REGEX="^(${APP_DEPS})/"
2929

0 commit comments

Comments
 (0)