From 9e24f295c2197d3f2f3c9e5d8ac41a8ce4e5a91c Mon Sep 17 00:00:00 2001 From: Matthias Rolke Date: Wed, 11 Oct 2023 22:24:18 +0200 Subject: [PATCH] fixup! test: simplify developing E2E tests --- test/browserforce.e2e-spec.ts | 50 ++++++----------------------------- 1 file changed, 8 insertions(+), 42 deletions(-) diff --git a/test/browserforce.e2e-spec.ts b/test/browserforce.e2e-spec.ts index 6264a8e4..b901ca1e 100644 --- a/test/browserforce.e2e-spec.ts +++ b/test/browserforce.e2e-spec.ts @@ -6,11 +6,7 @@ import { Browserforce } from '../src/browserforce'; describe('Browser', function () { describe('login()', () => { it('should successfully login with valid credentials', async () => { - const defaultScratchOrg = await Org.create({}); - const ux = await UX.create(); - const bf = new Browserforce(defaultScratchOrg, ux); - await bf.login(); - await bf.logout(); + // handled by e2e-setup.ts assert.ok(true); }); @@ -27,45 +23,26 @@ describe('Browser', function () { }); describe('getMyDomain()', () => { it('should determine a my domain for a scratch org', async () => { - const defaultScratchOrg = await Org.create({}); - const ux = await UX.create(); - const bf = new Browserforce(defaultScratchOrg, ux); - await bf.login(); - const myDomain = bf.getMyDomain(); + const myDomain = global.bf.getMyDomain(); assert.notDeepStrictEqual(null, myDomain); - await bf.logout(); }); }); describe('getInstanceDomain()', () => { it('should determine an instance domain for a scratch org with my domain', async () => { - const defaultScratchOrg = await Org.create({}); - const ux = await UX.create(); - const bf = new Browserforce(defaultScratchOrg, ux); - await bf.login(); - const instanceDomain = bf.getInstanceDomain(); + const instanceDomain = global.bf.getInstanceDomain(); assert.notDeepStrictEqual(null, instanceDomain); - await bf.logout(); }); }); describe('getLightningUrl()', () => { it('should determine a LEX URL for a scratch org with my domain', async () => { - const defaultScratchOrg = await Org.create({}); - const ux = await UX.create(); - const bf = new Browserforce(defaultScratchOrg, ux); - await bf.login(); - const lexUrl = bf.getLightningUrl(); + const lexUrl = global.bf.getLightningUrl(); assert.notDeepStrictEqual(null, lexUrl); - await bf.logout(); }); }); describe('waitForSelectorInFrameOrPage()', () => { it('should query a selector in LEX and Classic UI', async () => { - const defaultScratchOrg = await Org.create({}); - const ux = await UX.create(); - const bf = new Browserforce(defaultScratchOrg, ux); - await bf.login(); - const page = await bf.openPage('lightning/setup/ExternalStrings/home'); - const frame = await bf.waitForSelectorInFrameOrPage( + const page = await global.bf.openPage('lightning/setup/ExternalStrings/home'); + const frame = await global.bf.waitForSelectorInFrameOrPage( page, 'input[name="edit"]' ); @@ -73,33 +50,22 @@ describe('Browser', function () { page.waitForNavigation(), frame.click('input[name="edit"]') ]); - await bf.logout(); }); }); describe('throwPageErrors()', () => { it('should throw the page error on internal errors', async () => { - const defaultScratchOrg = await Org.create({}); - const ux = await UX.create(); - const bf = new Browserforce(defaultScratchOrg, ux); - await bf.login(); process.env.BROWSERFORCE_RETRY_TIMEOUT_MS = '0'; await assert.rejects(async () => { - await bf.openPage( + await global.bf.openPage( '_ui/common/config/field/StandardFieldAttributes/d?type=Account&id=INVALID_Name' ); }, /Insufficient Privileges/); delete process.env.BROWSERFORCE_RETRY_TIMEOUT_MS; - await bf.logout(); }); it('should not throw any error opening a page', async () => { - const defaultScratchOrg = await Org.create({}); - const ux = await UX.create(); - const bf = new Browserforce(defaultScratchOrg, ux); - await bf.login(); - await bf.openPage( + await global.bf.openPage( '_ui/common/config/field/StandardFieldAttributes/d?type=Account&id=Name' ); - await bf.logout(); }); }); });