Skip to content
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

fix: move wasm engine to handle featureEnabled not feature_enabled #149

Merged
merged 3 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions unleash-yggdrasil/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ pest_derive = "2.0"
lazy_static = "1.4.0"
semver = "1.0.17"
convert_case = "0.6.0"
unleash-types = "0.13.0"
unleash-types = "0.14.0"
chrono = "0.4.38"
dashmap = "5.5.0"
hostname = { version = "0.3.1", optional = true }
dashmap = "6.1.0"
hostname = { version = "0.4.0", optional = true }
ipnetwork = "0.20.0"

[dependencies.serde]
Expand Down
2 changes: 1 addition & 1 deletion yggdrasilffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ name = "yggdrasilffi"
libc = "0.2"
serde_json = "1.0.68"
serde = { version = "1.0.68", features = ["derive"] }
unleash-types = "0.13.0"
unleash-types = "0.14.0"
unleash-yggdrasil = {path = "../unleash-yggdrasil"}
2 changes: 1 addition & 1 deletion yggdrasilwasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ default = ["console_error_panic_hook"]

[dependencies]
wasm-bindgen = "0.2"
unleash-types = "0.13.0"
unleash-types = "0.14.0"
unleash-yggdrasil = {path = "../unleash-yggdrasil"}
getrandom = { version = "0.2", features = ["js"] }

Expand Down
32 changes: 25 additions & 7 deletions yggdrasilwasm/e2e-tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ type VariantTest = BaseTest & {
expectedResult: Record<string, unknown>
}

type VariantResponse = {
featureEnabled: boolean,
payload: Record<string, string>,
enabled: boolean,
name: string
}

type LegacyVariantResponse = {
feature_enabled: boolean,
payload: Record<string, string>,
enabled: boolean,
name: string
}

type TestSuite = {
state: Record<string, unknown>
tests: ToggleTest[]
Expand All @@ -26,9 +40,9 @@ const DISABLED_VARIANT = {
enabled: false
}

const getDisabledVariant = (feature_enabled: boolean) => ({
const getDisabledVariant = (featureEnabled: boolean) => ({
...DISABLED_VARIANT,
feature_enabled
featureEnabled
})

type Response = {
Expand Down Expand Up @@ -84,7 +98,8 @@ describe('Client Spec Tests', () => {

for (const variantTest of variantTests) {
const toggleName = variantTest.toggleName
const expectedResult = JSON.stringify(variantTest.expectedResult)
const expectedResult = variantTest.expectedResult as any as LegacyVariantResponse;


test(`Variant Test: ${variantTest.description}`, () => {
const variantResponse = engine.checkVariant(
Expand All @@ -99,14 +114,17 @@ describe('Client Spec Tests', () => {
undefined
)

const feature_enabled =
const featureEnabled =
extractResult<boolean>(toggleResponse) ?? false

const result =
extractResult(variantResponse) ??
getDisabledVariant(feature_enabled)
extractResult<VariantResponse>(variantResponse) ??
getDisabledVariant(featureEnabled)

expect(JSON.stringify(result)).toBe(expectedResult)
expect(result.name).toBe(expectedResult.name);
expect(result.enabled).toBe(expectedResult.enabled);
expect(result.featureEnabled).toBe(expectedResult.feature_enabled);
expect(result.payload).toEqual(expectedResult.payload);
})
}
})
Expand Down
Loading