Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
<flexiPageRegions>
<itemInstances>
<componentInstance>
<componentInstanceProperties>
<name>agentFileContent</name>
</componentInstanceProperties>
<componentName>agentScriptWrapper</componentName>
<identifier>c_agentScriptWrapper</identifier>
</componentInstance>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ describe("c-agent-script-wrapper", () => {
});
});

it("displays empty state when no agents provided", () => {
// Arrange
it("falls back to demo agents when empty content is provided", () => {
// Arrange — App Builder often passes "" / []; demos must still render
const element = createElement("c-agent-script-wrapper", {
is: AgentScriptWrapper
});
Expand All @@ -144,9 +144,10 @@ describe("c-agent-script-wrapper", () => {

return Promise.resolve().then(() => {
// Assert
const tiles = element.shadowRoot.querySelectorAll(".agent-tile");
expect(tiles.length).toBe(2);
const emptyState = element.shadowRoot.querySelector(".empty-state");
expect(emptyState).not.toBeNull();
expect(emptyState.textContent).toContain("No agent scripts available");
expect(emptyState).toBeNull();
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ <h3 class="tile-title">{tile.title}</h3>
</div>
<template if:true={tile.isExpanded}>
<div class="tile-content">
<c-agentscript-viewer content={tile.content} theme="light">
<!-- Actions slot is not used in this example -->
<c-agentscript-viewer
agent-file-content={tile.content}
theme="light"
>
</c-agentscript-viewer>
</div>
</template>
Expand Down
1,374 changes: 22 additions & 1,352 deletions examples/main/default/lwc/agentScriptWrapper/agentScriptWrapper.js

Large diffs are not rendered by default.

1,348 changes: 1,348 additions & 0 deletions examples/main/default/lwc/agentScriptWrapper/demoAgents.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<PermissionSet xmlns="http://soap.sforce.com/2006/04/metadata">
<description>Makes the Create Agents Lightning tab visible (AgentScript viewer/wrapper gallery).</description>
<hasActivationRequired>false</hasActivationRequired>
<label>Create Agents Tab</label>
<tabSettings>
<tab>Create_Agents</tab>
<visibility>Visible</visibility>
</tabSettings>
</PermissionSet>
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,25 @@ describe("c-agentscript-viewer", () => {

expect(writeTextMock).toHaveBeenCalledWith(SAMPLE_CONTENT);
});

it("falls back to execCommand when clipboard API is missing", async () => {
const execMock = jest.fn(() => true);
Object.assign(navigator, { clipboard: undefined });
document.execCommand = execMock;

const element = createComponent({ content: SAMPLE_CONTENT });
await flushPromises();

const copyButton = element.shadowRoot.querySelector(
"lightning-button[title='Copy']"
);
copyButton.click();
await flushPromises();

expect(execMock).toHaveBeenCalledWith("copy");
const helper = element.shadowRoot.querySelector("textarea.copy-helper");
expect(helper).not.toBeNull();
});
});

describe("content updates", () => {
Expand Down
16 changes: 16 additions & 0 deletions force-app/main/default/lwc/agentscriptViewer/agentscriptViewer.css
Original file line number Diff line number Diff line change
Expand Up @@ -292,3 +292,19 @@
.code-container::-webkit-scrollbar-track {
background-color: transparent;
}

/* Off-screen helper used by the execCommand copy fallback (LWS-safe). */
.copy-helper {
position: fixed;
top: 0;
left: 0;
width: 1px;
height: 1px;
padding: 0;
margin: 0;
border: none;
outline: none;
box-shadow: none;
opacity: 0;
pointer-events: none;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<template>
<div class={containerClass}>
<textarea
class="copy-helper"
aria-hidden="true"
tabindex="-1"
readonly
lwc:ref="copyHelper"
></textarea>
<template lwc:if={hasContent}>
<div class="toolbar">
<div class="toolbar-left">
Expand Down Expand Up @@ -45,7 +52,7 @@
</template>
<template lwc:else>
<div class="empty-state">
<p>No .agent file content to display.</p>
<p>{emptyStateMessage}</p>
</div>
</template>
</div>
Expand Down
Loading