Skip to content

Commit ccdec32

Browse files
authored
chore(e2e): move commands to commands folder (#6373)
1 parent ae0a9b3 commit ccdec32

File tree

8 files changed

+30
-33
lines changed

8 files changed

+30
-33
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,5 @@ export * from './unhide-index';
6262
export * from './hide-visible-modal';
6363
export * from './hide-visible-toasts';
6464
export * from './sidebar-collection';
65+
export * from './read-first-document-content';
66+
export * from './read-stage-operators';

packages/compass-e2e-tests/helpers/read-first-document-content.ts renamed to packages/compass-e2e-tests/helpers/commands/read-first-document-content.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import chai from 'chai';
22
const { expect } = chai;
33

4-
import type { CompassBrowser } from '../helpers/compass-browser';
5-
import * as Selectors from '../helpers/selectors';
4+
import type { CompassBrowser } from '../compass-browser';
5+
import * as Selectors from '../selectors';
66

77
export async function getFirstListDocument(browser: CompassBrowser) {
88
// We check the total from the header area so it is probably good enough to

packages/compass-e2e-tests/helpers/read-stage-operators.ts renamed to packages/compass-e2e-tests/helpers/commands/read-stage-operators.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { CompassBrowser } from '../helpers/compass-browser';
2-
import * as Selectors from '../helpers/selectors';
1+
import type { CompassBrowser } from '../compass-browser';
2+
import * as Selectors from '../selectors';
33

44
export async function getStageOperators(
55
browser: CompassBrowser,

packages/compass-e2e-tests/tests/collection-aggregations-tab.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
createNestedDocumentsCollection,
1717
createNumbersCollection,
1818
} from '../helpers/insert-data';
19-
import { getStageOperators } from '../helpers/read-stage-operators';
2019
import { saveAggregationPipeline } from '../helpers/commands/save-aggregation-pipeline';
2120
import { Key } from 'webdriverio';
2221

@@ -166,7 +165,7 @@ describe('Collection aggregations tab', function () {
166165
});
167166

168167
it('supports the right stages for the environment', async function () {
169-
const options = await getStageOperators(browser, 0);
168+
const options = await browser.getStageOperators(0);
170169

171170
const expectedAggregations = [
172171
'$addFields',

packages/compass-e2e-tests/tests/collection-ai-query.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import * as Selectors from '../helpers/selectors';
1616
import { createNumbersCollection } from '../helpers/insert-data';
1717
import { startMockAtlasServiceServer } from '../helpers/atlas-service';
1818
import type { MockAtlasServerResponse } from '../helpers/atlas-service';
19-
import { getFirstListDocument } from '../helpers/read-first-document-content';
2019

2120
describe('Collection ai query', function () {
2221
let compass: Compass;
@@ -147,7 +146,7 @@ describe('Collection ai query', function () {
147146

148147
// Run it and check that the correct documents are shown.
149148
await browser.runFind('Documents', true);
150-
const modifiedResult = await getFirstListDocument(browser);
149+
const modifiedResult = await browser.getFirstListDocument();
151150
expect(modifiedResult.i).to.be.equal('51');
152151
});
153152
});

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
TEST_COMPASS_WEB,
1212
DEFAULT_CONNECTION_NAME_1,
1313
} from '../helpers/compass';
14-
import { getFirstListDocument } from '../helpers/read-first-document-content';
1514
import type { Compass } from '../helpers/compass';
1615
import * as Selectors from '../helpers/selectors';
1716
import { startTelemetryServer } from '../helpers/telemetry';
@@ -189,7 +188,7 @@ describe('Collection import', function () {
189188
return text === '1 – 1 of 1';
190189
});
191190

192-
const result = await getFirstListDocument(browser);
191+
const result = await browser.getFirstListDocument();
193192

194193
expect(result._id).to.exist;
195194
delete result._id;
@@ -274,7 +273,7 @@ describe('Collection import', function () {
274273
return text === '1 – 1 of 1';
275274
});
276275

277-
const result = await getFirstListDocument(browser);
276+
const result = await browser.getFirstListDocument();
278277

279278
expect(result._id).to.exist;
280279
delete result._id;
@@ -334,7 +333,7 @@ describe('Collection import', function () {
334333
return text === '1 – 25 of 1000';
335334
});
336335

337-
const result = await getFirstListDocument(browser);
336+
const result = await browser.getFirstListDocument();
338337

339338
expect(result._id).to.exist;
340339
delete result._id;
@@ -402,7 +401,7 @@ describe('Collection import', function () {
402401
const text = await messageElement.getText();
403402
expect(text).to.equal('1 – 25 of 16116');
404403

405-
const result = await getFirstListDocument(browser);
404+
const result = await browser.getFirstListDocument();
406405

407406
expect(result._id).to.exist;
408407
delete result._id;
@@ -452,7 +451,7 @@ describe('Collection import', function () {
452451
const text = await messageElement.getText();
453452
expect(text).to.equal('1 – 1 of 1');
454453

455-
const result = await getFirstListDocument(browser);
454+
const result = await browser.getFirstListDocument();
456455

457456
expect(result._id).to.exist;
458457
delete result._id;
@@ -608,7 +607,7 @@ describe('Collection import', function () {
608607
const text = await messageElement.getText();
609608
expect(text).to.equal('1 – 25 of 16116');
610609

611-
const result = await getFirstListDocument(browser);
610+
const result = await browser.getFirstListDocument();
612611

613612
// _id is different every time
614613
expect(result._id).to.exist;
@@ -811,7 +810,7 @@ describe('Collection import', function () {
811810
// show the array and object fields
812811
await browser.clickVisible(Selectors.ShowMoreFieldsButton);
813812

814-
const result = await getFirstListDocument(browser);
813+
const result = await browser.getFirstListDocument();
815814

816815
expect(result._id).to.equal('1001265');
817816
});
@@ -894,7 +893,7 @@ describe('Collection import', function () {
894893
const text = await messageElement.getText();
895894
expect(text).to.equal('1 – 1 of 1');
896895

897-
const result = await getFirstListDocument(browser);
896+
const result = await browser.getFirstListDocument();
898897

899898
// _id is different every time
900899
expect(result._id).to.exist;
@@ -1044,7 +1043,7 @@ describe('Collection import', function () {
10441043
const text = await messageElement.getText();
10451044
expect(text).to.equal('1 – 1 of 1');
10461045

1047-
const result = await getFirstListDocument(browser);
1046+
const result = await browser.getFirstListDocument();
10481047

10491048
// _id is different every time
10501049
expect(result._id).to.exist;

packages/compass-e2e-tests/tests/in-use-encryption.test.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
} from '../helpers/compass';
1111
import type { Compass } from '../helpers/compass';
1212
import * as Selectors from '../helpers/selectors';
13-
import { getFirstListDocument } from '../helpers/read-first-document-content';
1413
import { MongoClient } from 'mongodb';
1514

1615
import delay from '../helpers/delay';
@@ -512,7 +511,7 @@ describe('CSFLE / QE', function () {
512511
// wait for the modal to go away
513512
await insertDialog.waitForDisplayed({ reverse: true });
514513

515-
const result = await getFirstListDocument(browser);
514+
const result = await browser.getFirstListDocument();
516515

517516
expect(result._id).to.exist;
518517
expect(result.__safeContent__).to.exist;
@@ -591,7 +590,7 @@ describe('CSFLE / QE', function () {
591590
'Documents'
592591
);
593592

594-
const result = await getFirstListDocument(browser);
593+
const result = await browser.getFirstListDocument();
595594
expect(result[field]).to.be.equal(toString(oldValueJS));
596595

597596
const document = await browser.$(Selectors.DocumentListEntry);
@@ -638,7 +637,7 @@ describe('CSFLE / QE', function () {
638637
: `{ ${field}: ${newValue} }`
639638
);
640639

641-
const modifiedResult = await getFirstListDocument(browser);
640+
const modifiedResult = await browser.getFirstListDocument();
642641
expect(modifiedResult[field]).to.be.equal(toString(newValueJS));
643642
expect(modifiedResult._id).to.be.equal(result._id);
644643
});
@@ -696,7 +695,7 @@ describe('CSFLE / QE', function () {
696695
"{ phoneNumber: '10101010' }"
697696
);
698697

699-
const modifiedResult = await getFirstListDocument(browser);
698+
const modifiedResult = await browser.getFirstListDocument();
700699
expect(modifiedResult.phoneNumber).to.be.equal('"10101010"');
701700
});
702701

@@ -847,7 +846,7 @@ describe('CSFLE / QE', function () {
847846

848847
await browser.runFindOperation('Documents', "{ name: 'Third' }");
849848

850-
const result = await getFirstListDocument(browser);
849+
const result = await browser.getFirstListDocument();
851850

852851
delete result._id;
853852
delete result.__safeContent__;
@@ -896,7 +895,7 @@ describe('CSFLE / QE', function () {
896895
'Documents'
897896
);
898897

899-
let decryptedResult = await getFirstListDocument(browser);
898+
let decryptedResult = await browser.getFirstListDocument();
900899

901900
delete decryptedResult._id;
902901
delete decryptedResult.__safeContent__;
@@ -926,7 +925,7 @@ describe('CSFLE / QE', function () {
926925
.$(Selectors.CSFLEConnectionModal)
927926
.waitForDisplayed({ reverse: true });
928927

929-
const encryptedResult = await getFirstListDocument(browser);
928+
const encryptedResult = await browser.getFirstListDocument();
930929

931930
delete encryptedResult._id;
932931
delete encryptedResult.__safeContent__;
@@ -956,7 +955,7 @@ describe('CSFLE / QE', function () {
956955
.$(Selectors.CSFLEConnectionModal)
957956
.waitForDisplayed({ reverse: true });
958957

959-
decryptedResult = await getFirstListDocument(browser);
958+
decryptedResult = await browser.getFirstListDocument();
960959

961960
delete decryptedResult._id;
962961
delete decryptedResult.__safeContent__;
@@ -1075,7 +1074,7 @@ describe('CSFLE / QE', function () {
10751074
collection,
10761075
'Documents'
10771076
);
1078-
const result = await getFirstListDocument(browser);
1077+
const result = await browser.getFirstListDocument();
10791078
expect(result.phoneNumber).to.be.equal(JSON.stringify(value));
10801079
}
10811080

@@ -1261,13 +1260,13 @@ describe('CSFLE / QE', function () {
12611260
// { v: "123", _id: 'asdf' }
12621261
// { v: "456", _id: 'ghjk' }
12631262

1264-
let decryptedResult = await getFirstListDocument(browser);
1263+
let decryptedResult = await browser.getFirstListDocument();
12651264
delete decryptedResult.__safeContent__;
12661265
expect(decryptedResult).to.deep.equal({ v: '"123"', _id: '"asdf"' });
12671266

12681267
// We can't search for the encrypted value, but it does get decrypted
12691268
await browser.runFindOperation('Documents', '{ _id: "ghjk" }');
1270-
decryptedResult = await getFirstListDocument(browser);
1269+
decryptedResult = await browser.getFirstListDocument();
12711270
delete decryptedResult.__safeContent__;
12721271
expect(decryptedResult).to.deep.equal({ v: '"456"', _id: '"ghjk"' });
12731272
});

packages/compass-e2e-tests/tests/read-only.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
import { expect } from 'chai';
1010
import * as Selectors from '../helpers/selectors';
1111
import { createNumbersCollection } from '../helpers/insert-data';
12-
import { getStageOperators } from '../helpers/read-stage-operators';
1312
import type { Compass } from '../helpers/compass';
1413
import type { CompassBrowser } from '../helpers/compass-browser';
1514

@@ -262,7 +261,7 @@ describe('readOnly: true / Read-Only Edition', function () {
262261
const stageContainers = await browser.$$(Selectors.StageCard);
263262
expect(stageContainers).to.have.lengthOf(1);
264263

265-
let options = await getStageOperators(browser, 0);
264+
let options = await browser.getStageOperators(0);
266265

267266
expect(options).to.include('$match');
268267
expect(options).to.include('$out');
@@ -291,7 +290,7 @@ describe('readOnly: true / Read-Only Edition', function () {
291290

292291
await browser.focusStageOperator(0);
293292

294-
options = await getStageOperators(browser, 0);
293+
options = await browser.getStageOperators(0);
295294

296295
expect(options).to.include('$match');
297296
expect(options).to.not.include('$out');

0 commit comments

Comments
 (0)