diff --git a/test/specs/manifestBuilder.e2e.ts b/test/specs/manifestBuilder.e2e.ts index e578ae01..c9d991dc 100644 --- a/test/specs/manifestBuilder.e2e.ts +++ b/test/specs/manifestBuilder.e2e.ts @@ -30,19 +30,8 @@ describe('Manifest Builder', async () => { const workbench = await browser.getWorkbench(); // Using the Command palette, run File: New File... - const inputBox = await utilities.executeQuickPick( - 'Create: New File...', - utilities.Duration.seconds(1) - ); - - // Set the name of the new manifest file - const filePath = path.join('manifest', 'manifest.xml'); - await inputBox.setText(filePath); - - // The following 3 confirms are just confirming the file creation and the folder it will belong to - await inputBox.confirm(); - await inputBox.confirm(); - await inputBox.confirm(); + await utilities.createFile(path.join('manifest', 'manifest.xml')); + await browser.keys(['Enter']); // This extra step is necessary, otherwise the process to create file here doesn't finish. const textEditor = await utilities.getTextEditor(workbench, 'manifest.xml'); const content = [ diff --git a/test/specs/miscellaneous.e2e.ts b/test/specs/miscellaneous.e2e.ts index a9b7eb3c..3ae01b32 100644 --- a/test/specs/miscellaneous.e2e.ts +++ b/test/specs/miscellaneous.e2e.ts @@ -44,7 +44,7 @@ describe('Miscellaneous', async () => { const workbench = await utilities.getWorkbench(); const commandName = EnvironmentSettings.getInstance().vscodeVersion === 'stable' || - semver.gte(EnvironmentSettings.getInstance().vscodeVersion, '1.92.0') + semver.gte(EnvironmentSettings.getInstance().vscodeVersion, '1.92.0') ? 'Snippets: Configure Snippets' : 'Snippets: Configure User Snippets'; @@ -96,13 +96,7 @@ describe('Miscellaneous', async () => { ].join('\n'); // Create simple lwc.html file - const inputBox = await utilities.executeQuickPick( - 'Create: New File...', - utilities.Duration.seconds(1) - ); - await inputBox.setText('lwc.html'); - await browser.keys(['Enter']); - await browser.keys(['Enter']); + await utilities.createFile('lwc.html'); // Type snippet "lwc-button" and check it inserted the right lwc const textEditor = await utilities.getTextEditor(workbench, 'lwc.html'); @@ -130,13 +124,7 @@ describe('Miscellaneous', async () => { const lwcSnippet = 'this.dispatchEvent(new CustomEvent("event-name"));'; // Create simple lwc.js file - const inputBox = await utilities.executeQuickPick( - 'Create: New File...', - utilities.Duration.seconds(1) - ); - await inputBox.setText('lwc.js'); - await browser.keys(['Enter']); - await browser.keys(['Enter']); + await utilities.createFile('lwc.js'); // Type snippet "lwc", select "lwc-event" and check it inserted the right thing const textEditor = await utilities.getTextEditor(workbench, 'lwc.js'); diff --git a/test/utilities/apexUtils.ts b/test/utilities/apexUtils.ts index bfc171c3..d0e04863 100644 --- a/test/utilities/apexUtils.ts +++ b/test/utilities/apexUtils.ts @@ -7,7 +7,7 @@ import { TextEditor } from 'wdio-vscode-service'; import { executeQuickPick } from './commandPrompt.ts'; -import { Duration, getTextEditor, pause } from './miscellaneous.ts'; +import { Duration, getTextEditor, pause, createFile } from './miscellaneous.ts'; import { getWorkbench } from './workbench.ts'; export async function createApexClass( @@ -107,16 +107,11 @@ export async function createApexClassWithBugs(): Promise { export async function createAnonymousApexFile(): Promise { const workbench = await getWorkbench(); const editorView = workbench.getEditorView(); + const anonymousApexFileName = 'Anonymous.apex'; - // Using the Command palette, run File: New File... - const inputBox = await executeQuickPick('Create: New File...', Duration.seconds(1)); + await createFile(anonymousApexFileName); - // Set the name of the new Anonymous Apex file - await inputBox.setText('Anonymous.apex'); - await browser.keys(['Enter']); - await browser.keys(['Enter']); - - const textEditor = (await editorView.openEditor('Anonymous.apex')) as TextEditor; + const textEditor = (await editorView.openEditor(anonymousApexFileName)) as TextEditor; await textEditor.setText("System.debug('¡Hola mundo!');"); await textEditor.save(); await pause(Duration.seconds(1)); diff --git a/test/utilities/miscellaneous.ts b/test/utilities/miscellaneous.ts index 4715d77c..6d234b1c 100644 --- a/test/utilities/miscellaneous.ts +++ b/test/utilities/miscellaneous.ts @@ -238,3 +238,19 @@ export class Duration extends DurationKit.Duration { return new Duration(quantity, Unit.WEEKS); } } + + +/** + * The function is not the best practice. + * We have observed that after installing the extension, the first time you specify the path with the command works, + * But it does not work for following file creation, it will ignore the path you specify but always follow the path from the first time + */ +export async function createFile(path: string): Promise { + // Using the Command palette, run File: New File... + const inputBox = await executeQuickPick('Create: New File...', Duration.seconds(1)); + + // Set the filepath + await inputBox.setText(path); + await browser.keys(['Enter']); + await browser.keys(['Enter']); +} \ No newline at end of file