Skip to content
Merged
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
42 changes: 14 additions & 28 deletions packages/core/src/test/awsService/appBuilder/walkthrough.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,32 +155,32 @@ describe('AppBuilder Walkthrough', function () {
})

describe('Create project', function () {
let sandbox: sinon.SinonSandbox
const workspaceUri = vscode.workspace.workspaceFolders?.[0]?.uri
const prevInfo = 'random text'
assert.ok(workspaceUri)

beforeEach(function () {
sandbox = sinon.createSandbox()
before(async function () {
await fs.delete(vscode.Uri.joinPath(workspaceUri, 'template.yaml'), { force: true })
})

afterEach(function () {
sandbox.restore()
beforeEach(async function () {
await fs.writeFile(vscode.Uri.joinPath(workspaceUri, 'template.yaml'), prevInfo)
})

afterEach(async function () {
await fs.delete(vscode.Uri.joinPath(workspaceUri, 'template.yaml'), { force: true })
})

it('open existing template', async function () {
// Given
const workspaceUri = vscode.workspace.workspaceFolders?.[0]?.uri
assert.ok(workspaceUri)
// Given no template exist
await fs.delete(vscode.Uri.joinPath(workspaceUri, 'template.yaml'), { force: true })
// When
await genWalkthroughProject('CustomTemplate', workspaceUri, undefined)
// Then
// Then nothing should be created
assert.equal(await fs.exists(vscode.Uri.joinPath(workspaceUri, 'template.yaml')), false)
})

it('build an app with appcomposer overwrite', async function () {
// Given
const workspaceUri = vscode.workspace.workspaceFolders?.[0]?.uri
assert.ok(workspaceUri)
await fs.writeFile(vscode.Uri.joinPath(workspaceUri, 'template.yaml'), 'random text')
const prevInfo = await fs.readFileText(vscode.Uri.joinPath(workspaceUri, 'template.yaml'))
getTestWindow().onDidShowMessage((message) => {
message.selectItem('Yes')
})
Expand All @@ -192,10 +192,6 @@ describe('AppBuilder Walkthrough', function () {

it('build an app with appcomposer no overwrite', async function () {
// Given
const workspaceUri = vscode.workspace.workspaceFolders?.[0]?.uri
assert.ok(workspaceUri)
await fs.writeFile(vscode.Uri.joinPath(workspaceUri, 'template.yaml'), 'random text')
const prevInfo = await fs.readFileText(vscode.Uri.joinPath(workspaceUri, 'template.yaml'))
Copy link
Contributor

Choose a reason for hiding this comment

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

Just for future reference: can also use waitUntil to retry.

getTestWindow().onDidShowMessage((message) => {
message.selectItem('No')
})
Expand All @@ -213,11 +209,6 @@ describe('AppBuilder Walkthrough', function () {

it('download serverlessland proj', async function () {
// Given
const workspaceUri = vscode.workspace.workspaceFolders?.[0]?.uri
assert.ok(workspaceUri)
// makesure template exist
await fs.writeFile(vscode.Uri.joinPath(workspaceUri, 'template.yaml'), '')
const prevInfo = await fs.readFileText(vscode.Uri.joinPath(workspaceUri, 'template.yaml'))
// select overwrite
getTestWindow().onDidShowMessage((message) => {
message.selectItem('Yes')
Expand All @@ -231,11 +222,6 @@ describe('AppBuilder Walkthrough', function () {

it('download serverlessland proj no overwrite', async function () {
// Given existing template.yaml
const workspaceUri = vscode.workspace.workspaceFolders?.[0]?.uri
assert.ok(workspaceUri)
// makesure template exist
await fs.writeFile(vscode.Uri.joinPath(workspaceUri, 'template.yaml'), '')
const prevInfo = await fs.readFileText(vscode.Uri.joinPath(workspaceUri, 'template.yaml'))
// select do not overwrite
getTestWindow().onDidShowMessage((message) => {
message.selectItem('No')
Expand Down
Loading