-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from dbreese/check_for_qas
Checks for a list of sobjects and the corresponding create/edit/view qa directories.
- Loading branch information
Showing
3 changed files
with
280 additions
and
77 deletions.
There are no files selected for viewing
183 changes: 106 additions & 77 deletions
183
resources/instructions/createSObjectLwcQuickActions.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,110 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Offline Starter Kit: Create sObject LWC Quick Actions</title> | ||
</head> | ||
<style> | ||
h1 { | ||
font-size: 16px; | ||
} | ||
h2 { | ||
font-size: 14px; | ||
} | ||
table { | ||
border-collapse: collapse; | ||
} | ||
table, | ||
th, | ||
td { | ||
border-width: 1px; | ||
border-style: solid; | ||
} | ||
th, | ||
td { | ||
text-align: center; | ||
} | ||
</style> | ||
<body> | ||
<h1>Create sObject LWC Quick Actions</h1> | ||
|
||
<p> | ||
The following sObjects are present in your configured landing page: | ||
</p> | ||
|
||
<table> | ||
<thead> | ||
<tr> | ||
<th>sObject</th> | ||
<th>LWC Quick Actions</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td>Contact</td> | ||
<td>✅</td> | ||
</tr> | ||
<tr> | ||
<td>Account</td> | ||
<td>✅</td> | ||
</tr> | ||
<tr> | ||
<td>Opportunity</td> | ||
<td>❌</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
|
||
<label | ||
style="display: block; margin-top: 10px; margin-bottom: 8px" | ||
for="generateLwcQuickActionsButton" | ||
> | ||
Click 'Generate LWC Quick Actions' to create the missing LWC Quick | ||
Actions: | ||
</label> | ||
<button id="generateLwcQuickActionsButton"> | ||
Generate LWC Quick Actions | ||
</button> | ||
<script> | ||
const generateQuickActionsButtonElement = document.getElementById( | ||
|
||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Offline Starter Kit: Create sObject LWC Quick Actions</title> | ||
</head> | ||
<style> | ||
h1 { | ||
font-size: 16px; | ||
} | ||
|
||
h2 { | ||
font-size: 14px; | ||
} | ||
|
||
table { | ||
border-collapse: collapse; | ||
} | ||
|
||
table, | ||
th, | ||
td { | ||
border-width: 1px; | ||
border-style: solid; | ||
} | ||
|
||
th, | ||
td { | ||
text-align: center; | ||
} | ||
</style> | ||
|
||
<body> | ||
<h1>Create sObject LWC Quick Actions</h1> | ||
|
||
<p> | ||
The following sObjects are present in your configured landing page: | ||
</p> | ||
|
||
<table id="quickActionStatusTable"> | ||
<thead> | ||
<tr> | ||
<th rowspan="2">sObject</th> | ||
<th colspan="3">LWC Quick Actions</th> | ||
</tr> | ||
<tr> | ||
<th>view</th> | ||
<th>edit</th> | ||
<th>create</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<!-- will be filled in programatically below --> | ||
</tbody> | ||
</table> | ||
|
||
<label style="display: block; margin-top: 10px; margin-bottom: 8px" for="generateLwcQuickActionsButton"> | ||
Click 'Generate LWC Quick Actions' to create the missing LWC Quick | ||
Actions: | ||
</label> | ||
<button id="generateLwcQuickActionsButton"> | ||
Generate LWC Quick Actions | ||
</button> | ||
<script> | ||
const generateQuickActionsButtonElement = document.getElementById( | ||
'generateLwcQuickActionsButton' | ||
); | ||
generateQuickActionsButtonElement.addEventListener('click', () => { | ||
webviewMessaging.sendMessageRequest( | ||
'generateLwcQuickActionsButton' | ||
); | ||
generateQuickActionsButtonElement.addEventListener('click', () => { | ||
webviewMessaging.sendMessageRequest( | ||
'generateLwcQuickActionsButton' | ||
); | ||
}); | ||
</script> | ||
<script src="--- MESSAGING_SCRIPT_SRC ---"></script> | ||
</body> | ||
</html> | ||
}); | ||
|
||
// Wait until all scripts are loaded, before engaging with e.g. | ||
// messaging functionality. | ||
window.addEventListener('load', () => { | ||
// What's the status of the various sobject quick actions in the landing_page.json? | ||
webviewMessaging.sendMessageRequest( | ||
'getQuickActionStatus', | ||
{}, | ||
handleQuickActionStatusResponse | ||
); | ||
|
||
}); | ||
|
||
function handleQuickActionStatusResponse(response) { | ||
const table = document.getElementById('quickActionStatusTable'); | ||
for (const sobject in response.sobjects) { | ||
const quickActions = response.sobjects[sobject]; | ||
|
||
const sobjectRow = table.insertRow(); | ||
const name = sobjectRow.insertCell(0); | ||
const view = sobjectRow.insertCell(1); | ||
const edit = sobjectRow.insertCell(2); | ||
const create = sobjectRow.insertCell(3); | ||
|
||
name.innerText = sobject; | ||
view.innerHTML = quickActions.view == true ? "✅" : "❌"; | ||
edit.innerHTML = quickActions.edit == true ? "✅" : "❌"; | ||
create.innerHTML = quickActions.create == true ? "✅" : "❌"; | ||
} | ||
} | ||
</script> | ||
|
||
<script src="--- MESSAGING_SCRIPT_SRC ---"></script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
src/test/suite/commands/wizard/lwcGenerationCommand.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* Copyright (c) 2023, salesforce.com, inc. | ||
* All rights reserved. | ||
* SPDX-License-Identifier: MIT | ||
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT | ||
*/ | ||
|
||
import * as assert from 'assert'; | ||
import * as sinon from 'sinon'; | ||
import * as fs from 'fs'; | ||
import { afterEach, beforeEach } from 'mocha'; | ||
import { | ||
LwcGenerationCommand, | ||
SObjectQuickActionStatus, | ||
QuickActionStatus | ||
} from '../../../../commands/wizard/lwcGenerationCommand'; | ||
|
||
suite('LWC Generation Command Test Suite', () => { | ||
beforeEach(function () {}); | ||
|
||
afterEach(function () { | ||
sinon.restore(); | ||
}); | ||
|
||
test('Quick Action directories check', async () => { | ||
const baseDir = 'force-app/main/default/quickActions'; | ||
const statSyncStub = sinon.stub(fs, 'statSync'); | ||
const statsStub = sinon.createStubInstance(fs.Stats); | ||
statsStub.isFile.returns(true); | ||
|
||
// stub the file system responses - any return value is a positive hit, an exception is a negative hit | ||
statSyncStub | ||
.withArgs(`${baseDir}/sobject1.view.quickAction-meta.xml`) | ||
.returns(statsStub); | ||
statSyncStub | ||
.withArgs(`${baseDir}/sobject1.edit.quickAction-meta.xml`) | ||
.returns(statsStub); | ||
statSyncStub | ||
.withArgs(`${baseDir}/sobject1.create.quickAction-meta.xml`) | ||
.returns(statsStub); | ||
|
||
statSyncStub | ||
.withArgs(`${baseDir}/sobject2.view.quickAction-meta.xml`) | ||
.throws('error'); | ||
statSyncStub | ||
.withArgs(`${baseDir}/sobject2.edit.quickAction-meta.xml`) | ||
.throws('error'); | ||
statSyncStub | ||
.withArgs(`${baseDir}/sobject2.create.quickAction-meta.xml`) | ||
.throws('error'); | ||
|
||
const result: SObjectQuickActionStatus = | ||
await LwcGenerationCommand.checkForExistingQuickActions([ | ||
'sobject1', | ||
'sobject2' | ||
]); | ||
|
||
assert.equal( | ||
result.sobjects['sobject1'].view, | ||
true, | ||
'sobject1.view should exist' | ||
); | ||
assert.equal( | ||
result.sobjects['sobject1'].edit, | ||
true, | ||
'sobject1.edit should exist' | ||
); | ||
assert.equal( | ||
result.sobjects['sobject1'].create, | ||
true, | ||
'sobject1.create should exist' | ||
); | ||
|
||
assert.equal( | ||
result.sobjects['sobject2'].view, | ||
false, | ||
'sobject2.view should NOT exist' | ||
); | ||
assert.equal( | ||
result.sobjects['sobject2'].edit, | ||
false, | ||
'sobject2.edit should NOT exist' | ||
); | ||
assert.equal( | ||
result.sobjects['sobject2'].create, | ||
false, | ||
'sobject2.create should NOT exist' | ||
); | ||
}); | ||
}); |