Blame Raw
· · · 50 lines (1.9 KB)
0 contributors
1import { test, expect } from '@playwright/test';
2import { testSetup } from './frontent-test-utils.js';
3
4// Tests for the deprecated MacrosParser shim to ensure it continues to work
5// both with the legacy regex macro system (feature flag disabled) and with
6// the new macro engine (feature flag enabled).
7
8test.describe('MacrosParser (legacy shim)', () => {
9 test.beforeEach(testSetup.awaitST);
10
11 test('should resolve macros via legacy evaluateMacros when experimental engine is disabled', async ({ page }) => {
12 const output = await page.evaluate(async () => {
13 const { MacrosParser, evaluateMacros } = await import('./scripts/macros.js');
14 const { power_user } = await import('./scripts/power-user.js');
15
16 power_user.experimental_macro_engine = false;
17
18 MacrosParser.registerMacro('legacyParserTest', 'LEGACY_OK', 'Legacy parser test');
19
20 const env = {};
21 const result = evaluateMacros('Value: {{legacyParserTest}}.', env, (x) => x);
22
23 MacrosParser.unregisterMacro('legacyParserTest');
24
25 return result;
26 });
27
28 expect(output).toBe('Value: LEGACY_OK.');
29 });
30
31 test('should resolve macros via new engine when experimental engine is enabled', async ({ page }) => {
32 const output = await page.evaluate(async () => {
33 const { MacrosParser } = await import('./scripts/macros.js');
34 const { substituteParams } = await import('./script.js');
35 const { power_user } = await import('./scripts/power-user.js');
36
37 power_user.experimental_macro_engine = true;
38
39 MacrosParser.registerMacro('engineParserTest', 'ENGINE_OK', 'Engine parser test');
40
41 const result = substituteParams('Value: {{engineParserTest}}.', {});
42
43 MacrosParser.unregisterMacro('engineParserTest');
44
45 return result;
46 });
47
48 expect(output).toBe('Value: ENGINE_OK.');
49 });
50});