From 1c34f86157aca4ec1f047b49f4afb20eb7c7f075 Mon Sep 17 00:00:00 2001 From: uid11 Date: Mon, 27 Jan 2025 23:25:49 +0300 Subject: [PATCH] FI-1647 fix: selector description in `except`'s methods --- .gitignore | 1 - autotests/tests/main/exists.ts | 2 ++ src/utils/expect/createExpectMethod.ts | 13 +++++++------ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index b5b377b4..60aa67b8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ .idea -bin/forks/*/package build local node_modules diff --git a/autotests/tests/main/exists.ts b/autotests/tests/main/exists.ts index c7c064d6..5ea28e26 100644 --- a/autotests/tests/main/exists.ts +++ b/autotests/tests/main/exists.ts @@ -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( diff --git a/src/utils/expect/createExpectMethod.ts b/src/utils/expect/createExpectMethod.ts index b0a8b132..09cbc072 100644 --- a/src/utils/expect/createExpectMethod.ts +++ b/src/utils/expect/createExpectMethod.ts @@ -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'; @@ -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`, @@ -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>, @@ -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)