Skip to content

Commit a0b6199

Browse files
committed
comments
1 parent 9585f50 commit a0b6199

File tree

4 files changed

+36
-19
lines changed

4 files changed

+36
-19
lines changed

packages/compass-e2e-tests/helpers/commands/connect-form.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
DEFAULT_CONNECTION_NAME_2,
99
DEFAULT_CONNECTION_STRING_1,
1010
DEFAULT_CONNECTION_STRING_2,
11+
TEST_ATLAS_CLOUD_EXTERNAL_URL,
1112
TEST_MULTIPLE_CONNECTIONS,
1213
} from '../compass';
1314
import Debug from 'debug';
@@ -986,6 +987,12 @@ export async function setupDefaultConnections(browser: CompassBrowser) {
986987
whereas we do have some tests that try and use those. We can easily change
987988
this in future if needed, though.
988989
*/
990+
991+
// no need to setup connections if we are running against Atlas
992+
if (!TEST_ATLAS_CLOUD_EXTERNAL_URL) {
993+
return;
994+
}
995+
989996
for (const connectionName of [
990997
DEFAULT_CONNECTION_NAME_1,
991998
DEFAULT_CONNECTION_NAME_2,

packages/compass-e2e-tests/helpers/compass.ts

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ let MONGODB_USE_ENTERPRISE =
4646

4747
// should we test compass-web (true) or compass electron (false)?
4848
export const TEST_COMPASS_WEB = process.argv.includes('--test-compass-web');
49-
export const ATLAS_DOMAIN = process.env.ATLAS_DOMAIN;
50-
export const ATLAS_GROUP_ID = process.env.ATLAS_GROUP_ID;
49+
export const TEST_ATLAS_CLOUD_EXTERNAL_URL =
50+
process.env.TEST_ATLAS_CLOUD_EXTERNAL_URL;
51+
export const TEST_ATLAS_CLOUD_EXTERNAL_GROUP_ID =
52+
process.env.TEST_ATLAS_CLOUD_EXTERNAL_GROUP_ID;
5153
// multiple connections is now the default
5254
export const TEST_MULTIPLE_CONNECTIONS = true;
5355

@@ -78,21 +80,21 @@ export const MONGODB_TEST_SERVER_PORT = Number(
7880
);
7981

8082
export const DEFAULT_CONNECTION_STRING_1 =
81-
process.env.CONNECTION_STRING_1 ||
83+
process.env.TEST_ATLAS_CLOUD_EXTERNAL_CONNECTION_STRING_1 ||
8284
`mongodb://127.0.0.1:${MONGODB_TEST_SERVER_PORT}/test`;
8385
// NOTE: in browser.setupDefaultConnections() we don't give the first connection an
8486
// explicit name, so it gets a calculated one based off the connection string
8587
export const DEFAULT_CONNECTION_NAME_1 =
86-
process.env.CONNECTION_NAME_1 ||
88+
process.env.TEST_ATLAS_CLOUD_EXTERNAL_CONNECTION_NAME_1 ||
8789
connectionNameFromString(DEFAULT_CONNECTION_STRING_1);
8890

8991
// for testing multiple connections
9092
export const DEFAULT_CONNECTION_STRING_2 =
91-
process.env.CONNECTION_STRING_2 ||
93+
process.env.TEST_ATLAS_CLOUD_EXTERNAL_CONNECTION_STRING_2 ||
9294
`mongodb://127.0.0.1:${MONGODB_TEST_SERVER_PORT + 1}/test`;
9395
// NOTE: in browser.setupDefaultConnections() the second connection gets given an explicit name
9496
export const DEFAULT_CONNECTION_NAME_2 =
95-
process.env.CONNECTION_NAME_2 || 'connection-2';
97+
process.env.TEST_ATLAS_CLOUD_EXTERNAL_CONNECTION_NAME_2 || 'connection-2';
9698

9799
export function updateMongoDBServerInfo() {
98100
try {
@@ -111,7 +113,7 @@ export function updateMongoDBServerInfo() {
111113
'server-info',
112114
'--',
113115
'--connectionString',
114-
process.env.CONNECTION_STRING_1 ||
116+
process.env.TEST_ATLAS_CLOUD_EXTERNAL_CONNECTION_STRING_1 ||
115117
`mongodb://127.0.0.1:${String(MONGODB_TEST_SERVER_PORT)}`,
116118
],
117119
{ encoding: 'utf-8' }
@@ -767,6 +769,16 @@ async function startCompassElectron(
767769
return compass;
768770
}
769771

772+
export type StoredAtlasCloudCookies = {
773+
name: string;
774+
value: string;
775+
domain: string;
776+
path: string;
777+
secure: boolean;
778+
httpOnly: boolean;
779+
expirationDate: number;
780+
}[];
781+
770782
export async function startBrowser(
771783
name: string,
772784
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -794,17 +806,19 @@ export async function startBrowser(
794806
...wdioOptions,
795807
})) as CompassBrowser;
796808

797-
if (ATLAS_DOMAIN) {
809+
if (TEST_ATLAS_CLOUD_EXTERNAL_URL) {
798810
// Navigate to a 404 page to set cookies
799-
await browser.navigateTo(`https://${ATLAS_DOMAIN}/404`);
811+
await browser.navigateTo(`https://${TEST_ATLAS_CLOUD_EXTERNAL_URL}/404`);
800812

801813
const cookiesFile = process.env.COOKIES_FILE;
802814
if (!cookiesFile) {
803815
throw new Error(
804816
'ATLAS_DOMAIN is set but COOKIES_FILE is not. Please set COOKIES_FILE to the path of the cookies file.'
805817
);
806818
}
807-
const cookies = JSON.parse(await fs.readFile(cookiesFile, 'utf8'));
819+
const cookies: StoredAtlasCloudCookies = JSON.parse(
820+
await fs.readFile(cookiesFile, 'utf8')
821+
);
808822

809823
for (const cookie of cookies) {
810824
if (
@@ -824,7 +838,7 @@ export async function startBrowser(
824838
}
825839

826840
await browser.navigateTo(
827-
`https://${ATLAS_DOMAIN}/v2/${ATLAS_GROUP_ID}#/explorer`
841+
`https://${TEST_ATLAS_CLOUD_EXTERNAL_URL}/v2/${TEST_ATLAS_CLOUD_EXTERNAL_GROUP_ID}#/explorer`
828842
);
829843
} else {
830844
await browser.navigateTo('http://localhost:7777/');

packages/compass-e2e-tests/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
LOG_PATH,
1919
removeUserDataDir,
2020
updateMongoDBServerInfo,
21-
ATLAS_DOMAIN,
21+
TEST_ATLAS_CLOUD_EXTERNAL_URL,
2222
} from './helpers/compass';
2323
import ResultLogger from './helpers/result-logger';
2424

@@ -61,7 +61,7 @@ async function setup() {
6161
const disableStartStop = process.argv.includes('--disable-start-stop');
6262
const shouldTestCompassWeb = process.argv.includes('--test-compass-web');
6363

64-
if (!ATLAS_DOMAIN) {
64+
if (!TEST_ATLAS_CLOUD_EXTERNAL_URL) {
6565
// When working on the tests it is faster to just keep the server running.
6666
if (!disableStartStop) {
6767
debug('Starting MongoDB server');
@@ -142,7 +142,7 @@ function cleanup() {
142142
const disableStartStop = process.argv.includes('--disable-start-stop');
143143
const shouldTestCompassWeb = process.argv.includes('--test-compass-web');
144144

145-
if (!ATLAS_DOMAIN) {
145+
if (!TEST_ATLAS_CLOUD_EXTERNAL_URL) {
146146
if (!disableStartStop) {
147147
if (shouldTestCompassWeb) {
148148
debug('Stopping compass-web');

packages/compass-e2e-tests/tests/collection-rename.test.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
screenshotIfFailed,
77
TEST_COMPASS_WEB,
88
DEFAULT_CONNECTION_NAME_1,
9-
ATLAS_DOMAIN,
109
} from '../helpers/compass';
1110
import type { CompassBrowser } from '../helpers/compass-browser';
1211
import { createDummyCollections } from '../helpers/insert-data';
@@ -85,10 +84,7 @@ describe('Collection Rename Modal', () => {
8584
before(async function () {
8685
compass = await init(this.test?.fullTitle());
8786
browser = compass.browser;
88-
// no need to setup connections if we are running against Atlas
89-
if (!ATLAS_DOMAIN) {
90-
await browser.setupDefaultConnections();
91-
}
87+
await browser.setupDefaultConnections();
9288
});
9389

9490
beforeEach(async function () {

0 commit comments

Comments
 (0)