Skip to content

Commit

Permalink
fix: not show the changelog prompt on a fresh install
Browse files Browse the repository at this point in the history
  • Loading branch information
tecton committed Jul 3, 2024
1 parent b164389 commit e83d1e2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
11 changes: 4 additions & 7 deletions packages/vscode-extension/src/utils/releaseNote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,14 @@ export class ReleaseNote {
}
} else {
const currentStableVersion = this.context.globalState.get<string>(SyncedState.Version);
await this.context.globalState.update(SyncedState.Version, teamsToolkitVersion);
if (
currentStableVersion === undefined ||
currentStableVersion !== undefined &&
versionUtil.compare(teamsToolkitVersion, currentStableVersion) === 1
) {
// if syncedVersion is undefined, then it is not existinig user
await this.context.globalState.update(
UserState.IsExisting,
currentStableVersion === undefined ? "no" : "yes"
);
// it is existinig user
await this.context.globalState.update(UserState.IsExisting, "yes");
ExtTelemetry.sendTelemetryEvent(TelemetryEvent.ShowWhatIsNewNotification);
await this.context.globalState.update(SyncedState.Version, teamsToolkitVersion);

const changelog = {
title: localize("teamstoolkit.upgrade.changelog"),
Expand Down
11 changes: 10 additions & 1 deletion packages/vscode-extension/test/utils/releaseNote.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,16 @@ describe("Release Note", () => {
sandbox.stub(vscode.window, "showInformationMessage").resolves();
const instance = new ReleaseNote(context);
await instance.show();
sinon.assert.notCalled(contextSpy);
sinon.assert.calledOnce(contextSpy);
chai.assert(telemetryStub.notCalled);
});
it("should not show changelog when it's a fresh install", async () => {
const contextSpy = sandbox.spy(context.globalState, "update");
sandbox.stub(context.globalState, "get").returns(undefined);
sandbox.stub(vscode.window, "showInformationMessage").resolves();
const instance = new ReleaseNote(context);
await instance.show();
sinon.assert.calledOnce(contextSpy);
chai.assert(telemetryStub.notCalled);
});
});
Expand Down

0 comments on commit e83d1e2

Please sign in to comment.