Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
35 changes: 0 additions & 35 deletions packages/amazonq/test/e2e/amazonq/testGen.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,6 @@ describe('Amazon Q Test Generation', function () {
},
]

const unsupportedLanguages = [
// move these over to testFiles once these languages are supported
// must be atleast one unsupported language here for testing
{
language: 'typescript',
filePath: 'testGenFolder/src/main/math.ts',
},
{
language: 'javascript',
filePath: 'testGenFolder/src/main/math.js',
},
]

// handles opening the file since /test must be called on an active file
async function setupTestDocument(filePath: string, language: string) {
const document = await waitUntil(async () => {
Expand Down Expand Up @@ -125,28 +112,6 @@ describe('Amazon Q Test Generation', function () {
})

describe('/test entry', () => {
describe('Unsupported language file', () => {
const { language, filePath } = unsupportedLanguages[0]

beforeEach(async () => {
await setupTestDocument(filePath, language)
})

it(`/test for unsupported language redirects to chat`, async () => {
tab.addChatMessage({ command: '/test' })
await tab.waitForChatFinishesLoading()

await waitForChatItems(3)
const unsupportedLanguageMessage = tab.getChatItems()[3]

assert.deepStrictEqual(unsupportedLanguageMessage.type, 'answer')
assert.deepStrictEqual(
unsupportedLanguageMessage.body,
`<span style="color: #EE9D28;">&#9888;<b>I'm sorry, but /test only supports Python and Java</b><br></span> While ${language.charAt(0).toUpperCase() + language.slice(1)} is not supported, I will generate a suggestion below.`
)
})
})

describe('External file out of project', async () => {
let testFolder: TestFolder
let fileName: string
Expand Down
8 changes: 2 additions & 6 deletions packages/core/src/amazonqTest/chat/controller/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -548,16 +548,12 @@ export class TestController {
*/
if (!['java', 'python'].includes(language) || workspaceFolder === undefined) {
let unsupportedMessage: string
const unsupportedLanguage = language ? language.charAt(0).toUpperCase() + language.slice(1) : ''
if (!workspaceFolder) {
// File is outside of workspace
unsupportedMessage = `<span style="color: #EE9D28;">&#9888;<b>I can't generate tests for ${fileName}</b> because the file is outside of workspace scope.<br></span> I can still provide examples, instructions and code suggestions.`
} else if (unsupportedLanguage) {
unsupportedMessage = `<span style="color: #EE9D28;">&#9888;<b>I'm sorry, but /test only supports Python and Java</b><br></span> While ${unsupportedLanguage} is not supported, I will generate a suggestion below.`
} else {
unsupportedMessage = `<span style="color: #EE9D28;">&#9888;<b>I'm sorry, but /test only supports Python and Java</b><br></span> I will still generate a suggestion below.`
this.messenger.sendMessage(unsupportedMessage, tabID, 'answer')
}
this.messenger.sendMessage(unsupportedMessage, tabID, 'answer')
// Keeping this metric as is. TODO - Change to true once we support through other feature
session.isSupportedLanguage = false
await this.onCodeGeneration(
session,
Expand Down
Loading