-
Notifications
You must be signed in to change notification settings - Fork 245
feat(smoke-tests): test auto-updating from the version of Compass that was just packaged COMPASS-8536 #6629
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
Changes from 1 commit
6b2148a
3dc10f5
6eaf996
0510a72
eec627b
57f87f0
86eca0d
1bb6e82
2d769aa
4c49473
8f0be55
c95a39c
d822498
d4b2995
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| import fs from 'fs'; | ||
| import path from 'path'; | ||
| import { expect } from 'chai'; | ||
| import { | ||
| init, | ||
| cleanup, | ||
| Selectors, | ||
| screenshotPathName, | ||
| } from '../helpers/compass'; | ||
| import { LOG_PATH } from '../helpers/test-runner-paths'; | ||
|
|
||
| function wait(ms: number) { | ||
| return new Promise((resolve) => { | ||
| setTimeout(resolve, ms); | ||
| }); | ||
| } | ||
|
|
||
| describe('Auto-update', function () { | ||
| it('auto-update from', async function () { | ||
| if (process.env.TEST_NAME !== 'AUTO_UPDATE_FROM') { | ||
lerouxb marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // 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 | ||
| console.log('starting compass the first time'); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have another branch open where I'm switching from console.log to debug. I don't want to conflict with that now, so will fix all these together in a future PR. |
||
| 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. | ||
| await browser.pause(1000); | ||
| } 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?utm_source=compass&utm_medium=product' | ||
| ); | ||
| } | ||
| } finally { | ||
| await browser.screenshot(screenshotPathName('auto-update-from')); | ||
| await cleanup(compass); | ||
|
|
||
| if (process.platform === 'darwin' && process.env.HOME) { | ||
lerouxb marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| console.log('copying ShipIt dir if it exits'); | ||
| const shipitDir = path.resolve( | ||
| process.env.HOME, | ||
| 'Library', | ||
| 'Caches', | ||
| 'com.mongodb.compass.dev.ShipIt' | ||
| ); | ||
|
|
||
| if (fs.existsSync(shipitDir)) { | ||
| console.log(`copying ${shipitDir}`); | ||
| fs.cpSync(shipitDir, `${LOG_PATH}/ShipIt`, { recursive: true }); | ||
| } else { | ||
| console.log(`${shipitDir} does not exist`); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if (process.env.AUTO_UPDATE_UPDATABLE === 'true') { | ||
| console.log( | ||
| 'pause to make sure the app properly exited before starting again' | ||
| ); | ||
| await wait(60_000); | ||
|
|
||
| console.log('starting compass a second time'); | ||
| // 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); | ||
| } | ||
| } | ||
| }); | ||
| }); | ||
Uh oh!
There was an error while loading. Please reload this page.