Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasolson committed Dec 11, 2024
1 parent 28d35d4 commit deacd8d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
14 changes: 9 additions & 5 deletions examples/search_examples/public/search/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export const SearchExamplesApp = ({
const [timeTook, setTimeTook] = useState<number | undefined>();
const [total, setTotal] = useState<number>(100);
const [loaded, setLoaded] = useState<number>(0);
const [executedAt, setExecutedAt] = useState<number>(0);
const [dataView, setDataView] = useState<DataView | null>();
const [fields, setFields] = useState<DataViewField[]>();
const [selectedFields, setSelectedFields] = useState<DataViewField[]>([]);
Expand All @@ -113,6 +114,7 @@ export const SearchExamplesApp = ({
setLoaded(response.loaded!);
setTotal(response.total!);
setTimeTook(response.rawResponse.took);
setExecutedAt((response as IMyStrategyResponse).executed_at);
}

// Fetch the default data view using the `data.dataViews` service, as the component is mounted.
Expand Down Expand Up @@ -215,18 +217,13 @@ export const SearchExamplesApp = ({
res.rawResponse.aggregations[1].value
: undefined;
const isCool = (res as IMyStrategyResponse).cool;
const executedAt = (res as IMyStrategyResponse).executed_at;
const message = (
<EuiText>
Searched {res.rawResponse.hits.total as number} documents. <br />
The ${metricAggType} of {selectedNumericField!.name} is{' '}
{aggResult ? Math.floor(aggResult) : 0}.
<br />
{isCool ? `Is it Cool? ${isCool}` : undefined}
<br />
<EuiText data-test-subj="requestExecutedAt">
{executedAt ? `Executed at? ${executedAt}` : undefined}
</EuiText>
</EuiText>
);
notifications.toasts.addSuccess(
Expand Down Expand Up @@ -471,6 +468,13 @@ export const SearchExamplesApp = ({
values={{ time: timeTook ?? 'Unknown' }}
/>
</EuiText>
<EuiText size="xs" data-test-subj="requestExecutedAt">
<FormattedMessage
id="searchExamples.executedAtText"
defaultMessage="Executed at: {time}"
values={{ time: executedAt ?? 'Unknown' }}
/>
</EuiText>
<EuiProgress value={loaded} max={total} size="xs" data-test-subj="progressBar" />
<EuiCodeBlock
language="json"
Expand Down
8 changes: 6 additions & 2 deletions x-pack/test/examples/search_examples/search_sessions_cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const comboBox = getService('comboBox');

async function getExecutedAt() {
const toast = await toasts.getElementByIndex(1);
const timeElem = await testSubjects.findDescendant('requestExecutedAt', toast);
await retry.waitFor('toast appears', async () => {
return (await toasts.getCount()) > 0;
});
await testSubjects.click('responseTab');
const timeElem = await testSubjects.find('requestExecutedAt');
const text = await timeElem.getVisibleText();
await testSubjects.click('requestTab');
await toasts.dismissAll();
await retry.waitFor('toasts gone', async () => {
return (await toasts.getCount()) === 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
sectionLinks: [
'dataViews',
'filesManagement',
'aiAssistantManagementSelection',
'objects',
'aiAssistantManagementSelection',
'tags',
'search_sessions',
'spaces',
Expand Down

0 comments on commit deacd8d

Please sign in to comment.