-
-
Notifications
You must be signed in to change notification settings - Fork 445
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
Conversation
@@ -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) => { |
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
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
} | ||
} | ||
) | ||
}) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good stuff
2cf0874
to
0fcf766
Compare
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 thewindow.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: