Skip to content

Commit 7702ff3

Browse files
committed
test(e2e): more command visibility (initial-suite-like)
1 parent 7204170 commit 7702ff3

8 files changed

Lines changed: 232 additions & 2 deletions

File tree

packages/salesforcedx-vscode-apex-log/test/playwright/fixtures/desktopFixtures.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,15 @@ export const desktopTest = createDesktopTest({
1818
'git.autofetch': false
1919
}
2020
});
21+
22+
export const emptyWorkspaceDesktopTest = createDesktopTest({
23+
fixturesDir: __dirname,
24+
emptyWorkspace: true,
25+
additionalExtensionDirs: ['salesforcedx-vscode-metadata'],
26+
disableOtherExtensions: false,
27+
userSettings: {
28+
'github.gitAuthentication': false,
29+
'git.terminalAuthentication': false,
30+
'git.autofetch': false
31+
}
32+
});

packages/salesforcedx-vscode-apex-log/test/playwright/fixtures/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import { test as webTest } from '@playwright/test';
99

10-
import { desktopTest } from './desktopFixtures';
10+
import { desktopTest, emptyWorkspaceDesktopTest } from './desktopFixtures';
1111

1212
const isDesktop = process.env.VSCODE_DESKTOP === '1';
1313

@@ -21,3 +21,4 @@ webTest.afterEach(async ({ page }, testInfo) => {
2121
});
2222

2323
export const test = isDesktop ? desktopTest : webTest;
24+
export const emptyWorkspaceTest = isDesktop ? emptyWorkspaceDesktopTest : webTest;
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright (c) 2026, salesforce.com, inc.
3+
* All rights reserved.
4+
* Licensed under the BSD 3-Clause license.
5+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6+
*/
7+
8+
import {
9+
setupConsoleMonitoring,
10+
setupNetworkMonitoring,
11+
validateNoCriticalErrors,
12+
verifyCommandDoesNotExist,
13+
verifyCommandExists,
14+
isDesktop
15+
} from '@salesforce/playwright-vscode-ext';
16+
import packageNls from '../../../package.nls.json';
17+
import { test } from '../fixtures';
18+
19+
(isDesktop() ? test : test.skip.bind(test))(
20+
'Apex Log commands visibility when project is open but no org is connected',
21+
async ({ page }) => {
22+
const consoleErrors = setupConsoleMonitoring(page);
23+
const networkErrors = setupNetworkMonitoring(page);
24+
25+
await test.step('verify project-only commands are visible', async () => {
26+
// Create Anonymous Apex Script should be visible with just a project
27+
await verifyCommandExists(page, packageNls['apexLog.command.createAnonymousApexScript'], 30_000);
28+
});
29+
30+
await test.step('verify org-dependent commands are hidden', async () => {
31+
// Get Apex Debug Logs requires an org
32+
await verifyCommandDoesNotExist(page, packageNls['apexLog.command.logGet']);
33+
34+
// Open Trace Flags requires an org
35+
await verifyCommandDoesNotExist(page, packageNls['apexLog.command.traceFlagsOpen']);
36+
37+
// Execute Anonymous Apex (Document) requires an org
38+
await verifyCommandDoesNotExist(page, packageNls['apexLog.command.executeDocument']);
39+
40+
// Execute Anonymous Apex (Selection) requires an org
41+
await verifyCommandDoesNotExist(page, packageNls['apexLog.command.executeSelection']);
42+
43+
// Trace Flag commands require an org
44+
await verifyCommandDoesNotExist(page, packageNls['apexLog.command.traceFlagsCreateForCurrentUser']);
45+
await verifyCommandDoesNotExist(page, packageNls['apexLog.command.traceFlagsDeleteForCurrentUser']);
46+
});
47+
48+
await validateNoCriticalErrors(test, consoleErrors, networkErrors);
49+
}
50+
);
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright (c) 2026, salesforce.com, inc.
3+
* All rights reserved.
4+
* Licensed under the BSD 3-Clause license.
5+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6+
*/
7+
8+
import {
9+
setupConsoleMonitoring,
10+
setupNetworkMonitoring,
11+
validateNoCriticalErrors,
12+
verifyCommandDoesNotExist,
13+
isDesktop
14+
} from '@salesforce/playwright-vscode-ext';
15+
import packageNls from '../../../package.nls.json';
16+
import { emptyWorkspaceTest as test } from '../fixtures';
17+
18+
(isDesktop() ? test : test.skip.bind(test))(
19+
'Apex Log commands are hidden when no project is open',
20+
async ({ page }) => {
21+
const consoleErrors = setupConsoleMonitoring(page);
22+
const networkErrors = setupNetworkMonitoring(page);
23+
24+
await test.step('verify all apex log commands are hidden', async () => {
25+
// Create Anonymous Apex Script
26+
await verifyCommandDoesNotExist(page, packageNls['apexLog.command.createAnonymousApexScript']);
27+
28+
// Get Apex Debug Logs
29+
await verifyCommandDoesNotExist(page, packageNls['apexLog.command.logGet']);
30+
31+
// Open Trace Flags
32+
await verifyCommandDoesNotExist(page, packageNls['apexLog.command.traceFlagsOpen']);
33+
34+
// Execute Anonymous Apex (Document)
35+
await verifyCommandDoesNotExist(page, packageNls['apexLog.command.executeDocument']);
36+
37+
// Execute Anonymous Apex (Selection)
38+
await verifyCommandDoesNotExist(page, packageNls['apexLog.command.executeSelection']);
39+
40+
// Trace Flag commands
41+
await verifyCommandDoesNotExist(page, packageNls['apexLog.command.traceFlagsCreateForCurrentUser']);
42+
await verifyCommandDoesNotExist(page, packageNls['apexLog.command.traceFlagsDeleteForCurrentUser']);
43+
});
44+
45+
await validateNoCriticalErrors(test, consoleErrors, networkErrors);
46+
}
47+
);

packages/salesforcedx-vscode-apex-testing/test/playwright/fixtures/desktopFixtures.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,15 @@ export const desktopTest = createDesktopTest({
1818
'git.autofetch': false
1919
}
2020
});
21+
22+
export const emptyWorkspaceDesktopTest = createDesktopTest({
23+
fixturesDir: __dirname,
24+
emptyWorkspace: true,
25+
additionalExtensionDirs: ['salesforcedx-vscode-metadata'],
26+
disableOtherExtensions: false,
27+
userSettings: {
28+
'github.gitAuthentication': false,
29+
'git.terminalAuthentication': false,
30+
'git.autofetch': false
31+
}
32+
});

packages/salesforcedx-vscode-apex-testing/test/playwright/fixtures/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import { test as webTest } from '@playwright/test';
99

10-
import { desktopTest } from './desktopFixtures';
10+
import { desktopTest, emptyWorkspaceDesktopTest } from './desktopFixtures';
1111

1212
const isDesktop = process.env.VSCODE_DESKTOP === '1';
1313

@@ -23,3 +23,4 @@ webTest.afterEach(async ({ page }, testInfo) => {
2323
// Export the appropriate test based on environment (fixtures differ)
2424
// expect is the same for both, so just re-export it directly
2525
export const test = isDesktop ? desktopTest : webTest;
26+
export const emptyWorkspaceTest = isDesktop ? emptyWorkspaceDesktopTest : webTest;
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright (c) 2026, salesforce.com, inc.
3+
* All rights reserved.
4+
* Licensed under the BSD 3-Clause license.
5+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6+
*/
7+
8+
import {
9+
setupConsoleMonitoring,
10+
setupNetworkMonitoring,
11+
validateNoCriticalErrors,
12+
verifyCommandDoesNotExist,
13+
verifyCommandExists,
14+
isDesktop
15+
} from '@salesforce/playwright-vscode-ext';
16+
import packageNls from '../../../package.nls.json';
17+
import { test } from '../fixtures';
18+
19+
(isDesktop() ? test : test.skip.bind(test))(
20+
'Apex Testing commands visibility when project is open but no org is connected',
21+
async ({ page }) => {
22+
const consoleErrors = setupConsoleMonitoring(page);
23+
const networkErrors = setupNetworkMonitoring(page);
24+
25+
await test.step('verify project-only commands are visible', async () => {
26+
// Create Apex Unit Test Class should be visible with just a project
27+
await verifyCommandExists(page, packageNls.apex_generate_unit_test_class_text, 30_000);
28+
29+
// Open Apex Test Explorer Walkthrough should be visible with just a project
30+
await verifyCommandExists(page, packageNls.apex_testing_walkthrough_open_command, 5000);
31+
});
32+
33+
await test.step('verify org-dependent commands are hidden', async () => {
34+
// Run Apex Tests requires an org
35+
await verifyCommandDoesNotExist(page, packageNls.apex_test_run_text);
36+
37+
// Run Apex Test Suite requires an org
38+
await verifyCommandDoesNotExist(page, packageNls.apex_test_suite_run_text);
39+
40+
// Create Apex Test Suite requires an org
41+
await verifyCommandDoesNotExist(page, packageNls.apex_test_suite_create_text);
42+
43+
// Add Tests to Apex Test Suite requires an org
44+
await verifyCommandDoesNotExist(page, packageNls.apex_test_suite_add_text);
45+
46+
// Re-Run Last Run Apex Test Class requires an org
47+
await verifyCommandDoesNotExist(page, packageNls.apex_test_last_class_run_text);
48+
49+
// Re-Run Last Run Apex Test Method requires an org
50+
await verifyCommandDoesNotExist(page, packageNls.apex_test_last_method_run_text);
51+
});
52+
53+
await validateNoCriticalErrors(test, consoleErrors, networkErrors);
54+
}
55+
);
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright (c) 2026, salesforce.com, inc.
3+
* All rights reserved.
4+
* Licensed under the BSD 3-Clause license.
5+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6+
*/
7+
8+
import {
9+
setupConsoleMonitoring,
10+
setupNetworkMonitoring,
11+
validateNoCriticalErrors,
12+
verifyCommandDoesNotExist,
13+
isDesktop
14+
} from '@salesforce/playwright-vscode-ext';
15+
import packageNls from '../../../package.nls.json';
16+
import { emptyWorkspaceTest as test } from '../fixtures';
17+
18+
(isDesktop() ? test : test.skip.bind(test))(
19+
'Apex Testing commands are hidden when no project is open',
20+
async ({ page }) => {
21+
const consoleErrors = setupConsoleMonitoring(page);
22+
const networkErrors = setupNetworkMonitoring(page);
23+
24+
await test.step('verify all apex testing commands are hidden', async () => {
25+
// Create Apex Unit Test Class
26+
await verifyCommandDoesNotExist(page, packageNls.apex_generate_unit_test_class_text);
27+
28+
// Open Apex Test Explorer Walkthrough
29+
await verifyCommandDoesNotExist(page, packageNls.apex_testing_walkthrough_open_command);
30+
31+
// Run Apex Tests
32+
await verifyCommandDoesNotExist(page, packageNls.apex_test_run_text);
33+
34+
// Run Apex Test Suite
35+
await verifyCommandDoesNotExist(page, packageNls.apex_test_suite_run_text);
36+
37+
// Create Apex Test Suite
38+
await verifyCommandDoesNotExist(page, packageNls.apex_test_suite_create_text);
39+
40+
// Add Tests to Apex Test Suite
41+
await verifyCommandDoesNotExist(page, packageNls.apex_test_suite_add_text);
42+
43+
// Re-Run Last Run Apex Test Class
44+
await verifyCommandDoesNotExist(page, packageNls.apex_test_last_class_run_text);
45+
46+
// Re-Run Last Run Apex Test Method
47+
await verifyCommandDoesNotExist(page, packageNls.apex_test_last_method_run_text);
48+
});
49+
50+
await validateNoCriticalErrors(test, consoleErrors, networkErrors);
51+
}
52+
);

0 commit comments

Comments
 (0)