Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Test/e2e] Add a mechanism to stub binaries #3485

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Conversation

arielj
Copy link
Collaborator

@arielj arielj commented Feb 1, 2024

This PR is an initial implementation to be able to stub binaries during e2e tests.

The current e2e/api.spec.ts tests are not really doing an e2e test: those tests are testing that the window.api functions return a version for each binary but are not really testing the boundaries of the app from the user point of view. They are more like an API test.

With this PR we can test navigating Heroic as a user would, going to Settings > Advanced where the versions are displayed, and we can now stub the binaries to test different outcomes. The current tests only stub a single stdout value, but the subbing supports setting a response Promise if we want to do something more complex to mimic a download progress for example?

I also added a few if (process.env.CI === 'e2e') guards in commands that were performing external requests, we shouldn't do that (and eventually we should also add a method to stub those to be able to test different scenarios).


Use the following Checklist if you have changed something on the Backend or Frontend:

  • Tested the feature and it's working on a current and clean install.
  • Tested the main App features and they are still working on a current and clean install. (Login, Install, Play, Uninstall, Move games, etc.)
  • Created / Updated Tests (If necessary)
  • Created / Updated documentation (If necessary)

@arielj arielj added the pr:testing This PR is in testing, don't merge. label Feb 1, 2024
@arielj arielj requested review from a team, flavioislima, CommandMC, Etaash-mathamsetty, Nocccer and imLinguin and removed request for a team February 1, 2024 04:15
@arielj arielj changed the title [Test/e2e] [WIP] Add a mechanism to stub legendary commands [Test/e2e] [WIP] Add a mechanism to stub binaries Feb 1, 2024
@@ -4,14 +4,11 @@ import { electronTest } from './helpers'

declare const window: { api: typeof import('../src/backend/api').default }

electronTest('renders the first page', async (app) => {
const page = await app.firstWindow()
electronTest('renders the first page', async (app, page) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm passing app and page from the helper to avoid calling const page .... for every test.

e2e/helpers.ts Outdated

export async function resetLegendaryCommandStub(app: ElectronApplication) {
await app.evaluate(({ ipcMain }) => {
ipcMain.emit('resetRunLegendaryCommandStub')
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we might want to move all the stub-related functions to another file if it gets too long here

}
}
)
})
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I tried to create a helper method to abstract this evaluate/emit code, but I keep running into this issue Error: electronApplication.evaluate: ReferenceError: .... is not defined because of how the evaluation context changes

I can add more details if needed

@arielj arielj added pr:ready-for-review Feature-complete, ready for the grind! :P and removed pr:testing This PR is in testing, don't merge. labels Feb 2, 2024
@arielj arielj changed the title [Test/e2e] [WIP] Add a mechanism to stub binaries [Test/e2e] Add a mechanism to stub binaries Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:ready-for-review Feature-complete, ready for the grind! :P
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant