diff --git a/docs/en/html-reporter-setup.md b/docs/en/html-reporter-setup.md index cae860a25..1eecbe230 100644 --- a/docs/en/html-reporter-setup.md +++ b/docs/en/html-reporter-setup.md @@ -250,6 +250,17 @@ For example: } ``` +When value of any key is set to `auto`, the base url will be set base host specified in the UI or kept intact if there base host isn't specified. + +For example, if you have the following `metaInfoBaseUrls` value: +```javascript +{ custom_url: 'auto' } +``` + +And set `meta.custom_url` field to `https://example.com/some/path` in your tests, you'll see in meta: +- A link to `https://example.com/some/path` when base host is not set in the UI +- A link to `https://another-host.com/some/path` when base host in the UI is set to 'https://another-host.com' + ### saveFormat **DEPRECATED** diff --git a/docs/ru/html-reporter-setup.md b/docs/ru/html-reporter-setup.md index d89aec5ec..2427c65d8 100644 --- a/docs/ru/html-reporter-setup.md +++ b/docs/ru/html-reporter-setup.md @@ -250,6 +250,18 @@ throw err; } ``` +Когда значение любого ключа установлено на `auto`, базовый URL будет установлен на базовый хост, указанный в интерфейсе отчета, или останется неизменным, если базовый хост не указан. + +Например, если у вас есть следующее значение `metaInfoBaseUrls`: + +```javascript +{ custom_url: 'auto' } +``` + +И вы установите поле `meta.custom_url` в `https://example.com/some/path` в ваших тестах, вы увидите в мете: +- Ссылку на `https://example.com/some/path`, если базовый хост не установлен в интерфейсе пользователя +- Ссылку на `https://another-host.com/some/path`, если базовый хост в интерфейсе пользователя установлен в `https://another-host.com` + ### saveFormat **Параметр устарел** diff --git a/lib/adapters/test-result/transformers/db.ts b/lib/adapters/test-result/transformers/db.ts index 635d2def6..7953d25ae 100644 --- a/lib/adapters/test-result/transformers/db.ts +++ b/lib/adapters/test-result/transformers/db.ts @@ -1,6 +1,6 @@ import {ReporterTestResult} from '../index'; import {DbTestResult} from '../../../sqlite-client'; -import {getError, getRelativeUrl, getUrlWithBase} from '../../../common-utils'; +import {getError, getUrlWithBase} from '../../../common-utils'; import _ from 'lodash'; interface Options { @@ -18,7 +18,7 @@ export class DbTestResultTransformer { const suiteUrl = getUrlWithBase(testResult.url, this._options.baseHost); const metaInfoFull = _.merge(_.cloneDeep(testResult.meta), { - url: getRelativeUrl(suiteUrl) ?? '', + url: testResult.meta?.url ?? suiteUrl ?? '', file: testResult.file, sessionId: testResult.sessionId }); diff --git a/lib/static/components/section/body/meta-info/content.jsx b/lib/static/components/section/body/meta-info/content.jsx index a2807bab8..cc843208f 100644 --- a/lib/static/components/section/body/meta-info/content.jsx +++ b/lib/static/components/section/body/meta-info/content.jsx @@ -4,7 +4,7 @@ import {connect} from 'react-redux'; import {DefinitionList} from '@gravity-ui/components'; import PropTypes from 'prop-types'; import {map, mapValues, isObject, omitBy, isEmpty} from 'lodash'; -import {isUrl, getUrlWithBase} from '../../../../../common-utils'; +import {isUrl, getUrlWithBase, getRelativeUrl} from '../../../../../common-utils'; const serializeMetaValues = (metaInfo) => mapValues(metaInfo, (v) => isObject(v) ? JSON.stringify(v) : v); @@ -32,7 +32,7 @@ const metaToElements = (metaInfo, metaInfoBaseUrls) => { if (isUrl(value)) { url = value; - } else if (metaInfoBaseUrls[key]) { + } else if (metaInfoBaseUrls[key] && metaInfoBaseUrls[key] !== 'auto') { const baseUrl = metaInfoBaseUrls[key]; const link = isUrl(baseUrl) ? resolveUrl(baseUrl, value) : path.join(baseUrl, value); url = link; @@ -95,8 +95,19 @@ class MetaInfoContent extends Component { formattedMetaInfo[key] = {content: formattedMetaInfo[key]}; }); - if (result.suiteUrl) { - formattedMetaInfo.url = {content: result.metaInfo.url || result.suiteUrl, url: getUrlWithBase(result.suiteUrl, baseHost)}; + for (const [key, value] of Object.entries(formattedMetaInfo)) { + if (isUrl(value.content) && (key === 'url' || metaInfoBaseUrls[key] === 'auto')) { + formattedMetaInfo[key] = { + content: getRelativeUrl(value.content), + url: getUrlWithBase(getRelativeUrl(value.content), baseHost) + }; + } + } + if (!formattedMetaInfo.url && result.suiteUrl) { + formattedMetaInfo.url = { + content: getRelativeUrl(result.suiteUrl), + url: getUrlWithBase(getRelativeUrl(result.suiteUrl), baseHost) + }; } return metaToElements(formattedMetaInfo, metaInfoBaseUrls); diff --git a/lib/static/components/suites.jsx b/lib/static/components/suites.jsx index 7a4fd1571..608828d51 100644 --- a/lib/static/components/suites.jsx +++ b/lib/static/components/suites.jsx @@ -14,7 +14,7 @@ import {getVisibleRootSuiteIds} from '../modules/selectors/tree'; function VirtualizedRow(props) { const resizeObserverRef = useRef(null); - useResizeObserver(resizeObserverRef, () => props.onResize); + useResizeObserver(resizeObserverRef, props.onResize); return
diff --git a/test/func/common.testplane.conf.js b/test/func/common.testplane.conf.js index 0ffee03fa..66a3b4519 100644 --- a/test/func/common.testplane.conf.js +++ b/test/func/common.testplane.conf.js @@ -9,6 +9,9 @@ module.exports.getCommonConfig = (projectDir) => ({ browsers: { chrome: { + assertViewOpts: { + ignoreDiffPixelCount: 4 + }, windowSize: '1280x1024', desiredCapabilities: { browserName: 'chrome', diff --git a/test/func/tests/screens/1361a92/chrome-pwt/retry-selector.png b/test/func/tests/screens/1361a92/chrome-pwt/retry-selector.png deleted file mode 100644 index 7432c9cd0..000000000 Binary files a/test/func/tests/screens/1361a92/chrome-pwt/retry-selector.png and /dev/null differ diff --git a/test/func/tests/screens/1361a92/chrome/retry-selector.png b/test/func/tests/screens/1361a92/chrome/retry-selector.png index f3cf584c5..f446cdd2f 100644 Binary files a/test/func/tests/screens/1361a92/chrome/retry-selector.png and b/test/func/tests/screens/1361a92/chrome/retry-selector.png differ diff --git a/test/func/tests/screens/1361a92/chrome/success.png b/test/func/tests/screens/1361a92/chrome/success.png deleted file mode 100644 index dbf3ade14..000000000 Binary files a/test/func/tests/screens/1361a92/chrome/success.png and /dev/null differ diff --git a/test/func/tests/screens/197b2c2/chrome/retry-switcher.png b/test/func/tests/screens/197b2c2/chrome/retry-switcher.png deleted file mode 100644 index 3864eb304..000000000 Binary files a/test/func/tests/screens/197b2c2/chrome/retry-switcher.png and /dev/null differ diff --git a/test/func/tests/screens/328ef49/chrome/retry-selector.png b/test/func/tests/screens/328ef49/chrome/retry-selector.png deleted file mode 100644 index a40bb6b78..000000000 Binary files a/test/func/tests/screens/328ef49/chrome/retry-selector.png and /dev/null differ diff --git a/test/func/tests/screens/42ea26d/chrome-pwt/retry-selector.png b/test/func/tests/screens/42ea26d/chrome-pwt/retry-selector.png deleted file mode 100644 index d78257ad8..000000000 Binary files a/test/func/tests/screens/42ea26d/chrome-pwt/retry-selector.png and /dev/null differ diff --git a/test/func/tests/screens/42ea26d/chrome/pink.png b/test/func/tests/screens/42ea26d/chrome/pink.png deleted file mode 100644 index a40bb6b78..000000000 Binary files a/test/func/tests/screens/42ea26d/chrome/pink.png and /dev/null differ diff --git a/test/func/tests/screens/42ea26d/chrome/retry-selector.png b/test/func/tests/screens/42ea26d/chrome/retry-selector.png index 9e1ce15b2..dc9d6968f 100644 Binary files a/test/func/tests/screens/42ea26d/chrome/retry-selector.png and b/test/func/tests/screens/42ea26d/chrome/retry-selector.png differ diff --git a/test/func/tests/screens/87f8b7e/chrome/retry-switcher.png b/test/func/tests/screens/87f8b7e/chrome/retry-switcher.png deleted file mode 100644 index d788a5e78..000000000 Binary files a/test/func/tests/screens/87f8b7e/chrome/retry-switcher.png and /dev/null differ diff --git a/test/func/tests/screens/9b544b9/chrome/retry-switcher.png b/test/func/tests/screens/9b544b9/chrome/retry-switcher.png deleted file mode 100644 index 3864eb304..000000000 Binary files a/test/func/tests/screens/9b544b9/chrome/retry-switcher.png and /dev/null differ diff --git a/test/func/tests/screens/9e6270b/chrome/retry-switcher.png b/test/func/tests/screens/9e6270b/chrome/retry-switcher.png deleted file mode 100644 index d788a5e78..000000000 Binary files a/test/func/tests/screens/9e6270b/chrome/retry-switcher.png and /dev/null differ diff --git a/test/func/tests/screens/aec277d/chrome/retry-switcher.png b/test/func/tests/screens/aec277d/chrome/retry-switcher.png deleted file mode 100644 index d788a5e78..000000000 Binary files a/test/func/tests/screens/aec277d/chrome/retry-switcher.png and /dev/null differ diff --git a/test/func/tests/screens/c0db305/chrome-pwt/details summary.png b/test/func/tests/screens/c0db305/chrome-pwt/details summary.png deleted file mode 100644 index 375eb098c..000000000 Binary files a/test/func/tests/screens/c0db305/chrome-pwt/details summary.png and /dev/null differ diff --git a/test/func/tests/screens/c9299b2/chrome/retry-switcher.png b/test/func/tests/screens/c9299b2/chrome/retry-switcher.png deleted file mode 100644 index 3864eb304..000000000 Binary files a/test/func/tests/screens/c9299b2/chrome/retry-switcher.png and /dev/null differ diff --git a/test/func/tests/screens/d90f7de/chrome-pwt/retry-selector.png b/test/func/tests/screens/d90f7de/chrome-pwt/retry-selector.png deleted file mode 100644 index c74f4a81c..000000000 Binary files a/test/func/tests/screens/d90f7de/chrome-pwt/retry-selector.png and /dev/null differ diff --git a/test/func/tests/screens/d90f7de/chrome/retry-selector.png b/test/func/tests/screens/d90f7de/chrome/retry-selector.png index f12b062cf..e9cbb1c30 100644 Binary files a/test/func/tests/screens/d90f7de/chrome/retry-selector.png and b/test/func/tests/screens/d90f7de/chrome/retry-selector.png differ diff --git a/test/func/tests/screens/ff4deba/chrome-pwt/retry-selector.png b/test/func/tests/screens/ff4deba/chrome-pwt/retry-selector.png deleted file mode 100644 index d78257ad8..000000000 Binary files a/test/func/tests/screens/ff4deba/chrome-pwt/retry-selector.png and /dev/null differ diff --git a/test/func/tests/screens/ff4deba/chrome/retry-selector.png b/test/func/tests/screens/ff4deba/chrome/retry-selector.png index 9e1ce15b2..dc9d6968f 100644 Binary files a/test/func/tests/screens/ff4deba/chrome/retry-selector.png and b/test/func/tests/screens/ff4deba/chrome/retry-selector.png differ diff --git a/test/unit/lib/static/components/section/body/meta-info/content.jsx b/test/unit/lib/static/components/section/body/meta-info/content.jsx index fb501df42..0be3aef20 100644 --- a/test/unit/lib/static/components/section/body/meta-info/content.jsx +++ b/test/unit/lib/static/components/section/body/meta-info/content.jsx @@ -193,14 +193,37 @@ describe('', () => { expectedFileUrl: 'http://127.0.0.1/path/test/file' }, { - type: 'url with query params and meta value with query params', + type: 'url when baseHost is not set and metaBaseUrls is not set', metaInfo: { - file: 'test/file?a=b' + file: 'http://localhost/test/file?a=b' + }, + metaInfoBaseUrls: {}, + baseHost: 'http://example.com/', + expectedFileLabel: 'http://localhost/test/file?a=b', + expectedFileUrl: 'http://localhost/test/file?a=b' + }, + { + type: 'url when baseHost is not set and metaBaseUrls set to auto', + metaInfo: { + file: 'http://localhost/test/file?a=b' + }, + metaInfoBaseUrls: { + file: 'auto' + }, + expectedFileLabel: '/test/file?a=b', + expectedFileUrl: 'http://localhost/test/file?a=b' + }, + { + type: 'url when baseHost is set and metaBaseUrls set to auto', + metaInfo: { + file: 'http://localhost/test/file?a=b' }, metaInfoBaseUrls: { - file: 'http://127.0.0.1/?c=d&e=f' + file: 'auto' }, - expectedFileUrl: 'http://127.0.0.1/test/file?a=b&c=d&e=f' + baseHost: 'http://example.com/', + expectedFileLabel: '/test/file?a=b', + expectedFileUrl: 'http://example.com/test/file?a=b' } ].forEach((stub) => { it(`should render link in meta info based upon metaInfoBaseUrls ${stub.type}`, () => { @@ -223,11 +246,13 @@ describe('', () => { } }; const config = {metaInfoBaseUrls: stub.metaInfoBaseUrls}; - const component = mkMetaInfoContentComponent({resultId: 'some-result'}, {tree, config}); + const view = {baseHost: stub.baseHost}; + const component = mkMetaInfoContentComponent({resultId: 'some-result'}, {tree, config, view}); + const label = stub.expectedFileLabel ?? stub.metaInfo.file; expect(component.getByText('file')).to.exist; - expect(component.getByText(stub.metaInfo.file)).to.exist; - expect(component.getByText(stub.metaInfo.file).href).to.equal(stub.expectedFileUrl); + expect(component.getByText(label)).to.exist; + expect(component.getByText(label).href).to.equal(stub.expectedFileUrl); }); }); });