Skip to content

Commit

Permalink
Merge pull request #580 from amtrack/test/more-refactoring
Browse files Browse the repository at this point in the history
fixup! test: simplify developing E2E tests
  • Loading branch information
amtrack authored Oct 11, 2023
2 parents f595555 + 9e24f29 commit cf3b686
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 cf3b686

Please sign in to comment.