| 1 |
import { describe, expect, test, getFixture } from "@odoo/hoot"; |
| 2 |
import { getBasicData } from "@spreadsheet/../tests/helpers/data"; |
| 3 |
import { createSpreadsheetDashboard } from "@spreadsheet_dashboard/../tests/helpers/dashboard_action"; |
| 4 |
import { |
| 5 |
defineSpreadsheetDashboardModels, |
| 6 |
getDashboardServerData, |
| 7 |
} from "@spreadsheet_dashboard/../tests/helpers/data"; |
| 8 |
import { contains } from "@web/../tests/web_test_helpers"; |
| 9 |
|
| 10 |
describe.current.tags("mobile"); |
| 11 |
defineSpreadsheetDashboardModels(); |
| 12 |
|
| 13 |
function getServerData(spreadsheetData) { |
| 14 |
const serverData = getDashboardServerData(); |
| 15 |
serverData.models = { |
| 16 |
...serverData.models, |
| 17 |
...getBasicData(), |
| 18 |
}; |
| 19 |
serverData.models["spreadsheet.dashboard.group"].records = [ |
| 20 |
{ |
| 21 |
published_dashboard_ids: [789], |
| 22 |
id: 1, |
| 23 |
name: "Pivot", |
| 24 |
}, |
| 25 |
]; |
| 26 |
serverData.models["spreadsheet.dashboard"].records = [ |
| 27 |
{ |
| 28 |
id: 789, |
| 29 |
name: "Spreadsheet with Pivot", |
| 30 |
json_data: JSON.stringify(spreadsheetData), |
| 31 |
spreadsheet_data: JSON.stringify(spreadsheetData), |
| 32 |
dashboard_group_id: 1, |
| 33 |
}, |
| 34 |
]; |
| 35 |
return serverData; |
| 36 |
} |
| 37 |
|
| 38 |
test("Search input can be toggled", async () => { |
| 39 |
const productFilter = { id: "1", type: "relation", label: "Product", modelName: "product" }; |
| 40 |
const spreadsheetData = { globalFilters: [productFilter] }; |
| 41 |
const serverData = getServerData(spreadsheetData); |
| 42 |
await createSpreadsheetDashboard({ serverData }); |
| 43 |
|
| 44 |
expect(".o_searchview_input").toHaveCount(0); |
| 45 |
|
| 46 |
await contains(".o_search_toggler button").click(); |
| 47 |
expect(".o_searchview_input").toHaveCount(1); |
| 48 |
}); |
| 49 |
|
| 50 |
test("Search input is not focusable in mobile", async () => { |
| 51 |
const productFilter = { |
| 52 |
id: "1", |
| 53 |
type: "relation", |
| 54 |
label: "Product", |
| 55 |
modelName: "product", |
| 56 |
}; |
| 57 |
const spreadsheetData = { globalFilters: [productFilter] }; |
| 58 |
const serverData = getServerData(spreadsheetData); |
| 59 |
await createSpreadsheetDashboard({ serverData }); |
| 60 |
|
| 61 |
await contains(".o_search_toggler button").click(); |
| 62 |
await contains(".o_searchview_input").click(); |
| 63 |
|
| 64 |
const input = getFixture().querySelector(".o_searchview_input"); |
| 65 |
expect(document.activeElement).not.toBe(input); |
| 66 |
expect(".o_bottom_sheet .o-filter-values").toHaveCount(1); |
| 67 |
}); |