From 16637c2a4622e5e1c1ce50e210ac2a88dd0386eb Mon Sep 17 00:00:00 2001 From: simbiozizv Date: Wed, 9 Oct 2024 14:04:26 +0300 Subject: [PATCH] feat(System): new regexp shortname [YTFRONT-4386] --- .../src/server/configs/common.ts | 2 +- packages/ui/src/server/configs/e2e/local.ts | 2 +- packages/ui/src/shared/ui-settings.ts | 6 +++--- .../system/helpers/makeShortSystemAddress.ts | 6 ++---- packages/ui/tests/e2e/pages/system.spec.ts | 20 +++++++++++++++++++ 5 files changed, 27 insertions(+), 9 deletions(-) create mode 100644 packages/ui/tests/e2e/pages/system.spec.ts diff --git a/packages/custom-ytsaurus-ui.example/src/server/configs/common.ts b/packages/custom-ytsaurus-ui.example/src/server/configs/common.ts index 647a22078..7bbfe8e28 100644 --- a/packages/custom-ytsaurus-ui.example/src/server/configs/common.ts +++ b/packages/custom-ytsaurus-ui.example/src/server/configs/common.ts @@ -21,7 +21,7 @@ const cfg: Partial = { reHashFromNodeVersion: '[^~]+~(?[^+]+)', reShortNameFromAddress: '(?.*)(\\.[^.]+)(\\.yt\\.my\\.domain)', - reShortNameFromSystemAddress: '(?.*)(\\.[^.]+)(\\.yt\\.my\\.domain)', + reShortNameSystemPage: '(?.*)(\\.[^.]+)(\\.yt\\.my\\.domain)', reShortNameFromTabletNodeAddress: '(?[^-]+-[^-]+).*', reUnipikaAllowTaggedSources: [ diff --git a/packages/ui/src/server/configs/e2e/local.ts b/packages/ui/src/server/configs/e2e/local.ts index 5912604d1..80902d69e 100644 --- a/packages/ui/src/server/configs/e2e/local.ts +++ b/packages/ui/src/server/configs/e2e/local.ts @@ -40,7 +40,7 @@ const e2eConfig: Partial = { }, reShortNameFromAddress: '(?^(loca)).*(?:\\d\\d\\d)', - reShortNameFromSystemAddress: '(?^(loca)).*(?:\\d\\d\\d)', + reShortNameSystemPage: '(?^(local))', reShortNameFromTabletNodeAddress: '(?^(local))[^:]+(?:\\d\\d)', reUnipikaAllowTaggedSources: ['^https://yastatic\\.net/'], diff --git a/packages/ui/src/shared/ui-settings.ts b/packages/ui/src/shared/ui-settings.ts index 87bfb36d1..da57ee908 100644 --- a/packages/ui/src/shared/ui-settings.ts +++ b/packages/ui/src/shared/ui-settings.ts @@ -136,10 +136,10 @@ export interface UISettings { reShortNameFromTabletNodeAddress?: string; /** - * Allows you to override the behavior of 'reShortNameFromSystemAddress ` for masters / providers / schedulers / agents. - * @example reShortNameFromSystemAddress: '(?.*)((\\.msk\\.my-domain\\.ru)|(\\.vla\\.my-domain\\.net))' + * Allows you to override the behavior of 'reShortNameSystemPage ` for masters / providers / schedulers / agents. + * @example reShortNameSystemPage: '(?.*)((\\.msk\\.my-domain\\.ru)|(\\.vla\\.my-domain\\.net))' */ - reShortNameFromSystemAddress?: string; + reShortNameSystemPage?: string; /** * Allows to define array of regexps for allowed urls of TaggedType of unipika to display media-content (audio/video/images). diff --git a/packages/ui/src/ui/pages/system/helpers/makeShortSystemAddress.ts b/packages/ui/src/ui/pages/system/helpers/makeShortSystemAddress.ts index 618032810..af4f088f8 100644 --- a/packages/ui/src/ui/pages/system/helpers/makeShortSystemAddress.ts +++ b/packages/ui/src/ui/pages/system/helpers/makeShortSystemAddress.ts @@ -1,11 +1,9 @@ import {makeRegexpFromSettings} from '../../../../shared/utils'; import {uiSettings} from '../../../config/ui-settings'; -const reShortNameFromSystemAddress = makeRegexpFromSettings( - uiSettings.reShortNameFromSystemAddress, -); +const reShortNameSystemPage = makeRegexpFromSettings(uiSettings.reShortNameSystemPage); export const makeShortSystemAddress = (address: string): string | undefined => { - const res = reShortNameFromSystemAddress?.exec(address); + const res = reShortNameSystemPage?.exec(address); return res?.groups?.shortname; }; diff --git a/packages/ui/tests/e2e/pages/system.spec.ts b/packages/ui/tests/e2e/pages/system.spec.ts new file mode 100644 index 000000000..a3bc7ffe4 --- /dev/null +++ b/packages/ui/tests/e2e/pages/system.spec.ts @@ -0,0 +1,20 @@ +import {expect, test} from '@playwright/test'; +import {makeClusterUrl} from '../../utils'; + +test('System: check short name', async ({page}) => { + const url = makeClusterUrl(`system/general`); + await page.goto(url); + + await page.waitForSelector('.system'); + await page.evaluate(() => { + const allMastersContainer = document.querySelector('.system-master__all-masters'); + if (!allMastersContainer) { + const button = document.querySelector('.collapsible-section__title'); + if (button) button.click(); + } + }); + + const mastersNameElements = await page.$$('.master-group__host-name'); + const firstMasterName = await mastersNameElements[0].innerText(); + expect(firstMasterName).toEqual('local'); +});