|
| 1 | +component extends="wheels.WheelsTest" { |
| 2 | + |
| 3 | + function run() { |
| 4 | + |
| 5 | + g = application.wo |
| 6 | + |
| 7 | + describe("Tests that $resolveSubpathInclude (issue 3251)", () => { |
| 8 | + |
| 9 | + // The app test-runner template ships |
| 10 | + // `<cfinclude template="/wheels/tests/app-runner.cfm">`. The leading |
| 11 | + // `/wheels` resolves only when the app is mounted at the web root. |
| 12 | + // Under a CommandBox multi-subfolder / IIS-subfolder topology the |
| 13 | + // mapping does not resolve, so the include fails. $resolveSubpathInclude |
| 14 | + // rewrites a framework-relative include path against the resolved |
| 15 | + // `webPath` (the same subpath derivation as $resolveFrameworkPaths) so |
| 16 | + // the include works in both root and subfolder installs. |
| 17 | + |
| 18 | + it("returns the absolute path unchanged for a root install (webPath '/')", () => { |
| 19 | + expect( |
| 20 | + g.$resolveSubpathInclude( |
| 21 | + template = "/wheels/tests/app-runner.cfm", |
| 22 | + webPath = "/" |
| 23 | + ) |
| 24 | + ).toBe("/wheels/tests/app-runner.cfm") |
| 25 | + }) |
| 26 | + |
| 27 | + it("prefixes the subpath for a subfolder install", () => { |
| 28 | + expect( |
| 29 | + g.$resolveSubpathInclude( |
| 30 | + template = "/wheels/tests/app-runner.cfm", |
| 31 | + webPath = "/wheelsproject1/" |
| 32 | + ) |
| 33 | + ).toBe("/wheelsproject1/wheels/tests/app-runner.cfm") |
| 34 | + }) |
| 35 | + |
| 36 | + it("handles a nested subpath", () => { |
| 37 | + expect( |
| 38 | + g.$resolveSubpathInclude( |
| 39 | + template = "/wheels/tests/app-runner.cfm", |
| 40 | + webPath = "/team/site/" |
| 41 | + ) |
| 42 | + ).toBe("/team/site/wheels/tests/app-runner.cfm") |
| 43 | + }) |
| 44 | + |
| 45 | + it("normalizes a webPath missing its trailing slash", () => { |
| 46 | + expect( |
| 47 | + g.$resolveSubpathInclude( |
| 48 | + template = "/wheels/tests/app-runner.cfm", |
| 49 | + webPath = "/wheelsproject1" |
| 50 | + ) |
| 51 | + ).toBe("/wheelsproject1/wheels/tests/app-runner.cfm") |
| 52 | + }) |
| 53 | + |
| 54 | + it("falls back to '/' when webPath is empty", () => { |
| 55 | + expect( |
| 56 | + g.$resolveSubpathInclude( |
| 57 | + template = "/wheels/tests/app-runner.cfm", |
| 58 | + webPath = "" |
| 59 | + ) |
| 60 | + ).toBe("/wheels/tests/app-runner.cfm") |
| 61 | + }) |
| 62 | + |
| 63 | + it("tolerates a template that omits its leading slash", () => { |
| 64 | + expect( |
| 65 | + g.$resolveSubpathInclude( |
| 66 | + template = "wheels/tests/app-runner.cfm", |
| 67 | + webPath = "/wheelsproject1/" |
| 68 | + ) |
| 69 | + ).toBe("/wheelsproject1/wheels/tests/app-runner.cfm") |
| 70 | + }) |
| 71 | + |
| 72 | + it("uses application.wheels.webPath when no webPath argument is passed (the production call shape)", () => { |
| 73 | + // The shipped runner template (cli/lucli/templates/app/tests/runner.cfm) |
| 74 | + // calls this with NO webPath argument, so the fallback branch that reads |
| 75 | + // application.wheels.webPath is the only path real callers take. Pin it by |
| 76 | + // asserting the no-arg result equals an explicit call passing the current |
| 77 | + // webPath — this exercises the previously-uncovered branch without mutating |
| 78 | + // global app state. |
| 79 | + expect( |
| 80 | + g.$resolveSubpathInclude(template = "/wheels/tests/app-runner.cfm") |
| 81 | + ).toBe( |
| 82 | + g.$resolveSubpathInclude(template = "/wheels/tests/app-runner.cfm", webPath = application.wheels.webPath) |
| 83 | + ) |
| 84 | + }) |
| 85 | + |
| 86 | + }) |
| 87 | + } |
| 88 | +} |
0 commit comments