From 6bd6b0370b04cb150dd1a7f491fce16c64cc49f3 Mon Sep 17 00:00:00 2001 From: Darin Kelkhoff Date: Tue, 17 Oct 2023 19:26:14 -0500 Subject: [PATCH] Initial checkin --- .../tests/DashboardTableWidgetExportTest.java | 104 +++++++++++++ .../resources/fixtures/metaData/index.json | 146 +----------------- 2 files changed, 108 insertions(+), 142 deletions(-) create mode 100755 src/test/java/com/kingsrook/qqq/materialdashboard/tests/DashboardTableWidgetExportTest.java diff --git a/src/test/java/com/kingsrook/qqq/materialdashboard/tests/DashboardTableWidgetExportTest.java b/src/test/java/com/kingsrook/qqq/materialdashboard/tests/DashboardTableWidgetExportTest.java new file mode 100755 index 0000000..03b9b47 --- /dev/null +++ b/src/test/java/com/kingsrook/qqq/materialdashboard/tests/DashboardTableWidgetExportTest.java @@ -0,0 +1,104 @@ +/* + * QQQ - Low-code Application Framework for Engineers. + * Copyright (C) 2021-2022. Kingsrook, LLC + * 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States + * contact@kingsrook.com + * https://github.com/Kingsrook/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package com.kingsrook.qqq.materialdashboard.tests; + + +import com.kingsrook.qqq.materialdashboard.lib.QBaseSeleniumTest; +import com.kingsrook.qqq.materialdashboard.lib.javalin.QSeleniumJavalin; +import org.junit.jupiter.api.Test; +import org.openqa.selenium.By; +import static org.assertj.core.api.Assertions.assertThat; + + +/******************************************************************************* + ** Tests for dashboard table widget with export button + *******************************************************************************/ +public class DashboardTableWidgetExportTest extends QBaseSeleniumTest +{ + + /******************************************************************************* + ** + *******************************************************************************/ + @Override + protected void addJavalinRoutes(QSeleniumJavalin qSeleniumJavalin) + { + super.addJavalinRoutes(qSeleniumJavalin); + qSeleniumJavalin + .withRouteToFile("/data/person/count", "data/person/count.json") + .withRouteToFile("/data/city/count", "data/city/count.json"); + + qSeleniumJavalin.withRouteToString("/widget/SampleTableWidget", """ + { + "label": "Sample Table Widget", + "footerHTML": "Updated at 2023-10-17 09:11:38 AM CDT", + "columns": [ + { "type": "html", "header": "Id", "accessor": "id", "width": "1%" }, + { "type": "html", "header": "Name", "accessor": "name", "width": "99%" } + ], + "rows": [ + { "id": "1", "name": "Homer S." }, + { "id": "2", "name": "Marge B." }, + { "id": "3", "name": "Bart J." } + ], + "type": "table" + } + """); + } + + + + /******************************************************************************* + ** + *******************************************************************************/ + @Test + void testDashboardTableWidgetExport() + { + qSeleniumLib.gotoAndWaitForBreadcrumbHeader("/", "Greetings App"); + + //////////////////////////////////////////////////////////////////////// + // assert that the table widget rendered its header and some contents // + //////////////////////////////////////////////////////////////////////// + qSeleniumLib.waitForSelectorContaining("#SampleTableWidget h6", "Sample Table Widget"); + qSeleniumLib.waitForSelectorContaining("#SampleTableWidget table a", "Homer S."); + qSeleniumLib.waitForSelectorContaining("#SampleTableWidget div", "Updated at 2023-10-17 09:11:38 AM CDT"); + + ///////////////////////////// + // click the export button // + ///////////////////////////// + qSeleniumLib.waitForSelector("#SampleTableWidget h6") + .findElement(By.xpath("./..")) + .findElement(By.cssSelector("button")) + .click(); + + ///////////////////////////////////////////////////////////////////////////// + // assert about the file that was downloaded - its name and some contents. // + ///////////////////////////////////////////////////////////////////////////// + String latestFile = qSeleniumLib.getLatestChromeDownloadedFileInfo(); + assertThat(latestFile).contains("Sample Table Widget"); + assertThat(latestFile).contains(".csv"); + assertThat(latestFile).contains(""" + "Id"%2C"Name"%0A"1"%2C"Homer S."%0A"""); + + qSeleniumLib.waitForever(); + } + +} diff --git a/src/test/resources/fixtures/metaData/index.json b/src/test/resources/fixtures/metaData/index.json index af09f14..9f31409 100644 --- a/src/test/resources/fixtures/metaData/index.json +++ b/src/test/resources/fixtures/metaData/index.json @@ -302,8 +302,7 @@ "label": "Greetings App", "iconName": "emoji_people", "widgets": [ - "PersonsByCreateDateBarChart", - "QuickSightChartRenderer" + "SampleTableWidget" ], "children": [ { @@ -738,147 +737,10 @@ "icon": "/kr-icon.png" }, "widgets": { - "parcelTrackingDetails": { - "name": "parcelTrackingDetails", - "label": "Tracking Details", - "type": "childRecordList" - }, - "deposcoSalesOrderLineItems": { - "name": "deposcoSalesOrderLineItems", - "label": "Line Items", - "type": "childRecordList" - }, - "TotalShipmentsByDayBarChart": { - "name": "TotalShipmentsByDayBarChart", - "label": "Total Shipments By Day", - "type": "chart" - }, - "TotalShipmentsByMonthLineChart": { - "name": "TotalShipmentsByMonthLineChart", - "label": "Total Shipments By Month", - "type": "chart" - }, - "YTDShipmentsByCarrierPieChart": { - "name": "YTDShipmentsByCarrierPieChart", - "label": "Shipments By Carrier Year To Date", - "type": "chart" - }, - "TodaysShipmentsStatisticsCard": { - "name": "TodaysShipmentsStatisticsCard", - "label": "Today's Shipments", - "type": "statistics" - }, - "ShipmentsInTransitStatisticsCard": { - "name": "ShipmentsInTransitStatisticsCard", - "label": "Shipments In Transit", - "type": "statistics" - }, - "OpenOrdersStatisticsCard": { - "name": "OpenOrdersStatisticsCard", - "label": "Open Orders", - "type": "statistics" - }, - "ShippingExceptionsStatisticsCard": { - "name": "ShippingExceptionsStatisticsCard", - "label": "Shipping Exceptions", - "type": "statistics" - }, - "WarehouseLocationCards": { - "name": "WarehouseLocationCards", - "type": "location" - }, - "TotalShipmentsStatisticsCard": { - "name": "TotalShipmentsStatisticsCard", - "label": "Total Shipments", - "type": "statistics" - }, - "SuccessfulDeliveriesStatisticsCard": { - "name": "SuccessfulDeliveriesStatisticsCard", - "label": "Successful Deliveries", - "type": "statistics" - }, - "ServiceFailuresStatisticsCard": { - "name": "ServiceFailuresStatisticsCard", - "label": "Service Failures", - "type": "statistics" - }, - "CarrierVolumeLineChart": { - "name": "CarrierVolumeLineChart", - "label": "Carrier Volume By Month", - "type": "lineChart" - }, - "YTDSpendByCarrierTable": { - "name": "YTDSpendByCarrierTable", - "label": "Spend By Carrier Year To Date", + "SampleTableWidget": { + "name": "SampleTableWidget", + "label": "Sample Table Widget", "type": "table" - }, - "TimeInTransitBarChart": { - "name": "TimeInTransitBarChart", - "label": "Time In Transit Last 30 Days", - "type": "chart" - }, - "OpenBillingWorksheetsTable": { - "name": "OpenBillingWorksheetsTable", - "label": "Open Billing Worksheets", - "type": "table" - }, - "AssociatedParcelInvoicesTable": { - "name": "AssociatedParcelInvoicesTable", - "label": "Associated Parcel Invoices", - "type": "table", - "icon": "receipt" - }, - "BillingWorksheetLinesTable": { - "name": "BillingWorksheetLinesTable", - "label": "Billing Worksheet Lines", - "type": "table" - }, - "RatingIssuesWidget": { - "name": "RatingIssuesWidget", - "label": "Rating Issues", - "type": "html", - "icon": "warning", - "gridColumns": 6 - }, - "UnassignedParcelInvoicesTable": { - "name": "UnassignedParcelInvoicesTable", - "label": "Unassigned Parcel Invoices", - "type": "table" - }, - "ParcelInvoiceSummaryWidget": { - "name": "ParcelInvoiceSummaryWidget", - "label": "Parcel Invoice Summary", - "type": "multiStatistics" - }, - "ParcelInvoiceLineExceptionsSummaryWidget": { - "name": "ParcelInvoiceLineExceptionsSummaryWidget", - "label": "Parcel Invoice Line Exceptions", - "type": "multiStatistics" - }, - "BillingWorksheetStatusStepper": { - "name": "BillingWorksheetStatusStepper", - "label": "Billing Worksheet Progress", - "type": "stepper", - "icon": "refresh", - "gridColumns": 6 - }, - "PersonsByCreateDateBarChart": { - "name": "PersonsByCreateDateBarChart", - "label": "Persons By Create Date", - "type": "barChart" - }, - "QuickSightChartRenderer": { - "name": "QuickSightChartRenderer", - "label": "Quick Sight", - "type": "quickSightChart" - }, - "scriptViewer": { - "name": "scriptViewer", - "label": "Contents", - "type": "scriptViewer", - "isCard": true, - "storeDropdownSelections": false, - "hasPermission": true } }, "environmentValues": {