Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {setPageCookies, setPageRequestHeaders} from 'autotests/context';
import {E2edReportExample as E2edReportExampleRoute} from 'autotests/routes/pageRoutes';
import {locator} from 'autotests/selectors';
import {Page} from 'e2ed';
import {click} from 'e2ed/actions';
import {setReadonlyProperty} from 'e2ed/utils';

import {TestRunButton} from './TestRunButton';
Expand Down Expand Up @@ -65,7 +66,7 @@ export class E2edReportExample extends Page<CustomPageParams> {
* List of test runs of retry.
*/
get testRunsList(): Selector {
return locator('column1');
return locator('column-2');
}

/**
Expand All @@ -81,6 +82,10 @@ export class E2edReportExample extends Page<CustomPageParams> {
}
}

async clickLogo(): Promise<void> {
await click(this.header, {position: {x: 30, y: 30}});
}

getRoute(): E2edReportExampleRoute {
return new E2edReportExampleRoute();
}
Expand Down
100 changes: 53 additions & 47 deletions autotests/tests/e2edReportExample/browserData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,50 +10,56 @@ import {
waitForInterfaceStabilization,
} from 'e2ed/actions';

test('correctly read data from browser', {meta: {testId: '14'}}, async () => {
await navigateToPage(E2edReportExample);

await createClientFunction(() => {
console.error('error');
console.info('info');
console.log('log');
console.warn('warning');

setTimeout(() => {
throw new Error('foo');
}, 100);
})();

const consoleMessages = getBrowserConsoleMessages();
const columnNumber = 12;
const url = '';

const consoleMessagesWithoutDate = consoleMessages.map(
({dateTimeInIso: _, ...messageWithoutDate}) => messageWithoutDate,
);

await expect(consoleMessagesWithoutDate, 'getBrowserConsoleMessages read all of messages').eql([
{args: ['error'], location: {columnNumber, lineNumber: 3, url}, text: 'error', type: 'error'},
{args: ['info'], location: {columnNumber, lineNumber: 4, url}, text: 'info', type: 'info'},
{args: ['log'], location: {columnNumber, lineNumber: 5, url}, text: 'log', type: 'log'},
{
args: ['warning'],
location: {columnNumber, lineNumber: 6, url},
text: 'warning',
type: 'warning',
},
]);

const jsErrors = getBrowserJsErrors();

await expect(
jsErrors.length,
'getBrowserJsErrors read zero JS errors when there are no errors',
).eql(0);

await waitForInterfaceStabilization(100);

await expect(jsErrors.length, 'getBrowserJsErrors read all JS errors').eql(1);

await expect(String(jsErrors[0]?.error), 'getBrowserJsErrors read all JS errors').contains('foo');
});
test(
'correctly read data from browser',
{meta: {testId: '14'}, viewportHeight: 1200, viewportWidth: 1600},
async () => {
await navigateToPage(E2edReportExample);

await createClientFunction(() => {
console.error('error');
console.info('info');
console.log('log');
console.warn('warning');

setTimeout(() => {
throw new Error('foo');
}, 100);
})();

const consoleMessages = getBrowserConsoleMessages();
const columnNumber = 12;
const url = '';

const consoleMessagesWithoutDate = consoleMessages.map(
({dateTimeInIso: _, ...messageWithoutDate}) => messageWithoutDate,
);

await expect(consoleMessagesWithoutDate, 'getBrowserConsoleMessages read all of messages').eql([
{args: ['error'], location: {columnNumber, lineNumber: 3, url}, text: 'error', type: 'error'},
{args: ['info'], location: {columnNumber, lineNumber: 4, url}, text: 'info', type: 'info'},
{args: ['log'], location: {columnNumber, lineNumber: 5, url}, text: 'log', type: 'log'},
{
args: ['warning'],
location: {columnNumber, lineNumber: 6, url},
text: 'warning',
type: 'warning',
},
]);

const jsErrors = getBrowserJsErrors();

await expect(
jsErrors.length,
'getBrowserJsErrors read zero JS errors when there are no errors',
).eql(0);

await waitForInterfaceStabilization(100);

await expect(jsErrors.length, 'getBrowserJsErrors read all JS errors').eql(1);

await expect(String(jsErrors[0]?.error), 'getBrowserJsErrors read all JS errors').contains(
'foo',
);
},
);
14 changes: 12 additions & 2 deletions autotests/tests/internalTypeTests/selectors.skip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,18 @@ import type {Selector} from 'e2ed/types';

// @ts-expect-error: wrong number of arguments
htmlElementSelector.findByTestId();
// @ts-expect-error: wrong type of arguments
htmlElementSelector.findByTestId(0);
// ok
htmlElementSelector.filterByTestId(0);
// ok
htmlElementSelector.findByTestId(true);
// ok
htmlElementSelector.filterByTestId(undefined);
// ok
htmlElementSelector.filterByTestId(null);
// ok
htmlElementSelector.findByTestId(1, 2, 2);
// ok
htmlElementSelector.filterByTestId('foo', 'bar', 'baz');
// ok
htmlElementSelector.findByTestId('id') satisfies Selector;
// ok
Expand Down
3 changes: 1 addition & 2 deletions autotests/tests/switchingPagesForRequests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {E2edReportExample} from 'autotests/pageObjects/pages';
import {GetUsers} from 'autotests/routes/apiRoutes';
import {expect} from 'e2ed';
import {
click,
navigateToPage,
switchToTab,
waitForNewTab,
Expand Down Expand Up @@ -54,7 +53,7 @@ test(
await waitForTimeout(maxNumberOfRequests * 333);

const npmPageTab = await waitForNewTab(async () => {
await click(reportPage.header);
await reportPage.clickLogo();
});

await switchToTab(npmPageTab);
Expand Down
3 changes: 1 addition & 2 deletions autotests/tests/switchingPagesForResponses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {E2edReportExample} from 'autotests/pageObjects/pages';
import {GetUsers} from 'autotests/routes/apiRoutes';
import {expect} from 'e2ed';
import {
click,
navigateToPage,
switchToTab,
waitForNewTab,
Expand Down Expand Up @@ -54,7 +53,7 @@ test(
await waitForTimeout(maxNumberOfRequests * 333);

const npmPageTab = await waitForNewTab(async () => {
await click(reportPage.header);
await reportPage.clickLogo();
});

await switchToTab(npmPageTab);
Expand Down
65 changes: 33 additions & 32 deletions package-lock.json

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

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
"url": "git+https://github.com/joomcode/e2ed.git"
},
"dependencies": {
"@playwright/test": "1.56.0",
"@playwright/test": "1.57.0",
"create-locator": "0.0.27",
"get-modules-graph": "0.0.11",
"sort-json-keys": "1.0.3"
},
"devDependencies": {
"@playwright/browser-chromium": "1.56.0",
"@types/node": "24.7.0",
"@playwright/browser-chromium": "1.57.0",
"@types/node": "24.10.1",
"@typescript-eslint/eslint-plugin": "7.18.0",
"@typescript-eslint/parser": "7.18.0",
"assert-modules-support-case-insensitive-fs": "1.0.1",
Expand All @@ -44,7 +44,7 @@
"eslint-plugin-simple-import-sort": "12.1.1",
"eslint-plugin-typescript-sort-keys": "3.3.0",
"husky": "9.1.7",
"prettier": "3.6.2",
"prettier": "3.7.4",
"typescript": "5.9.3"
},
"peerDependencies": {
Expand Down
17 changes: 17 additions & 0 deletions src/actions/blur.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {LogEventType} from '../constants/internal';
import {log} from '../utils/log';

import type {Locator} from '@playwright/test';

import type {Selector} from '../types/internal';

type Options = Parameters<Locator['blur']>[0];

/**
* Blur an element.
*/
export const blur = async (selector: Selector, options: Options = {}): Promise<void> => {
log('Blur an element', {...options, selector}, LogEventType.InternalAction);

await selector.getPlaywrightLocator().blur(options);
};
Loading
Loading