Skip to content

Commit 9ee3115

Browse files
feat: call to action link validation
1 parent 788e3b6 commit 9ee3115

File tree

3 files changed

+87
-0
lines changed

3 files changed

+87
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"jsdom": "^25.0.0",
1919
"lodash.chunk": "^4.2.0",
2020
"open": "^8.4.2",
21+
"puppeteer": "^24.12.1",
2122
"shelljs": "^0.8.5",
2223
"tslib": "^2",
2324
"xmldom": "^0.6.0"

src/utils/constants/documentRegistry.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,5 @@ export const documentRegistry = {
5656
integrationProcedureManualUpdateMessage:
5757
'https://help.salesforce.com/s/articleView?id=xcloud.os_migrate_update_references_to_integration_procedures_after_migration.htm&type=5',
5858
duplicateCardNameMessage: 'https://help.salesforce.com/s/articleView?id=xcloud.os_clone_a_flexcard.htm&type=5',
59+
testURL: 'https://help.salesforce.com/s/articleView?id=xcloud.os_omnistudio_naming_con.htm&type=5',
5960
};
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import puppeteer from 'puppeteer';
2+
import { expect } from '@salesforce/command/lib/test';
3+
import { documentRegistry } from '../../../src/utils/constants/documentRegistry';
4+
import { Logger } from '../../../src/utils/logger';
5+
6+
describe('DocumentRegistry', () => {
7+
describe('URL Validation', () => {
8+
// Helper function to make HTTP request and check if URL is accessible
9+
async function checkSalesforceUrlWithPuppeteer(url: string): Promise<boolean> {
10+
const browser = await puppeteer.launch({ headless: true }); // use true instead of 'new'
11+
const page = await browser.newPage();
12+
try {
13+
await page.goto(url, { waitUntil: 'networkidle2', timeout: 15000 });
14+
const content = await page.content();
15+
const notFoundText = "couldn't find that page.";
16+
const isValid = !content.includes(notFoundText);
17+
await browser.close();
18+
return isValid;
19+
} catch (error) {
20+
await browser.close();
21+
Logger.info(`Error checking URL with Puppeteer: ${url}`);
22+
return true;
23+
}
24+
}
25+
26+
// Cache to avoid duplicate checks
27+
const urlCheckCache = new Map<string, boolean>();
28+
29+
// Test all URLs in the documentRegistry
30+
Object.entries(documentRegistry).forEach(([key, url]: [string, string]) => {
31+
it(`should have a valid URL for ${key}`, async function () {
32+
// Increase timeout for network requests
33+
this.timeout(15000);
34+
const isValid = urlCheckCache.has(url) ? urlCheckCache.get(url) : await checkSalesforceUrlWithPuppeteer(url);
35+
urlCheckCache.set(url, isValid);
36+
expect(isValid, `URL for ${key} (${url}) should be accessible`).to.be.true;
37+
});
38+
});
39+
40+
it('should have all required document registry entries', () => {
41+
const expectedKeys = [
42+
'errorNoOrgResults',
43+
'couldNotDeactivateOmniProcesses',
44+
'couldNotTruncate',
45+
'couldNotTruncateOmnniProcess',
46+
'invalidNameTypeSubtypeOrLanguage',
47+
'invalidOrRepeatingOmniscriptElementNames',
48+
'invalidDataRaptorName',
49+
'duplicatedCardName',
50+
'duplicatedDrName',
51+
'duplicatedOSName',
52+
'duplicatedName',
53+
'errorWhileActivatingOs',
54+
'errorWhileActivatingCard',
55+
'errorWhileUploadingCard',
56+
'errorWhileCreatingElements',
57+
'allVersionsDescription',
58+
'changeMessage',
59+
'angularOSWarning',
60+
'formulaSyntaxError',
61+
'fileNoOmnistudioCalls',
62+
'fileAlreadyImplementsCallable',
63+
'inApexDrNameWillBeUpdated',
64+
'fileUpdatedToAllowRemoteCalls',
65+
'fileUpdatedToAllowCalls',
66+
'fileImplementsVlocityOpenInterface',
67+
'methodCallBundleNameUpdated',
68+
'cardNameChangeMessage',
69+
'authordNameChangeMessage',
70+
'omniScriptNameChangeMessage',
71+
'dataRaptorNameChangeMessage',
72+
'integrationProcedureNameChangeMessage',
73+
'integrationProcedureManualUpdateMessage',
74+
'duplicateCardNameMessage',
75+
'testURL',
76+
];
77+
78+
expectedKeys.forEach((key) => {
79+
expect(documentRegistry).to.have.property(key);
80+
expect(documentRegistry[key]).to.be.a('string');
81+
expect(documentRegistry[key]).to.match(/^https:\/\/help\.salesforce\.com/);
82+
});
83+
});
84+
});
85+
});

0 commit comments

Comments
 (0)