CE-1955 Initial checkin

This commit is contained in:
2024-12-03 20:43:33 -06:00
parent 8d37ce3c54
commit 76d7a8a858
2 changed files with 180 additions and 0 deletions

View File

@ -0,0 +1,85 @@
/*
* Copyright © 2022-2023. ColdTrack <contact@coldtrack.com>. All Rights Reserved.
*/
package com.kingsrook.sampleapp.selenium;
import com.kingsrook.qqq.backend.core.logging.QLogger;
import com.kingsrook.qqq.frontend.materialdashboard.selenium.lib.QBaseSeleniumTest;
import com.kingsrook.sampleapp.SampleJavalinServer;
import org.junit.jupiter.api.BeforeEach;
/*******************************************************************************
**
*******************************************************************************/
public class BaseSampleSeleniumTest extends QBaseSeleniumTest
{
private static final QLogger LOG = QLogger.getLogger(BaseSampleSeleniumTest.class);
public static final Integer DEFAULT_WAIT_SECONDS = 10;
private int port = 8011;
/*******************************************************************************
**
*******************************************************************************/
@Override
@BeforeEach
public void beforeEach()
{
super.beforeEach();
qSeleniumLib.withBaseUrl("http://localhost:" + port);
qSeleniumLib.withWaitSeconds(DEFAULT_WAIT_SECONDS);
new SampleJavalinServer().startJavalinServer(port);
}
/*******************************************************************************
**
*******************************************************************************/
@Override
protected boolean useInternalJavalin()
{
return (false);
}
/*******************************************************************************
**
*******************************************************************************/
public void clickLeftNavMenuItem(String text)
{
qSeleniumLib.waitForSelectorContaining(".MuiDrawer-paperAnchorLeft .MuiListItem-root", text).click();
}
/*******************************************************************************
**
*******************************************************************************/
public void clickLeftNavMenuItemThenSubItem(String text, String subItemText)
{
qSeleniumLib.waitForSelectorContaining(".MuiDrawer-paperAnchorLeft .MuiListItem-root", text).click();
qSeleniumLib.waitForSelectorContaining(".MuiDrawer-paperAnchorLeft .MuiCollapse-vertical.MuiCollapse-entered .MuiListItem-root", subItemText).click();
}
/*******************************************************************************
**
*******************************************************************************/
public void goToPathAndWaitForSelectorContaining(String path, String selector, String text)
{
driver.get(qSeleniumLib.getBaseUrl() + path);
qSeleniumLib.waitForSelectorContaining(selector, text);
}
}

View File

@ -0,0 +1,95 @@
/*
* QQQ - Low-code Application Framework for Engineers.
* Copyright (C) 2021-2024. 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 <https://www.gnu.org/licenses/>.
*/
package com.kingsrook.sampleapp.selenium;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.UUID;
import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.Test;
/*******************************************************************************
**
*******************************************************************************/
public class BulkLoadSeleniumTest extends BaseSampleSeleniumTest
{
/*******************************************************************************
**
*******************************************************************************/
@Test
void testSimple() throws IOException
{
String email = "jtkirk@starfleet.com";
String tablePath = "/peopleApp/greetingsApp/person";
////////////////////////////////////
// write a file to be bulk-loaded //
////////////////////////////////////
String path = "/tmp/" + UUID.randomUUID() + ".csv";
String csv = String.format("""
email,firstName,lastName
%s,James T.,Kirk
""", email);
FileUtils.writeStringToFile(new File(path), csv, StandardCharsets.UTF_8);
goToPathAndWaitForSelectorContaining(tablePath + "/person.bulkInsert", ".MuiTypography-h5", "Person Bulk Insert: Upload File");
//////////////////////////////
// complete the upload form //
//////////////////////////////
qSeleniumLib.waitForSelector("input[type=file]").sendKeys(path);
qSeleniumLib.waitForSelectorContaining("button", "next").click();
/////////////////////////////////////////
// proceed through file-mapping screen //
/////////////////////////////////////////
qSeleniumLib.waitForSelectorContaining("button", "next").click();
//////////////////////////////////////////////////
// confirm data on preview screen, then proceed //
//////////////////////////////////////////////////
qSeleniumLib.waitForSelectorContaining("form#review .MuiTypography-body2 div", email);
qSeleniumLib.waitForSelectorContaining("form#review .MuiTypography-body2 div", "Preview 1 of 1");
qSeleniumLib.waitForSelectorContaining("button", "arrow_forward").click(); // to avoid the record-preview 'next' button
///////////////////////////////////////
// proceed through validation screen //
///////////////////////////////////////
qSeleniumLib.waitForSelectorContaining("button", "submit").click();
////////////////////////////////////////
// confirm result screen and close it //
////////////////////////////////////////
qSeleniumLib.waitForSelectorContaining(".MuiListItemText-root", "1 Person record was inserted");
qSeleniumLib.waitForSelectorContaining("button", "close").click();
////////////////////////////////////////////
// go to the order that was just inserted //
// bonus - also test record-view-by-key //
////////////////////////////////////////////
goToPathAndWaitForSelectorContaining(tablePath + "/key?email=" + email, "h5", "Viewing Person");
}
}