Skip to content
This repository was archived by the owner on Jul 2, 2026. It is now read-only.

[W-19111839] refactor: use fs.writeFile() instead of textEditor.setText() to populate file contents - #82

Merged
daphne-sfdc merged 58 commits into
mainfrom
daphne/W-19111839-fs-write-for-e2e-tests
Aug 4, 2025
Merged

[W-19111839] refactor: use fs.writeFile() instead of textEditor.setText() to populate file contents#82
daphne-sfdc merged 58 commits into
mainfrom
daphne/W-19111839-fs-write-for-e2e-tests

Conversation

@daphne-sfdc

Copy link
Copy Markdown
Contributor

This PR updates our E2E tests to enhance reliability by switching from textEditor.setText() and textEditor.setTextAtLine() to fs.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.

daphne-sfdc and others added 30 commits July 24, 2025 11:13
…folder where the Apex class needs to be created
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`,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found this typo - how had this been working before?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@daphne-sfdc daphne-sfdc Jul 31, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@daphne-sfdc
daphne-sfdc marked this pull request as ready for review August 1, 2025 01:52
CristiCanizales
CristiCanizales previously approved these changes Aug 1, 2025

@CristiCanizales CristiCanizales left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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`,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's weird. Good catch!

@daphne-sfdc
daphne-sfdc dismissed CristiCanizales’s stale review August 1, 2025 20:26

Files have changed since the last review.

@CristiCanizales CristiCanizales left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a NIT. Thanks Daphne!

Comment thread src/ui-interaction/textEditorView.ts Outdated
import { getBrowser } from './workbench';
import { retryOperation } from '../retryUtils';
import fs from 'fs';
import * as fs from 'node:fs/promises';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

@daphne-sfdc
daphne-sfdc merged commit 09a545f into main Aug 4, 2025
3 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants