Skip to content

Commit

Permalink
feat(System): new regexp shortname [YTFRONT-4386]
Browse files Browse the repository at this point in the history
  • Loading branch information
SimbiozizV committed Oct 15, 2024
1 parent c0445f3 commit 16637c2
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const cfg: Partial<CustomAppConfig> = {
reHashFromNodeVersion: '[^~]+~(?<hash>[^+]+)',

reShortNameFromAddress: '(?<shortname>.*)(\\.[^.]+)(\\.yt\\.my\\.domain)',
reShortNameFromSystemAddress: '(?<shortname>.*)(\\.[^.]+)(\\.yt\\.my\\.domain)',
reShortNameSystemPage: '(?<shortname>.*)(\\.[^.]+)(\\.yt\\.my\\.domain)',
reShortNameFromTabletNodeAddress: '(?<shortname>[^-]+-[^-]+).*',

reUnipikaAllowTaggedSources: [
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/server/configs/e2e/local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const e2eConfig: Partial<AppConfig> = {
},

reShortNameFromAddress: '(?<shortname>^(loca)).*(?<suffix>:\\d\\d\\d)',
reShortNameFromSystemAddress: '(?<shortname>^(loca)).*(?<suffix>:\\d\\d\\d)',
reShortNameSystemPage: '(?<shortname>^(local))',
reShortNameFromTabletNodeAddress: '(?<shortname>^(local))[^:]+(?<suffix>:\\d\\d)',

reUnipikaAllowTaggedSources: ['^https://yastatic\\.net/'],
Expand Down
6 changes: 3 additions & 3 deletions packages/ui/src/shared/ui-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ export interface UISettings {
reShortNameFromTabletNodeAddress?: string;

/**
* Allows you to override the behavior of 'reShortNameFromSystemAddress ` for masters / providers / schedulers / agents.
* @example reShortNameFromSystemAddress: '(?<shortname>.*)((\\.msk\\.my-domain\\.ru)|(\\.vla\\.my-domain\\.net))'
* Allows you to override the behavior of 'reShortNameSystemPage ` for masters / providers / schedulers / agents.
* @example reShortNameSystemPage: '(?<shortname>.*)((\\.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).
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
};
20 changes: 20 additions & 0 deletions packages/ui/tests/e2e/pages/system.spec.ts
Original file line number Diff line number Diff line change
@@ -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<HTMLSpanElement>('.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');
});

0 comments on commit 16637c2

Please sign in to comment.