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

feat: SSE Prep/Test Cleanup #432

Merged
merged 1 commit into from
Jun 12, 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
71 changes: 0 additions & 71 deletions .github/dependabot.yml

This file was deleted.

12 changes: 3 additions & 9 deletions harness/features/allFeatures.local.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { LocalTestClient, getSDKScope, hasCapability } from '../helpers'
import { Capabilities } from '../types'
import { config, expectedFeaturesVariationOn } from '../mockData/config'
import { expectedFeaturesVariationOn } from '../mockData'

describe('allFeatures Tests - Local', () => {
const { sdkName, scope } = getSDKScope()
Expand All @@ -10,7 +10,7 @@ describe('allFeatures Tests - Local', () => {

beforeEach(async () => {
testClient = new LocalTestClient(sdkName)
const configRequestUrl = `/client/${testClient.clientId}/config/v1/server/${testClient.sdkKey}.json`
const configRequestUrl = testClient.getValidConfigPath()
scope.get(configRequestUrl).times(2).reply(500)
await testClient.createClient(true, {
configPollingIntervalMS: 60000,
Expand All @@ -31,13 +31,7 @@ describe('allFeatures Tests - Local', () => {
let testClient: LocalTestClient

beforeEach(async () => {
testClient = new LocalTestClient(sdkName)
scope
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this not setting up the config mock anymore?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's set in the client constructor

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by passing in the scope as a param - it sets the initial successful config

.get(
`/client/${testClient.clientId}/config/v1/server/${testClient.sdkKey}.json`,
)
.reply(200, config)

testClient = new LocalTestClient(sdkName, scope)
if (hasCapability(sdkName, Capabilities.sdkConfigEvent)) {
scope
.post(`/client/${testClient.clientId}/v1/events/batch`)
Expand Down
15 changes: 4 additions & 11 deletions harness/features/allVariables.local.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
hasCapability,
} from '../helpers'
import { Capabilities } from '../types'
import { config, variables } from '../mockData'
import { variables } from '../mockData'

describe('allVariables Tests - Local', () => {
const { sdkName, scope } = getSDKScope()
Expand All @@ -14,11 +14,9 @@ describe('allVariables Tests - Local', () => {
const delayClient = new LocalTestClient(sdkName)

let interceptor = scope
.get(
`/client/${delayClient.clientId}/config/v1/server/${delayClient.sdkKey}.json`,
)
.get(delayClient.getValidConfigPath())
.delay(2000)
interceptor.reply(200, config)
interceptor.reply(200, delayClient.getValidConfig())

if (hasCapability(sdkName, Capabilities.sdkConfigEvent)) {
interceptor = scope.post(
Expand Down Expand Up @@ -51,12 +49,7 @@ describe('allVariables Tests - Local', () => {
})

it('should return a variable map for a bucketed user', async () => {
const client = new LocalTestClient(sdkName)
scope
.get(
`/client/${client.clientId}/config/v1/server/${client.sdkKey}.json`,
)
.reply(200, config)
const client = new LocalTestClient(sdkName, scope)

if (hasCapability(sdkName, Capabilities.sdkConfigEvent)) {
scope
Expand Down
32 changes: 15 additions & 17 deletions harness/features/bootstrapping.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import {describeCapability, getSDKScope, hasCapability, LocalTestClient} from '../helpers'
import {
describeCapability,
getSDKScope,
hasCapability,
LocalTestClient,
} from '../helpers'
import { Capabilities } from '../types'
import { config } from '../mockData'
import immutable from 'object-path-immutable'

describe('Bootstrapping Tests', () => {
Expand All @@ -11,17 +15,14 @@ describe('Bootstrapping Tests', () => {

describe('not enabled client', () => {
beforeEach(async () => {
testClient = new LocalTestClient(sdkName)
scope
.get(
JamieSinn marked this conversation as resolved.
Show resolved Hide resolved
`/client/${testClient.clientId}/config/v1/server/${testClient.sdkKey}.json`,
)
.reply(200, config)
testClient = new LocalTestClient(sdkName, scope)

if (hasCapability(sdkName, Capabilities.sdkConfigEvent)) {
scope
.post(`/client/${testClient.clientId}/v1/events/batch`)
.reply(201, {message: 'Successfully received events.'})
.reply(201, {
message: 'Successfully received events.',
})
}

await testClient.createClient(true, {
Expand All @@ -43,23 +44,20 @@ describe('Bootstrapping Tests', () => {

describe('initialized client', () => {
beforeEach(async () => {
testClient = new LocalTestClient(sdkName)
scope
.get(
JamieSinn marked this conversation as resolved.
Show resolved Hide resolved
`/client/${testClient.clientId}/config/v1/server/${testClient.sdkKey}.json`,
)
.reply(200, config)
testClient = new LocalTestClient(sdkName, scope)

if (hasCapability(sdkName, Capabilities.sdkConfigEvent)) {
scope
.post(`/client/${testClient.clientId}/v1/events/batch`)
.reply(201, {message: 'Successfully received events.'})
.reply(201, {
message: 'Successfully received events.',
})
}

// create a different config clientside so we can make sure the bootstrapping method is using the right one
const clientsideConfig = {
...immutable.set(
config,
testClient.getValidConfig(),
'features.0.variations.0.variables.1.value',
'new string',
),
Expand Down
15 changes: 3 additions & 12 deletions harness/features/clientCustomData.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,13 @@ import {
getSDKScope,
} from '../helpers'
import { Capabilities } from '../types'
import { config } from '../mockData'

describe('Client Custom Data Tests', () => {
const { sdkName, scope } = getSDKScope()

describeCapability(sdkName, Capabilities.clientCustomData)(sdkName, () => {
it('should set client custom data and use it for segmentation', async () => {
const client = new LocalTestClient(sdkName)

scope
.get(
`/client/${client.clientId}/config/v1/server/${client.sdkKey}.json`,
)
.reply(200, config)
const client = new LocalTestClient(sdkName, scope)

scope.post(`/client/${client.clientId}/v1/events/batch`).reply(201)

Expand Down Expand Up @@ -51,11 +44,9 @@ describe('Client Custom Data Tests', () => {

it('should do nothing when client has not initialized', async () => {
const client = new LocalTestClient(sdkName)
const configCall = scope.get(
`/client/${client.clientId}/config/v1/server/${client.sdkKey}.json`,
)
const configCall = scope.get(client.getValidConfigPath())

configCall.delay(1000).reply(200, config)
configCall.delay(1000).reply(200, client.getValidConfig())

const customData = { 'should-bucket': true }
await client.createClient(false)
Expand Down
Loading
Loading