Skip to content
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
43 changes: 20 additions & 23 deletions src/adapters/file-upload.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,14 @@ describe('FileUpload Adapter', () => {

expect(cliux.inquire).toHaveBeenCalledWith(
expect.objectContaining({
type: 'input',
type: 'list',
name: 'responseMode',
message: 'Response Mode (s: streaming, b: buffered)',
message: 'Choose a response mode',
default: 'buffered',
validate: expect.any(Function),
choices: [
{ name: 'Buffered', value: 'buffered' },
{ name: 'Streaming', value: 'streaming' },
],
}),
);
expect(fileUploadInstance.config.isStreamingEnabled).toBe(true);
Expand Down Expand Up @@ -484,11 +487,14 @@ describe('FileUpload Adapter', () => {
expect(serverCommandCalls.length).toBe(0);
expect(cliux.inquire).toHaveBeenCalledWith(
expect.objectContaining({
type: 'input',
type: 'list',
name: 'responseMode',
message: 'Response Mode (s: streaming, b: buffered)',
message: 'Choose a response mode',
default: 'buffered',
validate: expect.any(Function),
choices: [
{ name: 'Buffered', value: 'buffered' },
{ name: 'Streaming', value: 'streaming' },
],
}),
);
expect(fileUploadInstance.config.isStreamingEnabled).toBe(true);
Expand Down Expand Up @@ -547,15 +553,9 @@ describe('FileUpload Adapter', () => {
});

it.each([
['s', true],
['streaming', true],
['STREAMING', true],
[' Streaming ', true],
['b', false],
['buffered', false],
['BUFFERED', false],
[' Buffered ', false],
])('should map Response Mode input "%s" to isStreamingEnabled %s', async (input, expected) => {
])('should map Response Mode selection "%s" to isStreamingEnabled %s', async (input, expected) => {
(cliux.inquire as jest.Mock).mockResolvedValueOnce('test-project');
(cliux.inquire as jest.Mock).mockResolvedValueOnce('Default');
(cliux.inquire as jest.Mock).mockResolvedValueOnce('npm run build');
Expand Down Expand Up @@ -599,7 +599,7 @@ describe('FileUpload Adapter', () => {
handleEnvImportFlowMock.mockRestore();
});

it('Response Mode validate should accept s/b/streaming/buffered and reject anything else', async () => {
it('Response Mode prompt should offer buffered and streaming choices', async () => {
(cliux.inquire as jest.Mock).mockResolvedValueOnce('test-project');
(cliux.inquire as jest.Mock).mockResolvedValueOnce('Default');
(cliux.inquire as jest.Mock).mockResolvedValueOnce('npm run build');
Expand Down Expand Up @@ -638,15 +638,12 @@ describe('FileUpload Adapter', () => {
const responseModeCall = (cliux.inquire as jest.Mock).mock.calls.find(
(call) => call[0]?.name === 'responseMode',
);
const { validate } = responseModeCall[0];

expect(validate('s')).toBe(true);
expect(validate('streaming')).toBe(true);
expect(validate('b')).toBe(true);
expect(validate('buffered')).toBe(true);
expect(validate(' STREAMING ')).toBe(true);
expect(validate('')).toBe('Please enter "s"/"streaming" or "b"/"buffered".');
expect(validate('yes')).toBe('Please enter "s"/"streaming" or "b"/"buffered".');

expect(responseModeCall[0].type).toBe('list');
expect(responseModeCall[0].choices).toEqual([
{ name: 'Buffered', value: 'buffered' },
{ name: 'Streaming', value: 'streaming' },
]);

createSignedUploadUrlMock.mockRestore();
archiveMock.mockRestore();
Expand Down
20 changes: 8 additions & 12 deletions src/adapters/file-upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,21 +250,17 @@ export default class FileUpload extends BaseClass {
}
}
if (!responseMode) {
const responseModeInput = (await cliux.inquire({
type: 'input',
const selectedResponseMode = (await cliux.inquire({
type: 'list',
name: 'responseMode',
message: 'Response Mode (s: streaming, b: buffered)',
message: 'Choose a response mode',
default: 'buffered',
validate: (input: string) => {
const value = String(input).trim().toLowerCase();
if (['s', 'streaming', 'b', 'buffered'].includes(value)) {
return true;
}
return 'Please enter "s"/"streaming" or "b"/"buffered".';
},
choices: [
{ name: 'Buffered', value: 'buffered' },
{ name: 'Streaming', value: 'streaming' },
],
})) as string;
const normalizedResponseMode = String(responseModeInput ?? '').trim().toLowerCase();
this.config.isStreamingEnabled = normalizedResponseMode === 's' || normalizedResponseMode === 'streaming';
this.config.isStreamingEnabled = selectedResponseMode === 'streaming';
} else {
this.config.isStreamingEnabled = responseMode === 'streaming';
}
Expand Down
43 changes: 20 additions & 23 deletions src/adapters/github.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -597,11 +597,14 @@ describe('GitHub Adapter', () => {

expect(ux.inquire).toHaveBeenCalledWith(
expect.objectContaining({
type: 'input',
type: 'list',
name: 'responseMode',
message: 'Response Mode (s: streaming, b: buffered)',
message: 'Choose a response mode',
default: 'buffered',
validate: expect.any(Function),
choices: [
{ name: 'Buffered', value: 'buffered' },
{ name: 'Streaming', value: 'streaming' },
],
}),
);
expect(githubInstance.config.isStreamingEnabled).toBe(true);
Expand Down Expand Up @@ -714,11 +717,14 @@ describe('GitHub Adapter', () => {
expect(serverCommandCalls.length).toBe(0);
expect(ux.inquire).toHaveBeenCalledWith(
expect.objectContaining({
type: 'input',
type: 'list',
name: 'responseMode',
message: 'Response Mode (s: streaming, b: buffered)',
message: 'Choose a response mode',
default: 'buffered',
validate: expect.any(Function),
choices: [
{ name: 'Buffered', value: 'buffered' },
{ name: 'Streaming', value: 'streaming' },
],
}),
);
expect(githubInstance.config.isStreamingEnabled).toBe(false);
Expand Down Expand Up @@ -762,15 +768,9 @@ describe('GitHub Adapter', () => {
});

it.each([
['s', true],
['streaming', true],
['STREAMING', true],
[' Streaming ', true],
['b', false],
['buffered', false],
['BUFFERED', false],
[' Buffered ', false],
])('should map Response Mode input "%s" to isStreamingEnabled %s', async (input, expected) => {
])('should map Response Mode selection "%s" to isStreamingEnabled %s', async (input, expected) => {
(ux.inquire as jest.Mock).mockResolvedValueOnce('test-project');
(ux.inquire as jest.Mock).mockResolvedValueOnce('Default');
(ux.inquire as jest.Mock).mockResolvedValueOnce('npm run build');
Expand Down Expand Up @@ -802,7 +802,7 @@ describe('GitHub Adapter', () => {
handleEnvImportFlowMock.mockRestore();
});

it('Response Mode validate should accept s/b/streaming/buffered and reject anything else', async () => {
it('Response Mode prompt should offer buffered and streaming choices', async () => {
(ux.inquire as jest.Mock).mockResolvedValueOnce('test-project');
(ux.inquire as jest.Mock).mockResolvedValueOnce('Default');
(ux.inquire as jest.Mock).mockResolvedValueOnce('npm run build');
Expand Down Expand Up @@ -832,15 +832,12 @@ describe('GitHub Adapter', () => {
const responseModeCall = (ux.inquire as jest.Mock).mock.calls.find(
(call) => call[0]?.name === 'responseMode',
);
const { validate } = responseModeCall[0];

expect(validate('s')).toBe(true);
expect(validate('streaming')).toBe(true);
expect(validate('b')).toBe(true);
expect(validate('buffered')).toBe(true);
expect(validate(' STREAMING ')).toBe(true);
expect(validate('')).toBe('Please enter "s"/"streaming" or "b"/"buffered".');
expect(validate('yes')).toBe('Please enter "s"/"streaming" or "b"/"buffered".');

expect(responseModeCall[0].type).toBe('list');
expect(responseModeCall[0].choices).toEqual([
{ name: 'Buffered', value: 'buffered' },
{ name: 'Streaming', value: 'streaming' },
]);

handleEnvImportFlowMock.mockRestore();
});
Expand Down
20 changes: 8 additions & 12 deletions src/adapters/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,21 +238,17 @@ export default class GitHub extends BaseClass {
}
}
if (!responseMode) {
const responseModeInput = (await ux.inquire({
type: 'input',
const selectedResponseMode = (await ux.inquire({
type: 'list',
name: 'responseMode',
message: 'Response Mode (s: streaming, b: buffered)',
message: 'Choose a response mode',
default: 'buffered',
validate: (input: string) => {
const value = String(input).trim().toLowerCase();
if (['s', 'streaming', 'b', 'buffered'].includes(value)) {
return true;
}
return 'Please enter "s"/"streaming" or "b"/"buffered".';
},
choices: [
{ name: 'Buffered', value: 'buffered' },
{ name: 'Streaming', value: 'streaming' },
],
})) as string;
const normalizedResponseMode = String(responseModeInput ?? '').trim().toLowerCase();
this.config.isStreamingEnabled = normalizedResponseMode === 's' || normalizedResponseMode === 'streaming';
this.config.isStreamingEnabled = selectedResponseMode === 'streaming';
} else {
this.config.isStreamingEnabled = responseMode === 'streaming';
}
Expand Down
Loading