Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .evergreen/buildvariants-and-tasks.in.yml
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ tasks:
- func: bootstrap
vars:
scope: 'compass-e2e-tests'
- func: get-update-server
- func: smoketest-packaged-app
vars:
mongodb_version: latest-enterprise
Expand Down
1 change: 1 addition & 0 deletions .evergreen/buildvariants-and-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@ tasks:
- func: bootstrap
vars:
scope: compass-e2e-tests
- func: get-update-server
- func: smoketest-packaged-app
vars:
mongodb_version: latest-enterprise
Expand Down
45 changes: 41 additions & 4 deletions .evergreen/functions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,39 @@ functions:

npm run --unsafe-perm --workspace compass-e2e-tests test-packaged-ci

get-update-server:
- command: github.generate_token
params:
owner: 10gen
repo: compass-mongodb-com
expansion_name: generated_token
permissions: # optional
contents: read
- command: shell.exec
type: setup
params:
working_dir: src
shell: bash
env:
<<: *compass-env
script: |
set -e
eval $(.evergreen/print-compass-env.sh)
git clone https://x-access-token:${generated_token}@github.com/10gen/compass-mongodb-com.git ../compass-mongodb-com
cd ../compass-mongodb-com
echo "Using node version:";
node -v;
echo "Using npm version:";
npm -v;
echo "Using gcc version:"
gcc --version;
echo "Using g++ version:"
g++ --version;
npm ci --engine-strict=false
npm link --engine-strict=false
cd ../src
npm link compass-mongodb-com --engine-strict=false

smoketest-packaged-app:
- command: shell.exec
# Fail the task if it's idle for 10 mins
Expand All @@ -668,15 +701,19 @@ functions:
eval $(.evergreen/print-compass-env.sh)

if [[ "$IS_WINDOWS" == "true" ]]; then
npm run --unsafe-perm --workspace @mongodb-js/compass-smoke-tests start -- --package=windows_zip
npm run --unsafe-perm --workspace @mongodb-js/compass-smoke-tests start -- --package=windows_msi
# TODO: windows_setup
npm run --unsafe-perm --workspace @mongodb-js/compass-smoke-tests start -- --package=windows_zip --tests=auto-update-from
npm run --unsafe-perm --workspace @mongodb-js/compass-smoke-tests start -- --package=windows_msi --tests=auto-update-from
fi

if [[ "$IS_OSX" == "true" ]]; then
echo "Disabling clipboard usage in e2e tests (TODO: https://jira.mongodb.org/browse/BUILD-14780)"
export COMPASS_E2E_DISABLE_CLIPBOARD_USAGE="true"
npm run --unsafe-perm --workspace @mongodb-js/compass-smoke-tests start -- --package=osx_dmg
npm run --unsafe-perm --workspace @mongodb-js/compass-smoke-tests start -- --package=osx_zip
# NOTE: We're also skipping auto-update of the macOS app in CI
# because it doesn't work. Running a different test to make sure it
# can install and run successfully at least.
npm run --unsafe-perm --workspace @mongodb-js/compass-smoke-tests start -- --package=osx_zip --tests=time-to-first-query
npm run --unsafe-perm --workspace @mongodb-js/compass-smoke-tests start -- --package=osx_dmg --tests=time-to-first-query
fi

#if [[ "$IS_UBUNTU" == "true" ]]; then
Expand Down
6 changes: 3 additions & 3 deletions .evergreen/preinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ echo "APPDATA: $APPDATA"
echo "PATH: $PATH"

# these are super useful if you want to run the smoke tests locally
echo "DEV_VERSION_IDENTIFIER: $DEV_VERSION_IDENTIFIER"
echo "EVERGREEN_BUCKET_NAME: $EVERGREEN_BUCKET_NAME"
echo "EVERGREEN_BUCKET_KEY_PREFIX: $EVERGREEN_BUCKET_KEY_PREFIX"
echo "export DEV_VERSION_IDENTIFIER=$DEV_VERSION_IDENTIFIER"
echo "export EVERGREEN_BUCKET_KEY_PREFIX=$EVERGREEN_BUCKET_KEY_PREFIX"
echo "export EVERGREEN_BUCKET_NAME=$EVERGREEN_BUCKET_NAME"

echo "IS_OSX: $IS_OSX"
echo "IS_LINUX: $IS_LINUX"
Expand Down
8 changes: 8 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions packages/compass-e2e-tests/helpers/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1380,3 +1380,12 @@ export const GlobalWrites = {
SampleFindingDocuments: '[data-testid="sample-finding-documents"]',
SampleInsertingDocuments: '[data-testid="sample-inserting-documents"]',
};

// Auto-update toasts
export const AutoUpdateToast = '[data-testid="toast-compass-update"]';
export const AutoUpdateRestartButton =
'[data-testid="auto-update-restart-button"]';
export const AutoUpdateDownloadLink =
'[data-testid="auto-update-download-link"]';
export const AutoUpdateReleaseNotesLink =
'[data-testid="auto-update-release-notes-link"]';
78 changes: 78 additions & 0 deletions packages/compass-e2e-tests/tests/auto-update.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { expect } from 'chai';
import {
init,
cleanup,
Selectors,
screenshotPathName,
} from '../helpers/compass';

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') {
// 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');
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.env.AUTO_UPDATE_UPDATABLE === 'true') {
console.log(
'pause to make sure the app properly exited before starting again'
);
await wait(10_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);
}
}
});
});
10 changes: 9 additions & 1 deletion packages/compass-smoke-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"eslint": "eslint",
"prettier": "prettier",
"lint": "npm run eslint . && npm run prettier -- --check .",
"depcheck": "compass-scripts check-peer-deps && depcheck",
"depcheck": "depcheck",
Copy link
Contributor

Choose a reason for hiding this comment

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

😬 If this doesn't handle optionalDependencies, we should probably add a ticket tracking a fix for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that's for compass plugins, though. Which is probably why it is a separate script and not part of depcheck.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll ask @gribnoysup what he thinks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Checking this rather than npm link, removing it as a peer dep.
5926b93

"check": "npm run typecheck && npm run lint && npm run depcheck",
"check-ci": "npm run check",
"reformat": "npm run eslint . -- --fix && npm run prettier -- --write ."
Expand All @@ -41,5 +41,13 @@
"prettier": "^2.7.1",
"typescript": "^5.0.4",
"yargs": "^17.7.2"
},
"peerDependencies": {
"compass-mongodb-com": "*"
},
"peerDependenciesMeta": {
"compass-mongodb-com": {
"optional": true
}
}
}
Loading
Loading