-
Notifications
You must be signed in to change notification settings - Fork 2
test(browser): execute packed package in Chromium #366
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
Merged
sameerank
merged 3 commits into
sameerank/FFL-2835/configuration-from-string
from
agent/browser-chromium-smoke
Aug 13, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import { defineConfig, devices } from '@playwright/test' | ||
|
|
||
| export default defineConfig({ | ||
| testDir: './tests', | ||
| outputDir: './node_modules/.cache/playwright-test', | ||
| reporter: 'line', | ||
| workers: 1, | ||
| use: { | ||
| baseURL: 'http://127.0.0.1:4173', | ||
| }, | ||
| webServer: { | ||
| command: 'yarn preview --host 127.0.0.1 --port 4173', | ||
| url: 'http://127.0.0.1:4173', | ||
| reuseExistingServer: false, | ||
| }, | ||
| projects: [ | ||
| { | ||
| name: 'chromium', | ||
| use: { ...devices['Desktop Chrome'] }, | ||
| }, | ||
| ], | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <!doctype html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <title>Datadog OpenFeature precomputed browser smoke test</title> | ||
| </head> | ||
| <body> | ||
| <pre id="app"></pre> | ||
| <script type="module" src="/src/precomputed.ts"></script> | ||
| </body> | ||
| </html> |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import { configurationFromString, configurationToString } from '@datadog/openfeature-browser/precomputed' | ||
| import { assert, reportSuccess } from './smoke' | ||
|
|
||
| const response = { | ||
| data: { | ||
| attributes: { | ||
| createdAt: '2026-07-06T23:01:56.822Z', | ||
| flags: { | ||
| 'precomputed-flag': { | ||
| allocationKey: 'allocation', | ||
| variationKey: 'on', | ||
| variationType: 'BOOLEAN', | ||
| variationValue: true, | ||
| reason: 'STATIC', | ||
| doLog: true, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| } | ||
| const configuration = configurationFromString( | ||
| JSON.stringify({ | ||
| version: 1, | ||
| precomputed: { response: JSON.stringify(response) }, | ||
| rules: { response: 'ignored by the precomputed entrypoint' }, | ||
| }) | ||
| ) | ||
| const serialized = configurationToString(configuration) | ||
| const roundTripWire = JSON.parse(serialized) as Record<string, unknown> | ||
| const restored = configurationFromString(serialized) | ||
| const flag = configuration.precomputed?.response.data.attributes.flags['precomputed-flag'] | ||
| const restoredFlag = restored.precomputed?.response.data.attributes.flags['precomputed-flag'] | ||
|
|
||
| assert(flag?.variationValue === true, 'precomputed flag was not parsed') | ||
| assert(configuration.rules === undefined, 'precomputed entrypoint parsed rules') | ||
| assert(roundTripWire.rules === undefined, 'precomputed entrypoint serialized rules') | ||
| assert(restoredFlag?.variationValue === true, 'precomputed flag did not survive a round trip') | ||
|
|
||
| reportSuccess({ | ||
| entrypoint: 'precomputed', | ||
| booleanValue: restoredFlag.variationValue, | ||
| rulesExcluded: true, | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| import { evaluateRulesBasedConfiguration, matchesRule, OperatorType } from '@datadog/flagging-core' | ||
| import { configurationFromString, configurationToString, DatadogProvider } from '@datadog/openfeature-browser' | ||
| import { assert, reportSuccess } from './smoke' | ||
|
|
||
| const protobufRulesResponse = | ||
| 'EgRwcm9kGigKDGJyb3dzZXItZmxhZxIYEAQaAigBIhAKCmFsbG9jYXRpb24iAiADGigKDGludGVnZXItZmxhZxIYEAIaAhgqIhAKCmFsbG9jYXRpb24iAiADKgJvbg==' | ||
| const precomputedResponse = { | ||
| data: { | ||
| attributes: { | ||
| createdAt: '2026-07-06T23:01:56.822Z', | ||
| flags: { | ||
| 'provider-flag': { | ||
| allocationKey: 'allocation', | ||
| variationKey: 'on', | ||
| variationType: 'BOOLEAN', | ||
| variationValue: true, | ||
| reason: 'STATIC', | ||
| doLog: false, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| } | ||
| const configuration = configurationFromString( | ||
| JSON.stringify({ | ||
| version: 1, | ||
| precomputed: { response: JSON.stringify(precomputedResponse) }, | ||
| rules: { response: protobufRulesResponse }, | ||
| }) | ||
| ) | ||
|
|
||
| assert(configuration.rules, 'protobuf rules configuration was not decoded') | ||
| assert( | ||
| configuration.rules.response.$typeName === 'datadog.ffe.flagging.ufc.v1.FlagsConfiguration', | ||
| 'rules response is not a generated protobuf message' | ||
| ) | ||
|
|
||
| const context = { targetingKey: 'browser-user' } | ||
| const booleanDetails = evaluateRulesBasedConfiguration( | ||
| configuration.rules.response, | ||
| 'boolean', | ||
| 'browser-flag', | ||
| false, | ||
| context, | ||
| console | ||
| ) | ||
| const integerDetails = evaluateRulesBasedConfiguration( | ||
| configuration.rules.response, | ||
| 'number', | ||
| 'integer-flag', | ||
| 0, | ||
| context, | ||
| console | ||
| ) | ||
| const provider = new DatadogProvider({ | ||
| clientToken: 'test-token', | ||
| site: 'datadoghq.com', | ||
| env: 'test', | ||
| enableExposureLogging: false, | ||
| enableFlagEvaluationTracking: false, | ||
| enableRumFeatureFlagTracking: false, | ||
| initialFlagsConfiguration: configuration, | ||
| }) | ||
| const providerDetails = provider.resolveBooleanEvaluation('provider-flag', false, context, console) | ||
| const restored = configurationFromString(configurationToString(configuration)) | ||
| const sha256Matched = matchesRule( | ||
| { | ||
| conditions: [ | ||
| { | ||
| attribute: 'name', | ||
| operator: OperatorType.ONE_OF_SHA256, | ||
| value: { | ||
| salt: [1, 2], | ||
| hashes: ['c0e551d80aa1e2cb1eaf5be7edbb04e51eb1823e562e2ce5dfeda0ecba76c744'], | ||
| }, | ||
| }, | ||
| ], | ||
| }, | ||
| { name: 'hello' } | ||
| ) | ||
|
|
||
| assert(booleanDetails.value === true, 'protobuf boolean evaluation returned the wrong value') | ||
| assert(integerDetails.value === 42, 'protobuf int64 evaluation returned the wrong value') | ||
| assert(providerDetails.value === true, 'DatadogProvider did not evaluate the decoded configuration') | ||
| assert( | ||
| restored.rules?.response.$typeName === 'datadog.ffe.flagging.ufc.v1.FlagsConfiguration', | ||
| 'protobuf rules configuration did not survive a round trip' | ||
| ) | ||
| assert(sha256Matched, 'SHA-256 condition did not match') | ||
|
|
||
| reportSuccess({ | ||
| entrypoint: 'protobuf', | ||
| protobufTypeName: configuration.rules.response.$typeName, | ||
| booleanValue: booleanDetails.value, | ||
| integerValue: integerDetails.value, | ||
| providerValue: providerDetails.value, | ||
| sha256Matched, | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| export function assert(condition: unknown, message: string): asserts condition { | ||
| if (!condition) throw new Error(message) | ||
| } | ||
|
|
||
| export function reportSuccess(result: Record<string, unknown>): void { | ||
| const global = globalThis as typeof globalThis & { __OPENFEATURE_SMOKE_RESULT__?: Record<string, unknown> } | ||
| global.__OPENFEATURE_SMOKE_RESULT__ = result | ||
|
|
||
| const app = document.querySelector<HTMLDivElement>('#app') | ||
| if (app) app.textContent = JSON.stringify(result, null, 2) | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.