IDEMSInternational / open-app-builder

PLH App Frontend
GNU General Public License v3.0
5 stars 24 forks source link

Fix/string evaluation js #2146

Closed chrismclarke closed 9 months ago

chrismclarke commented 10 months ago

PR Checklist

TODO

Description

Fix issue where dynamic string replacements do not support further JS evaluation (e.g. @fields.name.startsWith("A"))

Review Notes

See updated test cases now passing

 it("supports JS evaluation on replaced string values", async () => {
    await service.set("field", "test_value", "hello");
    const evaluated = await service.evaluateExpression("@field.test_value.startsWith('h')");
    expect(evaluated).toEqual(true);
  });
  it("evaluates expressions with string value", async () => {
    await service.set("field", "test_value", "hello");
    const evaluated = await service.evaluateExpression("@field.test_value === 'hello'");
    expect(evaluated).toEqual(true);
  });

Author Notes

It was previously suggested that manual string delimeters could be used as a workaround, e.g. "@field.test_value".startsWith('h').

This should still work (non-breaking change), but no longer be necessary. I'm not sure if we have any example templates that include this behaviour that can also be checked as part of this PR

Git Issues

Closes #2141

Screenshots/Videos

If useful, provide screenshot or capture to highlight main changes