From ee08c8bab4e1678408faef62a0b42f61dad3e0a9 Mon Sep 17 00:00:00 2001 From: Maxime Dufour Date: Wed, 3 Jan 2024 14:22:37 +0000 Subject: [PATCH] Add test to test account details Signed-off-by: Maxime Dufour --- src/cloud/mock/account.ts | 1 - src/ui-test/treeview.ts | 30 +++++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/cloud/mock/account.ts b/src/cloud/mock/account.ts index 8e5b049..da37a98 100644 --- a/src/cloud/mock/account.ts +++ b/src/cloud/mock/account.ts @@ -7,7 +7,6 @@ const account: osc.Account = { export function initMock() { const getAccountMock = ImportMock.mockFunction(osc.AccountApi.prototype, 'readAccounts'); - getAccountMock.onFirstCall().returns(Promise.reject("403")); getAccountMock.returns(Promise.resolve( { accounts: [account], diff --git a/src/ui-test/treeview.ts b/src/ui-test/treeview.ts index 914987a..5140b6e 100644 --- a/src/ui-test/treeview.ts +++ b/src/ui-test/treeview.ts @@ -115,7 +115,7 @@ describe('ActivityBar', () => { expect(action).not.undefined; }); - it.skip('open dialog', async function() { + it.skip('open dialog', async function () { await action.click(); const input = new InputBox(); // Check the title @@ -307,9 +307,33 @@ describe('ActivityBar', () => { expect(await menu.hasItem(expectedCommandName)).equals(true); }); - it('has show Account Info button', async () => { + describe('has show Account Info button', async () => { const expectedCommandName = getButtonTitle("osc.showAccountInfo"); - expect(await menu.hasItem(expectedCommandName)).equals(true); + + after(async () => { + await (new EditorView()).closeAllEditors(); + }); + + it("exists", async () => { + expect(await menu.hasItem(expectedCommandName)).equals(true); + }); + + it("shows resource detail when clicking", async () => { + const action = await menu.getItem(expectedCommandName); + await action?.select(); + + await delay(500); + + // New titles in editor + const editor = new TextEditor(); + expect(await editor.getTitle()).equals("first_profile.json"); + const data = await editor.getText(); + const account = osc.AccountFromJSON(JSON.parse(data)); + expect(account.accountId).equals("accountid"); + + const editorView = new EditorView(); + await editorView.closeEditor("first_profile.json"); + }); }); });