diff --git a/src/components/Cookies/CookiesToast.tsx b/src/components/Cookies/CookiesToast.tsx
index ea37f600f..0de6797cb 100644
--- a/src/components/Cookies/CookiesToast.tsx
+++ b/src/components/Cookies/CookiesToast.tsx
@@ -38,6 +38,7 @@ export function CookiesToast(props: { privacyPolicy?: string }) {
) : (
- No answer
+ {t(language, 'search_ask_no_answer')}
)}
>
) : null}
- {state?.type === 'error' ? Failed to fetch answer
: null}
+ {state?.type === 'error' ? {t(language, 'search_ask_error')}
: null}
{!state ? (
@@ -78,10 +82,14 @@ export function SearchAskAnswer(props: { spaceId: string; query: string }) {
function AnswerBody(props: { answer: AskAnswerResult }) {
const { answer } = props;
const getSearchLinkProps = useSearchLink();
+ const language = useLanguage();
return (
<>
-
+
{answer.body}
{answer.followupQuestions.length > 0 ? (
@@ -135,7 +143,7 @@ function AnswerBody(props: { answer: AskAnswerResult }) {
'dark:border-light/1',
)}
>
-
Sources
+
{t(language, 'search_ask_sources')}
{answer.sources.map((source) => (
diff --git a/src/components/Search/SearchModal.tsx b/src/components/Search/SearchModal.tsx
index 503a64501..381c2e176 100644
--- a/src/components/Search/SearchModal.tsx
+++ b/src/components/Search/SearchModal.tsx
@@ -60,6 +60,7 @@ export function SearchModal(props: SearchModalProps) {
return (
diff --git a/src/components/Search/SearchResults.tsx b/src/components/Search/SearchResults.tsx
index cbc62848d..0febff59e 100644
--- a/src/components/Search/SearchResults.tsx
+++ b/src/components/Search/SearchResults.tsx
@@ -163,6 +163,7 @@ export const SearchResults = React.forwardRef(function SearchResults(
>
{results.length === 0 ? (
) : (
- results.map((item, index) => {
- switch (item.type) {
- case 'page': {
- return (
-
{
- refs.current[index] = ref;
- }}
- key={item.id}
- query={query}
- item={item}
- active={index === cursor}
- />
- );
+
+ {results.map((item, index) => {
+ switch (item.type) {
+ case 'page': {
+ return (
+ {
+ refs.current[index] = ref;
+ }}
+ key={item.id}
+ query={query}
+ item={item}
+ active={index === cursor}
+ />
+ );
+ }
+ case 'question': {
+ return (
+ {
+ refs.current[index] = ref;
+ }}
+ key={item.id}
+ question={query}
+ active={index === cursor}
+ onClick={onSwitchToAsk}
+ />
+ );
+ }
+ case 'recommended-question': {
+ return (
+ {
+ refs.current[index] = ref;
+ }}
+ key={item.id}
+ question={item.question}
+ active={index === cursor}
+ onClick={onSwitchToAsk}
+ recommended
+ />
+ );
+ }
+ case 'section': {
+ return (
+ {
+ refs.current[index] = ref;
+ }}
+ key={item.id}
+ query={query}
+ item={item}
+ active={index === cursor}
+ />
+ );
+ }
+ default:
+ assertNever(item);
}
- case 'question': {
- return (
- {
- refs.current[index] = ref;
- }}
- key={item.id}
- question={query}
- active={index === cursor}
- onClick={onSwitchToAsk}
- />
- );
- }
- case 'recommended-question': {
- return (
- {
- refs.current[index] = ref;
- }}
- key={item.id}
- question={item.question}
- active={index === cursor}
- onClick={onSwitchToAsk}
- recommended
- />
- );
- }
- case 'section': {
- return (
- {
- refs.current[index] = ref;
- }}
- key={item.id}
- query={query}
- item={item}
- active={index === cursor}
- />
- );
- }
- default:
- assertNever(item);
- }
- })
+ })}
+
)}
);
diff --git a/src/intl/translations/en.json b/src/intl/translations/en.json
index 8740b7fba..0ebd211af 100644
--- a/src/intl/translations/en.json
+++ b/src/intl/translations/en.json
@@ -7,6 +7,9 @@
"search_input_placeholder": "Search content",
"search_no_results": "No results for \"${1}\".",
"search_ask": "Ask \"${1}\"",
+ "search_ask_sources": "Sources",
+ "search_ask_no_answer": "No answer could be found for your question, try with another one.",
+ "search_ask_error": "Something went wrong. Please try again later.",
"on_this_page": "On this page",
"next_page": "Next",
"previous_page": "Previous",
@@ -19,6 +22,7 @@
"code_copied": "Copied!",
"code_copy": "Copy",
"table_of_contents_button_label": "Open table of contents",
+ "cookies_title": "Cookies",
"cookies_prompt": "This site uses cookies to deliver its service and to analyse traffic. By browsing this site, you accept the ${1}.",
"cookies_prompt_privacy": "privacy policy",
"cookies_accept": "Accept",
diff --git a/tests/visual-testing.ts b/tests/visual-testing.ts
index d7342e9a7..d3ef63a94 100644
--- a/tests/visual-testing.ts
+++ b/tests/visual-testing.ts
@@ -1,10 +1,11 @@
-import puppeteer from 'puppeteer';
+import puppeteer, { Page } from 'puppeteer';
import { argosScreenshot } from '@argos-ci/puppeteer';
import { getContentTestURL, getTargetURL } from './utils';
interface Test {
name: string;
url: string;
+ wait?: (page: Page) => Promise;
}
interface TestsCase {
@@ -29,10 +30,12 @@ const testCases: TestsCase[] = [
{
name: 'Search Results',
url: '?q=gitsync',
+ wait: (page) => page.waitForSelector('[data-test="search-results"]'),
},
{
name: 'AI Search',
url: '?q=What+is+GitBook%3F&ask=1',
+ wait: (page) => page.waitForSelector('[data-test="search-ask-answer"]'),
},
{
name: 'Not found',