Skip to content

Commit da32854

Browse files
authored
chore(e2e): scroll to the custom collation field option before clicking and take a screenshot, fix css selector COMPASS-7569 (#5342)
* scroll to the custom collation field option before clicking and take a screenshot * hopefully better css that will continue to work when the button is not focused * fix screenshot path * consistent screenshotting * disambiguate param name * remove capturePage
1 parent e78c837 commit da32854

File tree

7 files changed

+15
-30
lines changed

7 files changed

+15
-30
lines changed

packages/compass-e2e-tests/helpers/commands/add-collection.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ export async function addCollection(
7878
await menu.waitForDisplayed();
7979
const span = await menu.$(`span=${value.toString()}`);
8080
await span.waitForDisplayed();
81+
await span.scrollIntoView();
82+
await browser.screenshot(
83+
`custom-collation-${key}-${value.toString()}.png`
84+
);
8185
await span.click();
8286

8387
// make sure the menu disappears before moving on to the next thing

packages/compass-e2e-tests/helpers/commands/click-visible.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export async function clickVisible(
3030

3131
const clickElement = await getElement();
3232
if (options?.screenshot) {
33-
await browser.saveScreenshot(options.screenshot);
33+
await browser.screenshot(options.screenshot);
3434
}
3535
if (await clickElement.isEnabled()) {
3636
await clickElement.click();
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import path from 'path';
22
import type { CompassBrowser } from '../compass-browser';
3-
import { LOG_PATH } from '../compass';
3+
import { SCREENSHOTS_PATH } from '../compass';
44

55
export async function screenshot(
66
browser: CompassBrowser,
@@ -9,5 +9,5 @@ export async function screenshot(
99
// Give animations a second. Hard to have a generic way to know if animations
1010
// are still in progress or not.
1111
await browser.pause(1000);
12-
await browser.saveScreenshot(path.join(LOG_PATH, 'screenshots', filename));
12+
await browser.saveScreenshot(path.join(SCREENSHOTS_PATH, filename));
1313
}

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

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const COMPASS_PATH = path.dirname(
3939
);
4040
export const LOG_PATH = path.resolve(__dirname, '..', '.log');
4141
const OUTPUT_PATH = path.join(LOG_PATH, 'output');
42-
const SCREENSHOTS_PATH = path.join(LOG_PATH, 'screenshots');
42+
export const SCREENSHOTS_PATH = path.join(LOG_PATH, 'screenshots');
4343
const COVERAGE_PATH = path.join(LOG_PATH, 'coverage');
4444

4545
let MONGODB_VERSION = '';
@@ -106,8 +106,6 @@ export const serverSatisfies = (
106106

107107
// For the user data dirs
108108
let i = 0;
109-
// For the screenshots
110-
let j = 0;
111109

112110
interface Coverage {
113111
main?: string;
@@ -377,18 +375,6 @@ export class Compass {
377375
await fs.writeFile(compassLogPath, compassLog.raw);
378376
this.logs = compassLog.structured;
379377
}
380-
381-
async capturePage(
382-
imgPathName = `screenshot-${formattedDate()}-${++j}.png`
383-
): Promise<boolean> {
384-
try {
385-
await this.browser.saveScreenshot(path.join(LOG_PATH, imgPathName));
386-
return true;
387-
} catch (err) {
388-
console.warn((err as Error).stack);
389-
return false;
390-
}
391-
}
392378
}
393379

394380
interface StartCompassOptions {
@@ -987,9 +973,11 @@ export async function screenshotIfFailed(
987973
if (test) {
988974
if (test.state === undefined) {
989975
// if there's no state, then it is probably because the before() hook failed
990-
await compass.capturePage(screenshotPathName(`${test.fullTitle()}-hook`));
976+
await compass.browser.screenshot(
977+
screenshotPathName(`${test.fullTitle()}-hook`)
978+
);
991979
} else if (test.state === 'failed') {
992-
await compass.capturePage(screenshotPathName(test.fullTitle()));
980+
await compass.browser.screenshot(screenshotPathName(test.fullTitle()));
993981
}
994982
}
995983
}

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

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

1514
import delay from '../helpers/delay';
1615

17-
import { LOG_PATH } from '../helpers/compass';
18-
1916
const CONNECTION_HOSTS = 'localhost:27091';
2017
const CONNECTION_STRING = `mongodb://${CONNECTION_HOSTS}/`;
2118

@@ -120,9 +117,7 @@ describe('CSFLE / QE', function () {
120117
}
121118

122119
await delay(10000);
123-
await browser.saveScreenshot(
124-
path.join(LOG_PATH, 'saved-connections-after-disconnect.png')
125-
);
120+
await browser.screenshot('saved-connections-after-disconnect.png');
126121

127122
await browser.clickVisible(Selectors.sidebarFavoriteButton(favoriteName));
128123
await browser.waitUntil(async () => {

packages/compass-e2e-tests/tests/instance-databases-tab.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import { expect } from 'chai';
2-
import path from 'path';
32
import type { CompassBrowser } from '../helpers/compass-browser';
43
import { init, cleanup, screenshotIfFailed } from '../helpers/compass';
54
import type { Compass } from '../helpers/compass';
6-
import { LOG_PATH } from '../helpers/compass';
75
import * as Selectors from '../helpers/selectors';
86
import {
97
createDummyCollections,
@@ -64,7 +62,7 @@ describe('Instance databases tab', function () {
6462
// even after scrolling it into view.
6563
await browser.clickVisible(Selectors.databaseCardClickable('test'), {
6664
scroll: true,
67-
screenshot: path.join(LOG_PATH, 'database-card.png'),
65+
screenshot: 'database-card.png',
6866
});
6967

7068
const collectionSelectors = ['json-array', 'json-file', 'numbers'].map(

packages/databases-collections/src/components/collation-fields/collation-fields.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { css } from '@mongodb-js/compass-components';
1111

1212
const optionsSelectDropdownStyles = css({
1313
zIndex: 1,
14-
'button:focus, button:focus-within': {
14+
'button[aria-expanded=true]': {
1515
zIndex: 20,
1616
},
1717
});

0 commit comments

Comments
 (0)