A plugin marketplace for GitHub Copilot and other AI agents that provides Power Platform development plugins, including reusable skills, agents, and commands for building and deploying solutions.
JavaScript claude-code-pluginclaude-code-skillscode-appsgithub-copilot-pluginpower-appspower-pagespower-platform
pcf: review follow-ups (workflow filter, contextual-grid GUIDs, lookup clear) (#729)
Akshay Malooa3b930af5012
diff --git a/.github/workflows/pcf-projects.yml b/.github/workflows/pcf-projects.ymlindex 0636f8943..4bbe714a4 100644--- a/.github/workflows/pcf-projects.yml+++ b/.github/workflows/pcf-projects.yml@@ -20,6 +20,13 @@ on:# The package smoke starts pac through these two, so a change to either must run it.- "plugins/pcf/scripts/lib/pac-exec.js"- "plugins/pcf/scripts/lib/process-runner.js"+ # pcf-ci-build.js and the gates it starts also load these, copies of model-apps helpers among+ # them; pcf-projects-workflow.test.js fails if a file it loads is missing here.+ - "plugins/pcf/scripts/lib/cli-failure.js"+ - "plugins/pcf/scripts/lib/dataverse-auth.js"+ - "plugins/pcf/scripts/lib/nearest-name.js"+ - "plugins/pcf/scripts/lib/source-literals.js"+ - "plugins/pcf/scripts/lib/xml-lite.js"- ".github/workflows/pcf-projects.yml"permissions:diff --git a/.github/workflows/pcf-script-tests.yml b/.github/workflows/pcf-script-tests.ymlindex 58c4a388a..bfd7aa6c4 100644--- a/.github/workflows/pcf-script-tests.yml+++ b/.github/workflows/pcf-script-tests.yml@@ -30,6 +30,9 @@ on:- "plugins/model-apps/scripts/vendor/PROVENANCE.json"- "plugins/model-apps/scripts/vendor/.gitattributes"- ".github/workflows/pcf-script-tests.yml"+ # These suites also check the other PCF workflows (path filters, telemetry opt-outs).+ - ".github/workflows/pcf-projects.yml"+ - ".github/workflows/pcf-matrix-drift.yml"permissions:contents: readdiff --git a/plugins/pcf/recipes/contextual-grid/__tests__/{{name}}.test.ts.tmpl b/plugins/pcf/recipes/contextual-grid/__tests__/{{name}}.test.ts.tmplindex 765e9348c..bc89da12f 100644--- a/plugins/pcf/recipes/contextual-grid/__tests__/{{name}}.test.ts.tmpl+++ b/plugins/pcf/recipes/contextual-grid/__tests__/{{name}}.test.ts.tmpl@@ -131,6 +131,16 @@ test("malformed GUID braces render the invalid-record state without querying", aexpect(mounted.status().textContent).toContain("not a valid GUID");expect(mounted.retrieveMultipleRecords).not.toHaveBeenCalled();});++test("record ids without RFC 4122 version bits still load, as Dataverse ids may", async () => {+ const mounted = mount({ entityId: mockProperty("{00000000-0000-0000-C000-000000000046}") as IInputs["entityId"] });++ await flushPromises();++ expect(mounted.retrieveMultipleRecords).toHaveBeenCalledTimes(1);+ expect(mounted.retrieveMultipleRecords.mock.calls[0][1]).toContain(encodeURIComponent("00000000-0000-0000-c000-000000000046"));+ expect(mounted.rows()).toHaveLength(1);+});test("Web API permission failures and empty results render messages without notifying", async () => {const failed = mount({webAPI: mockWebApi({ retrieveMultipleRecords: jest.fn(async (_entityLogicalName: string, _options?: string, _maxPageSize?: number) => { throw new Error("Access denied"); }) }),diff --git a/plugins/pcf/recipes/contextual-grid/{{name}}/fetchXmlData.ts.tmpl b/plugins/pcf/recipes/contextual-grid/{{name}}/fetchXmlData.ts.tmplindex 4b90805e5..f0dab5bb8 100644--- a/plugins/pcf/recipes/contextual-grid/{{name}}/fetchXmlData.ts.tmpl+++ b/plugins/pcf/recipes/contextual-grid/{{name}}/fetchXmlData.ts.tmpl@@ -16,7 +16,10 @@ export interface GridRequest {}const RECORD_ID_TOKEN = "{recordId}";-const GUID_RE = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/;+// Dataverse record ids are uniqueidentifier (Edm.Guid) values: any 8-4-4-4-12 hexadecimal value.+// They need not carry RFC 4122 version or variant bits, so sequential and imported ids such as+// 00000000-0000-0000-c000-000000000046 are valid and must load.+const GUID_RE = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;const ENTITY_NAME_RE = /<entity\s+[^>]*name\s*=\s*(["'])([^"']+)\1/i;export async function loadGridPage(diff --git a/plugins/pcf/recipes/contextual-grid/{{name}}/index.ts.tmpl b/plugins/pcf/recipes/contextual-grid/{{name}}/index.ts.tmplindex c8d14b1bb..06f707fd6 100644--- a/plugins/pcf/recipes/contextual-grid/{{name}}/index.ts.tmpl+++ b/plugins/pcf/recipes/contextual-grid/{{name}}/index.ts.tmpl@@ -332,5 +332,6 @@ function isAliasedResultKey(key: string): boolean {function isGuidLike(value: unknown): boolean {if (typeof value !== "string") return false;- return /^\{?[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}\}?$/.test(value.trim());+ // Any 8-4-4-4-12 hexadecimal value, as Dataverse ids are (no RFC 4122 version or variant bits).+ return /^\{?[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\}?$/.test(value.trim());}diff --git a/plugins/pcf/recipes/lookup-dropdown/README.md b/plugins/pcf/recipes/lookup-dropdown/README.mdindex f9907931c..cf000f1ad 100644--- a/plugins/pcf/recipes/lookup-dropdown/README.md+++ b/plugins/pcf/recipes/lookup-dropdown/README.md@@ -31,7 +31,7 @@ bound lookup without relying on undocumented lookup-property methods.- Loads target rows with `context.webAPI.retrieveMultipleRecords` using explicit `$select`, theoptional configured `selectableFilter`, page size, and `nextLink` paging.- Keeps an already-selected inactive record visible so users can see and clear the existing value.-- Returns `LookupValue[]` from `getOutputs()` when selected, or `undefined` to clear the lookup.+- Returns `LookupValue[]` from `getOutputs()` when selected, or an empty array `[]` to clear the lookup (`undefined` would leave the previous value in place).- Does not notify the host when the selected value is unchanged.- Shows disabled, unreadable, non-editable, loading and permission-failure states.- Works on unsaved forms because it never reads a current record id.diff --git a/plugins/pcf/recipes/lookup-dropdown/__tests__/{{name}}.test.ts.tmpl b/plugins/pcf/recipes/lookup-dropdown/__tests__/{{name}}.test.ts.tmplindex 7411f0d31..5a79a0deb 100644--- a/plugins/pcf/recipes/lookup-dropdown/__tests__/{{name}}.test.ts.tmpl+++ b/plugins/pcf/recipes/lookup-dropdown/__tests__/{{name}}.test.ts.tmpl@@ -327,7 +327,7 @@ test("unchanged updateView keeps the capped lookup warning without restarting thexpect(mounted.status().textContent).toContain("More rows exist");});-test("clearing the dropdown returns undefined and unchanged values do not notify", async () => {+test("clearing the dropdown returns an empty lookup array and unchanged values do not notify", async () => {const mounted = mount(lookupProperty([{ id: "11111111-1111-4111-8111-111111111111", name: "Alpha", entityType: "account" },]));@@ -339,7 +339,7 @@ test("clearing the dropdown returns undefined and unchanged values do not notifymounted.select().dispatchEvent(new Event("change"));expect(mounted.notify).toHaveBeenCalledTimes(1);- expect(mounted.control.getOutputs()).toEqual({ lookupValue: undefined });+ expect(mounted.control.getOutputs()).toEqual({ lookupValue: [] });});test("selected inactive records stay displayed even when the active query excludes them", async () => {@@ -415,5 +415,5 @@ test("two instances keep independent state and notifications", async () => {expect(first.control.getOutputs()).toEqual({lookupValue: [{ id: "11111111-1111-4111-8111-111111111111", name: "Active account", entityType: "account" }],});- expect(second.control.getOutputs()).toEqual({ lookupValue: undefined });+ expect(second.control.getOutputs()).toEqual({ lookupValue: [] });});diff --git a/plugins/pcf/recipes/lookup-dropdown/{{name}}/index.ts.tmpl b/plugins/pcf/recipes/lookup-dropdown/{{name}}/index.ts.tmplindex 7696a8b8d..a62d6a574 100644--- a/plugins/pcf/recipes/lookup-dropdown/{{name}}/index.ts.tmpl+++ b/plugins/pcf/recipes/lookup-dropdown/{{name}}/index.ts.tmpl@@ -159,8 +159,11 @@ export class {{name}} implements ComponentFramework.StandardControl<IInputs, IOu}public getOutputs(): IOutputs {+ // An empty array clears the bound lookup. `undefined` reads as "no new value", which can leave+ // the previous record in place, so the "(Clear lookup)" choice must send [].+ // See the Learn lookup component sample: https://learn.microsoft.com/power-apps/developer/component-framework/sample-controls/lookup-controlreturn {- lookupValue: this.selected ? [this.selected] : undefined,+ lookupValue: this.selected ? [this.selected] : [],};}diff --git a/plugins/pcf/references/pcf-testing.md b/plugins/pcf/references/pcf-testing.mdindex 7a6fbfe64..58df8bfb2 100644--- a/plugins/pcf/references/pcf-testing.md+++ b/plugins/pcf/references/pcf-testing.md@@ -28,7 +28,7 @@ Unit tests cover pure rendering, parsing, adapters and state transitions without- Test missing parameter objects, `security.readable=false`, `security.editable=false`, null values and permission failures.- Test two instances on one page: no shared singleton state or duplicate ids.- Test current-record recipes with missing `entityId` as an unsaved-record disabled state.-- For lookup outputs, assert the `LookupValue[]` shape or `undefined` clear value expected by the recipe contract.+- For lookup outputs, assert the `LookupValue[]` shape, and an empty array `[]` as the clear value: `undefined` reads as no new value and can leave the previous lookup in place.- For grid customizers, assert renderers return elements or `null`/`undefined`, and never mutate grid data.### Harness testsdiff --git a/plugins/pcf/scripts/tests/pcf-projects-workflow.test.js b/plugins/pcf/scripts/tests/pcf-projects-workflow.test.jsnew file mode 100644index 000000000..d97d17b5a--- /dev/null+++ b/plugins/pcf/scripts/tests/pcf-projects-workflow.test.js@@ -0,0 +1,74 @@+'use strict';++// The generated-project workflow is path-filtered. Its build entry point, pcf-ci-build.js, loads+// other plugin files at run time (copied model-apps helpers among them), so a change to any of them+// can change scaffolding, gating or packaging. Every file in that require closure must trigger the+// workflow, or a PR touching only that file merges without the template and recipe builds.++const test = require('node:test');+const assert = require('node:assert/strict');+const fs = require('node:fs');+const path = require('node:path');++const REPO_ROOT = path.resolve(__dirname, '..', '..', '..', '..');+const WORKFLOW = path.join(REPO_ROOT, '.github', 'workflows', 'pcf-projects.yml');+const ENTRY = path.join(REPO_ROOT, 'plugins', 'pcf', 'scripts', 'pcf-ci-build.js');++function requireClosure(entry) {+ const pluginRoot = path.join(REPO_ROOT, 'plugins', 'pcf');+ const seen = new Set();+ const visit = (file) => {+ if (seen.has(file)) return;+ seen.add(file);+ // Relative requires only, as these scripts write them:+ // require('./lib/pcf-build.js') require('../vendor/cds-maker-sdk.cjs') require('./xml-lite')+ for (const match of fs.readFileSync(file, 'utf8').matchAll(/require\(\s*['"](\.{1,2}\/[^'"]+)['"]\s*\)/g)) {+ const base = path.resolve(path.dirname(file), match[1]);+ const target = [base, `${base}.js`, `${base}.cjs`].find((candidate) => fs.existsSync(candidate) && fs.statSync(candidate).isFile());+ if (target && target.startsWith(pluginRoot + path.sep)) visit(target);+ }+ // Sibling scripts started as child processes count too, e.g. the gates:+ // runNodeScript(path.join(SCRIPT_DIR, 'pcf-gates.js'), [...])+ for (const match of fs.readFileSync(file, 'utf8').matchAll(/path\.join\(\s*SCRIPT_DIR\s*,\s*['"]([\w.-]+\.js)['"]\s*\)/g)) {+ const target = path.join(path.dirname(file), match[1]);+ if (fs.existsSync(target)) visit(target);+ }+ };+ visit(entry);+ return [...seen].map((file) => path.relative(REPO_ROOT, file).split(path.sep).join('/')).sort();+}++function pullRequestPathGlobs(workflowText) {+ // The pull_request `paths:` list, as the workflow writes it:+ // pull_request:+ // branches:+ // - main+ // paths:+ // - "plugins/pcf/scripts/pcf-*.js"+ // # a comment line+ const lines = workflowText.split(/\r?\n/);+ const start = lines.findIndex((line, i) => /^\s+paths:\s*$/.test(line) && lines.slice(0, i).some((l) => /^\s+pull_request:\s*$/.test(l)));+ assert.notEqual(start, -1, 'pcf-projects.yml must filter pull requests by path');+ const globs = [];+ for (const line of lines.slice(start + 1)) {+ const item = /^\s+-\s+"?([^"\s]+)"?\s*$/.exec(line);+ if (item) globs.push(item[1]);+ else if (!/^\s*(#.*)?$/.test(line)) break;+ }+ return globs;+}++function globToRegExp(glob) {+ // GitHub path filters: `**` crosses folders, `*` stays within one.+ const source = glob.split('**').map((part) => part.split('*').map((s) => s.replace(/[.+?^${}()|[\]\\]/g, '\\$&')).join('[^/]*')).join('.*');+ return new RegExp(`^${source}$`);+}++test('pcf-projects runs for every file pcf-ci-build.js loads or starts', () => {+ const patterns = pullRequestPathGlobs(fs.readFileSync(WORKFLOW, 'utf8')).map(globToRegExp);+ const closure = requireClosure(ENTRY);+ assert.ok(closure.includes('plugins/pcf/scripts/pcf-gates.js'), 'the closure must follow the gates child process');+ assert.ok(closure.length > 5, `unexpectedly small require closure: ${closure.join(', ')}`);+ const missing = closure.filter((file) => !patterns.some((pattern) => pattern.test(file)));+ assert.deepEqual(missing, [], `add these to the pull_request paths of pcf-projects.yml: ${missing.join(', ')}`);+});diff --git a/plugins/pcf/scripts/tests/pcf-skill-docs.test.js b/plugins/pcf/scripts/tests/pcf-skill-docs.test.jsindex acc0c28ad..9012a6bee 100644--- a/plugins/pcf/scripts/tests/pcf-skill-docs.test.js+++ b/plugins/pcf/scripts/tests/pcf-skill-docs.test.js@@ -806,3 +806,12 @@ test('Microsoft Learn links in PCF references use the en-us canonical prefix', (}}});++test('lookup testing guidance clears with an empty array, matching the lookup-dropdown recipe', () => {+ // undefined from getOutputs reads as "no new value"; the recipe clears a lookup with [].+ const testing = readPluginFile('references/pcf-testing.md');+ const lookupLine = testing.split('\n').find((line) => /lookup outputs/i.test(line));+ assert.ok(lookupLine, 'pcf-testing.md must give lookup output guidance');+ assert.match(lookupLine, /empty array `\[\]`/);+ assert.doesNotMatch(lookupLine, /or `undefined` clear value/);+});diff --git a/plugins/pcf/scripts/tests/telemetry-ci.test.js b/plugins/pcf/scripts/tests/telemetry-ci.test.jsindex 1d71311e3..c420fca86 100644--- a/plugins/pcf/scripts/tests/telemetry-ci.test.js+++ b/plugins/pcf/scripts/tests/telemetry-ci.test.js@@ -73,7 +73,7 @@ test('PCF script CI watches every bundled telemetry source without widening unreconst text = workflow(t, 'pcf-script-tests.yml');if (text === null) return;const globs = [];- for (const line of text.slice(text.indexOf('paths:')).split('\n').slice(1)) {+ for (const line of text.slice(text.indexOf('paths:')).split(/\r?\n/).slice(1)) {const entry = /^\s+-\s+"([^"]+)"\s*$/.exec(line);if (entry) { globs.push(entry[1]); continue; }if (/^\s*(?:#.*)?$/.test(line)) continue;@@ -89,8 +89,13 @@ test('PCF script CI watches every bundled telemetry source without widening unre.filter((source) => source.startsWith('plugins/model-apps/')));for (const glob of globs) {assert.ok(glob.startsWith('plugins/pcf/') || glob.startsWith('evals/pcf/')- || glob === '.github/workflows/pcf-script-tests.yml' || glob === 'scripts/validate-plugin-copies.js'+ || /^\.github\/workflows\/pcf-[\w-]+\.yml$/.test(glob) || glob === 'scripts/validate-plugin-copies.js'|| SHARED_SOURCES.has(glob) || modelSources.has(glob), `unrelated CI filter: ${glob}`);}for (const source of modelSources) assert.ok(globs.includes(source), `existing copied source must remain watched: ${source}`);+ // PCF's script tests also check its other workflows (path filters, telemetry opt-outs), so a change+ // to one of those alone must still run them.+ for (const name of ['pcf-script-tests.yml', 'pcf-projects.yml', 'pcf-matrix-drift.yml']) {+ assert.ok(globs.includes(`.github/workflows/${name}`), `.github/workflows/${name} must trigger the PCF script tests that check it`);+ }});