[W-19111839] refactor: use fs.writeFile() instead of textEditor.setText() to populate file contents - #82
Conversation
…th no custom text
…folder where the Apex class needs to be created
…4)' warning in extensionUtils.ts
…visualforceUtils.ts and apexUtils.ts
…ndValidateCommand()
…in overrideTextInFile()
…se it is no longer needed
| const metadataPaths: Record<string, string> = { | ||
| ApexClass: `force-app${pathSeparator}main${pathSeparator}default${pathSeparator}classes`, | ||
| ExternalServiceRsegistration: `force-app${pathSeparator}main${pathSeparator}default${pathSeparator}externalServiceRegistrations`, | ||
| ExternalServiceRegistration: `force-app${pathSeparator}main${pathSeparator}default${pathSeparator}externalServiceRegistrations`, |
There was a problem hiding this comment.
Found this typo - how had this been working before?
There was a problem hiding this comment.
That's weird. Good catch!
| /** | ||
| * Shows the list of running extensions in VS Code | ||
| * @returns {Promise<Editor | undefined>} The editor showing running extensions, or undefined if not found | ||
| * @returns The editor showing running extensions, or undefined if not found |
There was a problem hiding this comment.
I was getting a JSDoc types may be moved to TypeScript types. ts(80004) warning on this file, and this was the suggested solution. I did notice that all new JSDocs were created without any types listed.
CristiCanizales
left a comment
There was a problem hiding this comment.
Thank you for working on this Daphne! 🥳
🚢
| const metadataPaths: Record<string, string> = { | ||
| ApexClass: `force-app${pathSeparator}main${pathSeparator}default${pathSeparator}classes`, | ||
| ExternalServiceRsegistration: `force-app${pathSeparator}main${pathSeparator}default${pathSeparator}externalServiceRegistrations`, | ||
| ExternalServiceRegistration: `force-app${pathSeparator}main${pathSeparator}default${pathSeparator}externalServiceRegistrations`, |
There was a problem hiding this comment.
That's weird. Good catch!
Files have changed since the last review.
CristiCanizales
left a comment
There was a problem hiding this comment.
Just a NIT. Thanks Daphne!
| import { getBrowser } from './workbench'; | ||
| import { retryOperation } from '../retryUtils'; | ||
| import fs from 'fs'; | ||
| import * as fs from 'node:fs/promises'; |
There was a problem hiding this comment.
I see in visualforceUtils.ts we're importing just 'fs/promises', I know it's the same but let's just use the same style for consistency!
This PR updates our E2E tests to enhance reliability by switching from
textEditor.setText()andtextEditor.setTextAtLine()tofs.writeFile()for populating file contents.Previously, our E2E tests would open files in an Editor View and use UI-based methods to replace their contents. This approach proved unreliable and led to flappers. These failures were due to the inherent instability of UI-driven file manipulation within the testing environment.
By adopting
fs.writeFile(), we now directly interact with the filesystem to create or overwrite file contents. This change significantly improves the stability of our E2E tests, as it bypasses the less predictable UI operations. Our primary goal for these E2E tests is not to test file creation – that's already covered in our templates.e2e.ts – but rather to validate broader system functionality.This refactor ensures our E2E tests are more robust and less prone to environmental inconsistencies, allowing us to focus on testing the core features they were designed for.