Skip to content

Commit 7b4339a

Browse files
feat: validation for the title of CTA
1 parent f5669bb commit 7b4339a

File tree

2 files changed

+1147
-529
lines changed

2 files changed

+1147
-529
lines changed

test/utils/constants/documentRegistry.test.ts

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,64 @@ import { expect } from '@salesforce/command/lib/test';
33
import { documentRegistry } from '../../../src/utils/constants/documentRegistry';
44
import { Logger } from '../../../src/utils/logger';
55

6+
// Dictionary mapping documentRegistry keys to their expected page titles
7+
const titles = {
8+
errorNoOrgResults: 'Run the Omnistudio Migration Tool',
9+
couldNotDeactivateOmniProcesses: 'Deactivate and Activate OmniScripts',
10+
couldNotTruncate: 'Embed an Omniscript in Another Omniscript',
11+
couldNotTruncateOmnniProcess: 'Embed an Omniscript in Another Omniscript',
12+
invalidNameTypeSubtypeOrLanguage: 'Omnistudio Naming Conventions',
13+
invalidOrRepeatingOmniscriptElementNames: 'Omnistudio Naming Conventions',
14+
invalidDataRaptorName: 'Omnistudio Naming Conventions',
15+
duplicatedCardName: 'Omnistudio Naming Conventions',
16+
duplicatedDrName: 'Omnistudio Naming Conventions',
17+
duplicatedOSName: 'Omnistudio Naming Conventions',
18+
duplicatedName: 'Omnistudio Naming Conventions',
19+
errorWhileActivatingOs: 'Activating Omniscripts',
20+
errorWhileActivatingCard: 'Activate and Publish a Flexcard',
21+
errorWhileUploadingCard: 'Activate and Publish a Flexcard',
22+
errorWhileCreatingElements: 'Omniscript Element Reference',
23+
allVersionsDescription: 'Migrate All Versions of OmniStudio Components',
24+
changeMessage: 'Omnistudio Naming Conventions',
25+
angularOSWarning: 'Convert an Angular Omniscript to an LWC Omniscript',
26+
formulaSyntaxError: 'Formulas and Functions',
27+
fileNoOmnistudioCalls: 'Callable Implementations',
28+
fileAlreadyImplementsCallable: 'Callable Implementations',
29+
inApexDrNameWillBeUpdated: 'Update References to Omnistudio Data Mappers from Apex After Migration',
30+
fileUpdatedToAllowRemoteCalls: 'Make a Long-Running Remote Call Using Omnistudio.OmniContinuation',
31+
fileUpdatedToAllowCalls: 'Make a Long-Running Remote Call Using Omnistudio.OmniContinuation',
32+
fileImplementsVlocityOpenInterface: 'VlocityOpenInterface',
33+
methodCallBundleNameUpdated: 'Updates to Omnistudio Custom Functions',
34+
cardNameChangeMessage: 'Omnistudio Naming Conventions',
35+
authordNameChangeMessage: 'Omnistudio Naming Conventions',
36+
omniScriptNameChangeMessage:
37+
'Update Omniscript Custom Lightning Web Components and Omniscript Elements Overridden with Customized Components',
38+
dataRaptorNameChangeMessage: 'Update References to Omnistudio Data Mappers from Apex After Migration',
39+
integrationProcedureNameChangeMessage: 'Update Integration Procedure Type and Subtype After Migration',
40+
integrationProcedureManualUpdateMessage: 'Update Integration Procedure Type and Subtype After Migration',
41+
duplicateCardNameMessage: 'Clone a Flexcard',
42+
};
43+
644
describe('DocumentRegistry', () => {
745
describe('URL Validation', () => {
846
// Helper function to make HTTP request and check if URL is accessible
9-
async function checkSalesforceUrlWithPuppeteer(url: string): Promise<boolean> {
47+
async function checkSalesforceUrlWithPuppeteer(key: string, url: string): Promise<boolean> {
1048
const browser = await puppeteer.launch({ headless: true }); // use true instead of 'new'
1149
const page = await browser.newPage();
1250
try {
1351
await page.goto(url, { waitUntil: 'networkidle2', timeout: 15000 });
1452
const content = await page.content();
1553
const notFoundText = "couldn't find that page.";
1654
const isValid = !content.includes(notFoundText);
55+
if (!isValid) {
56+
Logger.error(`URL for ${key} (${url}) is not accessible`);
57+
}
58+
const isTitleValid = content.includes(titles[key]);
59+
if (!isTitleValid) {
60+
Logger.error(`The content of the page for ${key} (${url}) is not valid`);
61+
}
1762
await browser.close();
18-
return isValid;
63+
return isValid && isTitleValid;
1964
} catch (error) {
2065
await browser.close();
2166
Logger.info(`Error checking URL with Puppeteer: ${url}`);
@@ -31,7 +76,9 @@ describe('DocumentRegistry', () => {
3176
it(`should have a valid URL for ${key}`, async function () {
3277
// Increase timeout for network requests
3378
this.timeout(20000);
34-
const isValid = urlCheckCache.has(url) ? urlCheckCache.get(url) : await checkSalesforceUrlWithPuppeteer(url);
79+
const isValid = urlCheckCache.has(url)
80+
? urlCheckCache.get(url)
81+
: await checkSalesforceUrlWithPuppeteer(key, url);
3582
urlCheckCache.set(url, isValid);
3683
expect(isValid, `URL for ${key} (${url}) should be accessible`).to.be.true;
3784
});

0 commit comments

Comments
 (0)