Skip to content

Commit

Permalink
Merge pull request #205 from nuance-communications/beta
Browse files Browse the repository at this point in the history
fix: merge beta to main
  • Loading branch information
grof authored Nov 30, 2023
2 parents dbce8d0 + 3a0bbf6 commit 644d553
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

strategy:
matrix:
node-version: [16.x, 18.x]
node-version: [18.x, 20.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
Expand Down
17 changes: 12 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@oclif/plugin-autocomplete": "^1.3.0",
"@oclif/plugin-help": "^5",
"@oclif/plugin-plugins": "^2.1.12",
"axios": "0.26.0",
"axios": "1.6.2",
"chalk": "4.1.2",
"date-fns": "2.28.0",
"debug": "4.3.3",
Expand Down
4 changes: 2 additions & 2 deletions src/mix/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* the LICENSE file in the root directory of this source tree.
*/

import axios, {AxiosRequestHeaders} from 'axios'
import axios, {RawAxiosRequestHeaders} from 'axios'
import makeDebug from 'debug'

import {
Expand Down Expand Up @@ -52,7 +52,7 @@ export function createMixClient(options: MixClientOptions) {
debug(`request method: ${method}`)
debug(`request url: ${url}`)
debug('request body: %O', data)
const augmentedHeaders: AxiosRequestHeaders = {
const augmentedHeaders: RawAxiosRequestHeaders = {
Authorization: bearerToken,
'User-Agent': userAgent,
...headers}
Expand Down
21 changes: 9 additions & 12 deletions test/commands/grammars/replace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {expect, test} from '@oclif/test'
import {mixAPIServerURL} from '../../mocks'
import testData from './grammars-test-data'

import * as createFormModule from '../../../src/mix/api/utils/create-form'
import * as CreateFormModule from '../../../src/mix/api/utils/create-form'

const chai = require('chai')
const sinon = require('sinon')
Expand All @@ -25,26 +25,23 @@ const {
grammarsReplaceResponse,
} = testData

const getHeaders = () => ({
'Content-Type': 'multipart/form-data; boundary=--------------------------461709635804907982362641'
})
const form = new FormData() as any
form.append('file', Buffer.alloc(10))
form.getHeaders = () => {}

describe('grammars:replace command', () => {
const projectId = '254'
const entityName = 'DrinkEntity'
const filepath = `./grammars.grxml`
const endpoint = `/v4/projects/${projectId}/entities/${entityName}/grammars/.replace`
const promptStub = sinon.stub()
const createFormStub = sinon.stub().returns({getHeaders})

const createFormStub = sinon.stub().returns(form)

afterEach(() => {
promptStub.reset()
})

after(() => {
createFormStub.reset()
})

describe('grammars:replace command with valid projectId, entityName and filepath', () => {
describe('grammars:replace command with user confirmation', () => {
test
Expand All @@ -57,7 +54,7 @@ describe('grammars:replace command', () => {
.post(endpoint)
.reply(200, grammarsReplaceResponse)
)
.stub(createFormModule, 'createForm', () => createFormStub(filepath))
.stub(CreateFormModule, 'createForm', createFormStub)
.stdout()
.stderr()
.command(['grammars:replace', '-P', projectId, '-E', entityName, '-f', filepath])
Expand Down Expand Up @@ -88,7 +85,7 @@ describe('grammars:replace command', () => {
.post(endpoint)
.reply(200, grammarsReplaceResponse)
)
.stub(createFormModule, 'createForm', () => createFormStub(filepath))
.stub(CreateFormModule, 'createForm', createFormStub)
.stdout()
.command(['grammars:replace',
`-P=${projectId}`,
Expand All @@ -105,7 +102,7 @@ describe('grammars:replace command', () => {

const wrongEntity = 'Drnk'
test
.stub(createFormModule, 'createForm', createFormStub)
.stub(CreateFormModule, 'createForm', createFormStub)
.stdout()
.command(['grammars:replace',
`-P=${projectId}`,
Expand Down
12 changes: 4 additions & 8 deletions test/commands/literals/import.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,18 @@ const endpoints = {
replace: `/v4/projects/1922/entities/DrinkSize/literals/.replace`,
}

const getHeaders = () => ({
'Content-Type': 'multipart/form-data; boundary=--------------------------461709635804907982362641'
})
const form = new FormData() as any
form.append('file', Buffer.alloc(10))
form.getHeaders = () => {}

describe('literals:import command', () => {
const promptStub = sinon.stub()
const createFormStub = sinon.stub().returns({getHeaders})
const createFormStub = sinon.stub().returns(form)

afterEach(() => {
promptStub.reset()
})

after(() => {
createFormStub.reset()
})

test
.env(testData.env)
.do(() => {
Expand Down
15 changes: 6 additions & 9 deletions test/commands/ontology/import.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,19 @@ const serverURL = `https://${testData.server}`

const endpoint = `/v4/projects/1922/ontology/.append`

const getHeaders = () => ({
'Content-Type': 'multipart/form-data; boundary=--------------------------461709635804907982362641'
})

describe('ontology:import command', () => {
const promptStub = sinon.stub()
const createFormStub = sinon.stub().returns({getHeaders})

const form = new FormData() as any
form.append('file', Buffer.alloc(10))
form.getHeaders = () => {}

const createFormStub = sinon.stub().returns(form)

afterEach(() => {
promptStub.reset()
})

after(() => {
createFormStub.reset()
})

test
.env(testData.env)
.do(() => {
Expand Down
10 changes: 4 additions & 6 deletions test/commands/projects/replace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,18 @@ const td = require('./projects-test-data')
const testEnvData = require('../../test-data')
const serverURL = `https://${testEnvData.server}`

const getHeaders = () => ({
'Content-Type': 'multipart/form-data; boundary=--------------------------461709635804907982362641'
})
const form = new FormData() as any
form.append('file', Buffer.alloc(10))
form.getHeaders = () => {}

describe('projects:replace', () => {
const promptStub = sinon.stub()
const createFormStub = sinon.stub().returns({getHeaders})
const createFormStub = sinon.stub().returns(form)

afterEach(() => {
promptStub.reset()
})

after(() => {createFormStub.reset()})

test
.env(testEnvData.env)
.do(() => {
Expand Down
12 changes: 4 additions & 8 deletions test/commands/samples/import.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,18 @@ const endpoints = {
replace: `/v4/projects/1922/intents/ORDER_DRINK/samples/.replace`,
}

const getHeaders = () => ({
'Content-Type': 'multipart/form-data; boundary=--------------------------461709635804907982362641'
})
const form = new FormData() as any
form.append('file', Buffer.alloc(10))
form.getHeaders = () => {}

describe('samples:import command', () => {
const promptStub = sinon.stub()
const createFormStub = sinon.stub().returns({getHeaders})
const createFormStub = sinon.stub().returns(form)

afterEach(() => {
promptStub.reset()
})

after(() => {
createFormStub.reset()
})

test
.env(testData.env)
.do(() => {
Expand Down

0 comments on commit 644d553

Please sign in to comment.