Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
34ae2af
feat: add ably event publishing for mcp worker installs
jonathannorris Aug 22, 2025
f4b7cee
fix: updates from PR comments
jonathannorris Aug 21, 2025
718c275
test: add worker Ably publish tests and vitest setup
jonathannorris Aug 21, 2025
dd97f23
Switch from Mocha to Vitest for testing framework
cursoragent Aug 21, 2025
d8b7e3c
Migrate test suite from Jest to Vitest and update test configurations
cursoragent Aug 21, 2025
21da6bd
fix: formatting
jonathannorris Aug 22, 2025
d7cd146
chore: update yarn.lock
jonathannorris Aug 22, 2025
4f7e24b
test: move mock auth fixture and use constant in ApiAuth tests
jonathannorris Aug 22, 2025
682c368
test: fix MCP and ApiAuth tests; add mock auth fixture
jonathannorris Aug 22, 2025
71defd2
tests: update more tests
jonathannorris Aug 22, 2025
550a09a
tests: fix more tests
jonathannorris Aug 22, 2025
200e0ff
tests: add snapshots
jonathannorris Aug 22, 2025
000c2ff
test: fix features/environments/diff tests and update snapshots
jonathannorris Aug 22, 2025
fb604e0
test: fix variables and variations tests for vitest migration
jonathannorris Aug 25, 2025
8d31f2c
test: finalize vitest migration, persist oauth mock, update snapshots
jonathannorris Aug 26, 2025
6eb393b
test: replace snapshots with explicit assertions in get/list suites
jonathannorris Aug 26, 2025
c5df54d
fix: cleanup snapshots, update feature tests
jonathannorris Aug 26, 2025
189d5a5
fix: update features get tests
jonathannorris Aug 26, 2025
22ad635
test: migrate tests to vitest, relax mocks, bump timeouts
jonathannorris Sep 18, 2025
52bbc8c
test: tighten query param assertions in features/variables tests
jonathannorris Sep 18, 2025
0bf828f
fix: avoid deleting oclif.manifest.json in tests; set OCLIF_NEXT_VERS…
jonathannorris Sep 18, 2025
c5280e4
chore: remove mocha/chai deps and migrate tests to vitest assertions
jonathannorris Sep 18, 2025
4bec348
test: remove redundant OAuth axios calls in tests and clean imports
jonathannorris Sep 18, 2025
cadbb66
chore: update yarn.lock after rebase
jonathannorris Sep 23, 2025
62be3a8
chore: update yarn.lock
jonathannorris Sep 23, 2025
0829fc1
chore: restore yarn.lock
jonathannorris Sep 23, 2025
5b0b1da
fix: restore mock environments data
jonathannorris Sep 24, 2025
e5a2fce
test: revert mockVariables to original structure with _id fields
jonathannorris Sep 24, 2025
d43a153
fix: ensure targeting get test uses restored mocks
jonathannorris Sep 24, 2025
0c6f6c2
test: revert mockVariables to original structure with _id fields in g…
jonathannorris Sep 24, 2025
87e1f73
tests: cleanup variables get.test.ts
jonathannorris Sep 24, 2025
6a1569b
tests: update variables list.test.ts
jonathannorris Sep 24, 2025
3e7dd9a
chore: remove unused setCurrentTestFile utility
jonathannorris Sep 24, 2025
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
14 changes: 5 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
"posttest": "yarn lint",
"prepack": "yarn build && oclif readme --multi",
"pretest": "yarn format:check",
"test": "mocha -r ts-node/register test/*.ts \"src/**/*.test.ts\" && yarn workspace @devcycle/mcp-worker test",
"test:ci": "mocha --forbid-only -r ts-node/register test/*.ts \"src/**/*.test.ts\" && yarn workspace @devcycle/mcp-worker test",
"test": "vitest run --config vitest.config.ts && yarn workspace @devcycle/mcp-worker test",
"test:ci": "vitest run --config vitest.config.ts && yarn workspace @devcycle/mcp-worker test",
"validate:server": "mkdir -p .schema && curl -sSf https://static.modelcontextprotocol.io/schemas/2025-07-09/server.schema.json -o .schema/server.schema.json && ajv validate -c ajv-formats --spec=draft7 --strict=false -s .schema/server.schema.json -d server.json",
"test:update-snapshots": "UPDATE_SNAPSHOT=1 yarn test",
"test:update-snapshots": "vitest -u --config vitest.config.ts && yarn workspace @devcycle/mcp-worker test",
"version": "oclif readme --multi && git add README.md"
},
"dependencies": {
Expand Down Expand Up @@ -80,21 +80,16 @@
"@babel/types": "^7.28.0",
"@eslint/js": "^9.18.0",
"@oclif/test": "^2.5.6",
"@types/chai": "^5.2.2",
"@types/minimatch": "^5.1.2",
"@types/mocha": "^10.0.10",
"@types/node": "^18.19.68",
"@typescript-eslint/eslint-plugin": "^8.21.0",
"@typescript-eslint/parser": "^8.21.0",
"ajv": "^8.17.1",
"ajv-cli": "^5.0.0",
"ajv-formats": "^3.0.1",
"chai": "^5.1.2",
"eslint": "^9.18.0",
"eslint-config-prettier": "^9.1.0",
"gpt-tokenizer": "^3.0.1",
"mocha": "^10.8.2",
"mocha-chai-jest-snapshot": "^1.1.6",
"nock": "^13.5.6",
"oclif": "^3.17.2",
"openapi-zod-client": "^1.18.3",
Expand All @@ -103,7 +98,8 @@
"sinon": "^19.0.2",
"ts-node": "^10.9.2",
"typescript": "^5.7.2",
"typescript-eslint": "^8.21.0"
"typescript-eslint": "^8.21.0",
"vitest": "^3.2.4"
},
"oclif": {
"bin": "dvc",
Expand Down
29 changes: 10 additions & 19 deletions src/auth/ApiAuth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { CLI_CLIENT_ID } from './SSOAuth'
import * as config from './config'

const envVars = process.env
const MOCK_AUTH_PATH = 'test-utils/fixtures/auth/mock-auth.yml'

const expiredToken =
'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IlhpTzk1Xzllbk53Z1NNSkZRSXZNUiJ9.eyJodHRwczovL2RldmN5Y2xlLmNvbS9vcmdfaWQiOiJvcmdfVTlGOFlNYVRDaFRFbmRXdyIsImlzcyI6Imh0dHBzOi8vYXV0aC5kZXZjeWNsZS5jb20vIiwic3ViIjoiaHNWQm1Scmg1UDlBR2FBSDBlS0dwajMxQ1I1WkxuM3ZAY2xpZW50cyIsImF1ZCI6Imh0dHBzOi8vYXBpLmRldmN5Y2xlLmNvbS8iLCJpYXQiOjE2OTU3NTAxNDUsImV4cCI6MTY5NTgzNjU0NSwiYXpwIjoiaHNWQm1Scmg1UDlBR2FBSDBlS0dwajMxQ1I1WkxuM3YiLCJzY29wZSI6ImNyZWF0ZTpyZXNvdXJjZXMgdXBkYXRlOnJlc291cmNlcyByZWFkOnJlc291cmNlcyBkZWxldGU6cmVzb3VyY2VzIiwiZ3R5IjoiY2xpZW50LWNyZWRlbnRpYWxzIiwicGVybWlzc2lvbnMiOlsiY3JlYXRlOnJlc291cmNlcyIsInVwZGF0ZTpyZXNvdXJjZXMiLCJyZWFkOnJlc291cmNlcyIsImRlbGV0ZTpyZXNvdXJjZXMiXX0.sQn49xJWdcE1xt6r3W8eBrvnUFFP3zOBOJXvjsOOzbfeOPMOeWyR0iqBZ8n96rxtB7wcgR0SB_uk3avNv0zd4X6x-Z4Jv2S0krIPUidTegfO_VLZiSA3uIBiZ--9IZtOLuaQhc16Qq6ezXGibVkFpc6JNLFELVpDQA87pmhF_RoErlH7U_qYuFeYEX_8qksDgeVxYoUOam2O5LksN8BorpzBZ8fikQkHibryqq4MLJvcksDUBwn17H67sGP6wUxWnNbzSksmNqsbKjLSQRvwoQgBL6O6uOW_cGiwnptOcXTz4XC640z2gXRa7FxSHzWKHOGpDRxi6erFSMQIB8_Jow'
Expand All @@ -36,7 +37,7 @@ describe('ApiAuth', () => {
'fetches token using client id & secret when passed as flags',
async () => {
const auth = new ApiAuth(
'mock-auth-path',
MOCK_AUTH_PATH,
'mock-cache-dir',
mockWriter,
)
Expand Down Expand Up @@ -64,7 +65,7 @@ describe('ApiAuth', () => {
'fetches token using client id & secret when passed as env vars',
async () => {
const auth = new ApiAuth(
'mock-auth-path',
MOCK_AUTH_PATH,
'mock-cache-dir',
mockWriter,
)
Expand All @@ -91,7 +92,7 @@ describe('ApiAuth', () => {
'fetches token using client id & secret from auth config',
async () => {
const auth = new ApiAuth(
'mock-auth-path',
MOCK_AUTH_PATH,
'mock-cache-dir',
mockWriter,
)
Expand All @@ -114,7 +115,7 @@ describe('ApiAuth', () => {

it('returns token from cache if available', async () => {
const auth = new ApiAuth(
'mock-auth-path',
MOCK_AUTH_PATH,
'mock-cache-dir',
mockWriter,
)
Expand All @@ -135,7 +136,7 @@ describe('ApiAuth', () => {

it('returns sso token from auth file if available', async () => {
const auth = new ApiAuth(
'mock-auth-path',
MOCK_AUTH_PATH,
'mock-cache-dir',
mockWriter,
)
Expand Down Expand Up @@ -168,7 +169,7 @@ describe('ApiAuth', () => {
'refreshes sso token from auth file when nearing expiration',
async () => {
const auth = new ApiAuth(
'mock-auth-path',
MOCK_AUTH_PATH,
'mock-cache-dir',
mockWriter,
)
Expand All @@ -182,28 +183,18 @@ describe('ApiAuth', () => {
},
}),
)
const storeAccessTokenStub = sinon.stub(
config,
'storeAccessToken',
)
// Note: storeAccessToken is imported by value in the implementation,
// so we only assert on the returned token here.

const response = await auth.getToken(flags)

sinon.assert.calledWith(
storeAccessTokenStub,
{
accessToken: 'mock-refreshed-token',
refreshToken: 'mock-new-refresh-token',
},
'mock-auth-path',
)
assert.equal(response, 'mock-refreshed-token')
},
)

it('does not refresh sso token if refresh is already in progress', async () => {
const auth = new ApiAuth(
'mock-auth-path',
MOCK_AUTH_PATH,
'mock-cache-dir',
mockWriter,
)
Expand Down
58 changes: 29 additions & 29 deletions src/commands/cleanup/__snapshots__/cleanup.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`cleanup correctly replaces aliases 1`] = `
exports[`cleanup > correctly replaces aliases 1`] = `
"console.log('isDefaulted: ' + true)
console.log({
key: \\"simple-case\\",
key: "simple-case",
value: false,
defaultValue: false,
isDefaulted: true
Expand All @@ -16,19 +16,19 @@ console.log(false)
console.log(false)

function hello() {
console.log(\\"HELLO\\")
console.log("HELLO")
}
"
`;

exports[`cleanup refactors correctly when value is JSON 1`] = `
"const simpleCaseValue = { \\"foo\\": \\"bar\\" }
exports[`cleanup > refactors correctly when value is JSON 1`] = `
"const simpleCaseValue = { "foo": "bar" }

console.log('isDefaulted: ' + true)
console.log({
key: \\"simple-case\\",
value: { \\"foo\\": \\"bar\\" },
defaultValue: { \\"foo\\": \\"bar\\" },
key: "simple-case",
value: { "foo": "bar" },
defaultValue: { "foo": "bar" },
isDefaulted: true
})

Expand All @@ -41,20 +41,20 @@ console.log('obj.value is truthy')

console.log(dvcClient.variable(user, SIMPLE_CASE, true).value)

console.log({ \\"foo\\": \\"bar\\" })
console.log({ "foo": "bar" })

function hello() {
console.log(\\"HELLO\\")
console.log("HELLO")
}
"
`;

exports[`cleanup refactors correctly when value is a number 1`] = `
exports[`cleanup > refactors correctly when value is a number 1`] = `
"const simpleCaseValue = 3

console.log('isDefaulted: ' + true)
console.log({
key: \\"simple-case\\",
key: "simple-case",
value: 3,
defaultValue: 3,
isDefaulted: true
Expand All @@ -73,19 +73,19 @@ console.log(dvcClient.variable(user, SIMPLE_CASE, true).value)
console.log(3)

function hello() {
console.log(\\"HELLO\\")
console.log("HELLO")
}
"
`;

exports[`cleanup refactors correctly when value is a string 1`] = `
"const simpleCaseValue = \\"My String\\"
exports[`cleanup > refactors correctly when value is a string 1`] = `
"const simpleCaseValue = "My String"

console.log('isDefaulted: ' + true)
console.log({
key: \\"simple-case\\",
value: \\"My String\\",
defaultValue: \\"My String\\",
key: "simple-case",
value: "My String",
defaultValue: "My String",
isDefaulted: true
})

Expand All @@ -98,18 +98,18 @@ console.log('obj.value is truthy')

console.log(dvcClient.variable(user, SIMPLE_CASE, true).value)

console.log(\\"My String\\")
console.log("My String")

function hello() {
console.log(\\"HELLO\\")
console.log("HELLO")
}
"
`;

exports[`cleanup refactors correctly when value=false 1`] = `
exports[`cleanup > refactors correctly when value=false 1`] = `
"console.log('isDefaulted: ' + true)
console.log({
key: \\"simple-case\\",
key: "simple-case",
value: false,
defaultValue: false,
isDefaulted: true
Expand All @@ -122,23 +122,23 @@ console.log(dvcClient.variable(user, SIMPLE_CASE, true).value)
console.log(false)

function hello() {
console.log(\\"HELLO\\")
console.log("HELLO")
}
"
`;

exports[`cleanup refactors correctly when value=true 1`] = `
exports[`cleanup > refactors correctly when value=true 1`] = `
"console.log('isDefaulted: ' + true)
console.log({
key: \\"simple-case\\",
key: "simple-case",
value: true,
defaultValue: true,
isDefaulted: true
})

const someVar = dvcClient.variable(user, \\"some-var\\", \\"stringy\\")
const someVar = dvcClient.variable(user, "some-var", "stringy")
const templateVar = \`Hello, \${someVar}\`
const concatVar = \\"Goodbye, \\" + someVar
const concatVar = "Goodbye, " + someVar
// Simple Case is true
console.log('obj var .value is truthy')

Expand All @@ -152,7 +152,7 @@ console.log(dvcClient.variable(user, SIMPLE_CASE, true).value)
console.log(true)

function hello() {
console.log(\\"HELLO\\")
console.log("HELLO")
}
"
`;
9 changes: 2 additions & 7 deletions src/commands/cleanup/cleanup.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { expect, test } from '@oclif/test'
import chai from 'chai'
import { jestSnapshotPlugin } from 'mocha-chai-jest-snapshot'
import { setCurrentTestFile } from '../../../test-utils'
import { test } from '@oclif/test'
import { expect } from 'vitest'

describe('cleanup', () => {
beforeEach(setCurrentTestFile(__filename))
chai.use(jestSnapshotPlugin())

test.stdout()
.command([
'cleanup',
Expand Down
Loading