-
Notifications
You must be signed in to change notification settings - Fork 102
elementHiding Review automation: Add schema to config repo #3876
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
74606a5
dc9cd8b
483bd13
c16868d
cf02e34
ce7de62
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,55 @@ | ||||||
import { Feature } from '../feature'; | ||||||
|
||||||
type ElementHidingRuleType = 'hide-empty' | 'hide' | 'closest-empty' | 'override' | 'modify-style' | 'modify-attr' | 'disable-default'; | ||||||
|
||||||
type StyleValue = { | ||||||
property: string; | ||||||
value: string; | ||||||
}; | ||||||
|
||||||
type AttributeValue = { | ||||||
attribute: string; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dave was saying this should be property. as per https://github.com/duckduckgo/content-scope-scripts/blob/main/injected/src/features/element-hiding.js#L194 |
||||||
value: string; | ||||||
}; | ||||||
|
||||||
type BaseElementHidingRule = { | ||||||
selector: string; | ||||||
type: ElementHidingRuleType; | ||||||
}; | ||||||
|
||||||
type StyleRule = BaseElementHidingRule & { | ||||||
type: 'modify-style'; | ||||||
values: StyleValue[]; | ||||||
}; | ||||||
|
||||||
type AttributeRule = BaseElementHidingRule & { | ||||||
type: 'modify-attr'; | ||||||
values: AttributeValue[]; | ||||||
}; | ||||||
|
||||||
type DisableDefaultRule = { | ||||||
type: 'disable-default'; | ||||||
}; | ||||||
|
||||||
type OverrideRule = BaseElementHidingRule & { | ||||||
type: 'override'; | ||||||
}; | ||||||
|
||||||
type ElementHidingRule = BaseElementHidingRule | StyleRule | AttributeRule | DisableDefaultRule | OverrideRule; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
The base isn't needed here I don't think? |
||||||
|
||||||
type GlobalRules = ElementHidingRule[]; | ||||||
|
||||||
type DomainRules = { | ||||||
domain: string | string[]; | ||||||
rules: ElementHidingRule[]; | ||||||
}; | ||||||
|
||||||
type ElementHidingSettings = { | ||||||
rules: GlobalRules; | ||||||
domains: DomainRules[]; | ||||||
[key: string]: any; | ||||||
}; | ||||||
|
||||||
export type ElementHidingFeature<VersionType> = Feature<ElementHidingSettings, VersionType>; | ||||||
|
||||||
export type ElementHidingSettingsType = ElementHidingSettings; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { expect } from 'chai'; | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import { createValidator, formatErrors } from './schema-validation.js'; | ||
import { createValidator, createHybridValidator, formatErrors } from './schema-validation.js'; | ||
import platforms from './../platforms.js'; | ||
import { immutableJSONPatch } from 'immutable-json-patch'; | ||
import { getBaseFeatureConfigs } from '../util.js'; | ||
|
@@ -55,7 +55,7 @@ describe('Config schema tests', () => { | |
}); | ||
|
||
it('should validate against the full configV5 schema', () => { | ||
const validate = createValidator(platformSpecificSchemas[config.name] || 'CurrentGenericConfig'); | ||
const validate = createHybridValidator(platformSpecificSchemas[config.name] || 'CurrentGenericConfig'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a bit of a red flag there's a change needed here. or is this just temporary? |
||
expect(validate(config.body)).to.be.equal(true, formatErrors(validate.errors)); | ||
}); | ||
|
||
|
@@ -128,7 +128,7 @@ describe('Config schema tests', () => { | |
}); | ||
|
||
it('All patchSettings should also be valid', () => { | ||
const validate = createValidator(platformSpecificSchemas[config.name] || 'CurrentGenericConfig'); | ||
const validate = createHybridValidator(platformSpecificSchemas[config.name] || 'CurrentGenericConfig'); | ||
function applyPatchAndValidate(featureName, feature, conditionalChange, config) { | ||
for (const change of conditionalChange) { | ||
if (!change.patchSettings) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Missing Values Property in Modify-Style Rule
The
modify-style
rule forabcnews.go.com
's.navigation
selector is missing its requiredvalues
property. Per theelement-hiding.ts
schema,modify-style
rules need this array to define style modifications, making the current rule invalid and non-functional.