Skip to content

Commit 48b5724

Browse files
mmiticheerocheleau
andauthored
fix(quantic): citation url in tooltip issue fixed (#5048)
## https://coveord.atlassian.net/browse/SFINT-6023 ### The issue: the Quantic Citation component currently displays the regular link on hover even when the document is a Salesforce document. ### The fix: The expected behaviour is to display the Salesforce link constructed using the Salesforce APIs instead of the regular link. --------- Co-authored-by: Etienne Rocheleau <[email protected]>
1 parent 0102cbb commit 48b5724

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

packages/quantic/cypress/e2e/default-2/generatedAnswer/generated-answer-selectors.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -109,20 +109,20 @@ export const GeneratedAnswerSelectors: GeneratedAnswerSelector = {
109109
citationTooltipUri: (index: number) =>
110110
GeneratedAnswerSelectors.get()
111111
.find(
112-
'[data-testid="generated-answer__citations"] [data-cy="citation__tooltip-uri"]'
112+
'[data-testid="generated-answer__citations"] [data-testid="citation__tooltip-uri"]'
113113
)
114114
.eq(index),
115115
citationTooltipTitle: (index: number) =>
116116
GeneratedAnswerSelectors.get()
117117
.find(
118-
'[data-testid="generated-answer__citations"] [data-cy="citation__tooltip-title"]'
118+
'[data-testid="generated-answer__citations"] [data-testid="citation__tooltip-title"]'
119119
)
120120
.eq(index),
121121

122122
citationTooltipText: (index: number) =>
123123
GeneratedAnswerSelectors.get()
124124
.find(
125-
'[data-testid="generated-answer__citations"] [data-cy="citation__tooltip-text"]'
125+
'[data-testid="generated-answer__citations"] [data-testid="citation__tooltip-text"]'
126126
)
127127
.eq(index),
128128
disclaimer: () =>

packages/quantic/force-app/main/default/lwc/quanticCitation/__tests__/quanticCitation.test.js

+18-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const exampleSalesforceKnowledgeArticleCitation = {
3737
sfkavid: 'bar',
3838
},
3939
};
40-
const exampleSalesforceLink = 'https://www.example-salesforce.com/';
40+
const exampleSalesforceLink = 'https://www.example-salesforce.com';
4141

4242
const defaultOptions = {
4343
citation: exampleCitation,
@@ -53,6 +53,7 @@ const selectors = {
5353
citationLink: '.citation__link',
5454
citationTitle: '.citation__title',
5555
citationTooltip: 'c-quantic-tooltip',
56+
citationTooltipUrl: '[data-testid="citation__tooltip-uri"]',
5657
};
5758

5859
function createTestComponent(options = defaultOptions) {
@@ -211,7 +212,7 @@ describe('c-quantic-citation', () => {
211212
expect(pageReference.attributes.recordId).toBe(
212213
exampleSalesforceCitation.fields.sfid
213214
);
214-
expect(link.href).toBe(exampleSalesforceLink);
215+
expect(link.href).toBe(`${exampleSalesforceLink}/`);
215216
});
216217

217218
it('should open the citation link inside Salesforce', async () => {
@@ -231,6 +232,20 @@ describe('c-quantic-citation', () => {
231232
);
232233
});
233234

235+
it('should display the salesforce link inside the tooltip url', async () => {
236+
const element = createTestComponent({
237+
...defaultOptions,
238+
citation: exampleSalesforceCitation,
239+
});
240+
await flushPromises();
241+
242+
const citationTooltipUrl = element.shadowRoot.querySelector(
243+
selectors.citationTooltipUrl
244+
);
245+
expect(citationTooltipUrl).not.toBeNull();
246+
expect(citationTooltipUrl.textContent).toBe(exampleSalesforceLink);
247+
});
248+
234249
describe('when the result is a knowledge article', () => {
235250
it('should open the citation link inside Salesforce', async () => {
236251
const element = createTestComponent({
@@ -247,7 +262,7 @@ describe('c-quantic-citation', () => {
247262
expect(pageReference.attributes.recordId).toBe(
248263
exampleSalesforceKnowledgeArticleCitation.fields.sfkavid
249264
);
250-
expect(link.href).toBe(exampleSalesforceLink);
265+
expect(link.href).toBe(`${exampleSalesforceLink}/`);
251266
});
252267
});
253268
});

packages/quantic/force-app/main/default/lwc/quanticCitation/quanticCitation.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
</a>
2020
<c-quantic-tooltip light-theme class="slds-show_medium" target={template.host}>
2121
<div class="citation__tooltip" slot="content">
22-
<div data-cy="citation__tooltip-uri" class="slds-text-body_small slds-text-color_weak slds-truncate slds-var-p-vertical_xxx-small">{clickUri}</div>
23-
<div data-cy="citation__tooltip-title" class="slds-text-title_bold slds-var-p-vertical_xx-small">{citationTitle}</div>
24-
<div data-cy="citation__tooltip-text" class="citation__tooltip-text slds-text-body_small slds-var-p-vertical_xxx-small">{text}</div>
22+
<div data-testid="citation__tooltip-uri" class="slds-text-body_small slds-text-color_weak slds-truncate slds-var-p-vertical_xxx-small">{hrefValue}</div>
23+
<div data-testid="citation__tooltip-title" class="slds-text-title_bold slds-var-p-vertical_xx-small">{citationTitle}</div>
24+
<div data-testid="citation__tooltip-text" class="citation__tooltip-text slds-text-body_small slds-var-p-vertical_xxx-small">{text}</div>
2525
</div>
2626
</c-quantic-tooltip>
2727
</li>

0 commit comments

Comments
 (0)