-
Notifications
You must be signed in to change notification settings - Fork 245
chore(e2e): test auto-update from COMPASS-8536 #6608
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
Closed
Closed
Changes from 7 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
747d2da
WIP
lerouxb f2dc6cf
test that you can auto-update from the just-packaged version
lerouxb ded47b9
actually auto-update
lerouxb 252707a
typo
lerouxb 7ea61b9
remove console.log
lerouxb d84a6c0
logging, screenshots
lerouxb 083425f
use a log id rather
lerouxb 0f06e74
sanity saving trick
lerouxb 77dc547
Merge branch 'main' into autoupdate-from2
lerouxb 805fcf4
clone compass-mongodb-com and install it
lerouxb 8f0e730
Merge branch 'main' into autoupdate-from2
lerouxb a8b393f
assume compass-mongodb-com is already running
lerouxb 0159641
start compass-mongodb-com as a docker image before we run the smoketests
lerouxb 1f32bcc
update some TODOs
lerouxb eb7ede3
Merge branch 'main' into autoupdate-from2
lerouxb fa27628
put the shell code in a script
lerouxb 9134850
no docker on mac
lerouxb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| import { execute } from '../installers/helpers'; | ||
| import type { Package } from '../installers/types'; | ||
|
|
||
| // TODO: move this since we'll use the same for testing TO | ||
| function testInstalledApp( | ||
| pkg: Package, | ||
| appPath: string, | ||
| env: Record<string, string> | ||
| ): Promise<void> { | ||
| return execute( | ||
| 'npm', | ||
| [ | ||
| 'run', | ||
| '--unsafe-perm', | ||
| 'test-packaged', | ||
| '--workspace', | ||
| 'compass-e2e-tests', | ||
| '--', | ||
| '--test-filter=auto-update', | ||
| ], | ||
| { | ||
| env: { | ||
| ...process.env, | ||
| HADRON_AUTO_UPDATE_ENDPOINT_OVERRIDE: 'http://localhost:8080', | ||
| AUTO_UPDATE_UPDATABLE: pkg.updatable.toString(), | ||
| COMPASS_APP_NAME: pkg.appName, | ||
| COMPASS_APP_PATH: appPath, | ||
| ...env, | ||
| }, | ||
| } | ||
| ); | ||
| } | ||
|
|
||
| export async function testAutoUpdateFrom(pkg: Package) { | ||
| // install the app | ||
| console.log(`installing ${pkg.packageFilepath}`); | ||
| const { appPath, uninstall } = await pkg.installer({ | ||
| appName: pkg.appName, | ||
| filepath: pkg.packageFilepath, | ||
| }); | ||
|
|
||
| console.log(appPath); | ||
|
|
||
| try { | ||
| // TODO: start the autoupdate server | ||
|
||
| try { | ||
| await testInstalledApp(pkg, appPath, { | ||
| AUTO_UPDATE_FROM: 'true', | ||
| }); | ||
| } finally { | ||
| // TODO: stop the autoupdate server | ||
| } | ||
| } finally { | ||
| // remove the app | ||
| await uninstall(); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| import { expect } from 'chai'; | ||
| import { | ||
| init, | ||
| cleanup, | ||
| Selectors, | ||
| screenshotPathName, | ||
| } from '../helpers/compass'; | ||
|
|
||
| describe('Auto-update', function () { | ||
| it('auto-update from', async function () { | ||
| if (!process.env.AUTO_UPDATE_FROM) { | ||
| // we don't want this test to execute along with all the others under | ||
| // normal circumstances because it is destructive - it overwrites Compass | ||
| // itself | ||
| this.skip(); | ||
| } | ||
|
|
||
| // run the app and wait for it to auto-update | ||
| const compass = await init('auto-update from', { firstRun: true }); | ||
| const { browser } = compass; | ||
| try { | ||
| await browser.$(Selectors.AutoUpdateToast).waitForDisplayed(); | ||
|
|
||
| if (process.env.AUTO_UPDATE_UPDATABLE === 'true') { | ||
| const restartButton = browser.$(Selectors.AutoUpdateRestartButton); | ||
| await restartButton.waitForDisplayed(); | ||
|
|
||
| // We could click the restart button to apply the update and restart the | ||
| // app, but restarting the app confuses webdriverio or at least our test | ||
| // helpers. So we're going to just restart the app manually. | ||
| } else { | ||
| // When auto-update is not supported the toast contains a link to | ||
| // download | ||
| const linkElement = browser.$(Selectors.AutoUpdateDownloadLink); | ||
| await linkElement.waitForDisplayed(); | ||
| expect(await linkElement.getAttribute('href')).to.equal( | ||
| 'https://www.mongodb.com/try/download/compass' | ||
| ); | ||
| } | ||
| } finally { | ||
| await browser.screenshot(screenshotPathName('auto-update-from')); | ||
| await cleanup(compass); | ||
| } | ||
|
|
||
| if (process.env.AUTO_UPDATE_UPDATABLE === 'true') { | ||
| // run the app again and check that the version changed | ||
| const compass = await init('auto-update from restart', { | ||
| firstRun: false, | ||
| }); | ||
| const { browser } = compass; | ||
| try { | ||
| await browser.$(Selectors.AutoUpdateToast).waitForDisplayed(); | ||
| await browser | ||
| .$(Selectors.AutoUpdateReleaseNotesLink) | ||
| .waitForDisplayed(); | ||
| } finally { | ||
| await browser.screenshot( | ||
| screenshotPathName('auto-update-from-restart') | ||
| ); | ||
| await cleanup(compass); | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| it('auto-update to', function () { | ||
| if (!process.env.AUTO_UPDATE_TO) { | ||
| // we don't want this test to execute along with all the others under | ||
| // normal circumstances because it is destructive - it overwrites Compass | ||
| // itself | ||
| this.skip(); | ||
| } | ||
|
|
||
| // TODO | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Copied from https://github.com/kraenhansen/bufout which we should probably just use.