Skip to content

Commit

Permalink
fixup! test: simplify developing E2E tests
Browse files Browse the repository at this point in the history
  • Loading branch information
amtrack committed Oct 11, 2023
1 parent f595555 commit 9e24f29
Showing 1 changed file with 8 additions and 42 deletions.
50 changes: 8 additions & 42 deletions test/browserforce.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand All @@ -27,79 +23,49 @@ 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"]'
);
await Promise.all([
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();
});
});
});

0 comments on commit 9e24f29

Please sign in to comment.