Skip to content

Commit

Permalink
FI-1647 fix: selector description in except's methods
Browse files Browse the repository at this point in the history
  • Loading branch information
uid11 committed Jan 27, 2025
1 parent fc95e83 commit 1c34f86
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.idea
bin/forks/*/package
build
local
node_modules
2 changes: 2 additions & 0 deletions autotests/tests/main/exists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ test('exists', {meta: {testId: '1'}, testIdleTimeout: 10_000, testTimeout: 15_00

const mainPage = await navigateToPage(Main, {language});

await expect(mainPage.header.textContent, 'header text is ok').ok();

const urlObject = await urlObjectPromise;

await expect(getDocumentUrl(), 'waitForStartOfPageLoad returns correct url object').eql(
Expand Down
13 changes: 7 additions & 6 deletions src/utils/expect/createExpectMethod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {valueToString, wrapStringForLogs} from '../valueToString';
import {additionalMatchers} from './additionalMatchers';
import {applyAdditionalMatcher} from './applyAdditionalMatcher';

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

import type {Expect} from './Expect';
import type {AssertionFunction, ExpectMethod} from './types';
Expand All @@ -36,6 +36,9 @@ export const createExpectMethod = (
const timeout = assertionTimeout + additionalAssertionTimeoutInMs;
const message = getAssertionMessage === undefined ? key : getAssertionMessage(...args);

const selectorPropertyRetryData = (
this.actualValue as {[RETRY_KEY]?: SelectorPropertyRetryData}
)?.[RETRY_KEY];
const timeoutWithUnits = getDurationWithUnits(timeout);
const error = new E2edError(
`"${key}" assertion promise rejected after ${timeoutWithUnits} timeout`,
Expand All @@ -46,10 +49,6 @@ export const createExpectMethod = (
const ctx: Expect = {actualValue: value, description: this.description};

if (additionalMatcher !== undefined) {
const selectorPropertyRetryData = (
this.actualValue as {[RETRY_KEY]?: SelectorPropertyRetryData}
)?.[RETRY_KEY];

return addTimeoutToPromise(
applyAdditionalMatcher(
additionalMatcher as Fn<unknown[], Promise<unknown>>,
Expand Down Expand Up @@ -86,9 +85,11 @@ export const createExpectMethod = (
const logMessage = `Assert: ${this.description}`;
const logPayload = {
assertionArguments: args,
description: value != null ? getDescriptionFromSelector(value as Selector) : undefined,
error: maybeError,
logEventStatus: maybeError ? LogEventStatus.Failed : LogEventStatus.Passed,
selector: selectorPropertyRetryData
? getDescriptionFromSelector(selectorPropertyRetryData.selector)
: undefined,
};

return addTimeoutToPromise(Promise.resolve(value), timeout, error)
Expand Down

0 comments on commit 1c34f86

Please sign in to comment.