Skip to content

Commit b32c4bc

Browse files
authored
fix: failing test "publishDocument .. createDocument" #4014
Problem: "publishDocument .. createDocument" tests fail on "Insiders" CI job. #4013 Solution: - Adjust the tests to show what was passed. - Create the `TextDocument` in `beforeEach` instead of `before()`. Don't bother to "show" it. Before: 1) publishDocument createDocument createDocument API returns successfully: AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value: (0, assert_1.default)(client.createDocument.calledWith(fakeCreateRequest)) + expected - actual -false +true at Context.<anonymous> (src/test/ssmDocument/commands/publishDocument.test.ts:84:19) After: + actual - expected ... Lines skipped [ [ { + Content: '', - Content: 'foo', DocumentFormat: 'JSON', ... } ] ]
1 parent 6057ef4 commit b32c4bc

File tree

3 files changed

+7
-16
lines changed

3 files changed

+7
-16
lines changed

src/ssmDocument/activation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ async function registerSsmDocumentCommands(
5151
await openDocumentItemYaml(node, awsContext)
5252
}),
5353
Commands.register('aws.ssmDocument.publishDocument', async () => {
54-
await publishSSMDocument(awsContext, regionProvider)
54+
await publishSSMDocument()
5555
}),
5656
Commands.register('aws.ssmDocument.updateDocumentVersion', async (node: DocumentItemNodeWriteable) => {
5757
await updateDocumentVersion(node, awsContext)

src/ssmDocument/commands/publishDocument.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,17 @@ import { SSM } from 'aws-sdk'
77
import * as vscode from 'vscode'
88
import * as nls from 'vscode-nls'
99
const localize = nls.loadMessageBundle()
10-
import { AwsContext } from '../../shared/awsContext'
1110
import { DefaultSsmDocumentClient, SsmDocumentClient } from '../../shared/clients/ssmDocumentClient'
1211
import { ssmJson, ssmYaml } from '../../shared/constants'
1312

1413
import * as localizedText from '../../shared/localizedText'
1514
import { getLogger, Logger } from '../../shared/logger'
16-
import { RegionProvider } from '../../shared/regions/regionProvider'
1715
import { PublishSSMDocumentWizard, PublishSSMDocumentWizardResponse } from '../wizards/publishDocumentWizard'
1816
import { showConfirmationMessage } from '../util/util'
1917
import { telemetry } from '../../shared/telemetry/telemetry'
2018
import { Result, SsmOperation } from '../../shared/telemetry/telemetry'
2119

22-
export async function publishSSMDocument(awsContext: AwsContext, regionProvider: RegionProvider): Promise<void> {
20+
export async function publishSSMDocument(): Promise<void> {
2321
const logger: Logger = getLogger()
2422

2523
const textDocument = vscode.window.activeTextEditor?.document

src/test/ssmDocument/commands/publishDocument.test.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,6 @@ describe('publishDocument', async function () {
3939
Name: 'test',
4040
}
4141

42-
before(async function () {
43-
textDocument = await vscode.workspace.openTextDocument({ content: 'foo', language: 'ssm-json' })
44-
await vscode.window.showTextDocument(textDocument)
45-
})
46-
47-
after(async function () {
48-
await closeAllEditors()
49-
})
50-
5142
beforeEach(async function () {
5243
wizardResponse = {
5344
action: PublishSSMDocumentAction.QuickUpdate,
@@ -60,10 +51,12 @@ describe('publishDocument', async function () {
6051
Name: 'testName',
6152
},
6253
}
54+
textDocument = await vscode.workspace.openTextDocument({ content: 'foo', language: 'ssm-json' })
6355
})
6456

65-
afterEach(function () {
57+
afterEach(async function () {
6658
sinon.restore()
59+
await closeAllEditors()
6760
})
6861

6962
describe('createDocument', async function () {
@@ -81,7 +74,7 @@ describe('publishDocument', async function () {
8174
await publish.createDocument(wizardResponse, textDocument, client)
8275

8376
assert(client.createDocument.calledOnce)
84-
assert(client.createDocument.calledWith(fakeCreateRequest))
77+
assert.deepStrictEqual(client.createDocument.args, [[fakeCreateRequest]])
8578
})
8679

8780
it('createDocument API failed', async function () {
@@ -104,7 +97,7 @@ describe('publishDocument', async function () {
10497
await publish.updateDocument(wizardResponse, textDocument, client)
10598

10699
assert(client.updateDocument.calledOnce)
107-
assert(client.updateDocument.calledWith(fakeUpdateRequest))
100+
assert.deepStrictEqual(client.updateDocument.args, [[fakeUpdateRequest]])
108101
})
109102

110103
it('updateDocument API failed', async function () {

0 commit comments

Comments
 (0)