@@ -2633,8 +2633,6 @@ void TestGui::testExcludedGroupEntryInReports()
26332633 auto rect = healthTable->visualRect (index);
26342634 auto centerPoint = rect.center ();
26352635 QTest::mouseClick (healthTable->viewport (), Qt::LeftButton, Qt::NoModifier, centerPoint);
2636- // QTest::mouseClick(healthTable->viewport(), Qt::RightButton, Qt::NoModifier, centerPoint);
2637- // QTest::mouseClick(healthCheckWidget, Qt::RightButton);
26382636 healthCheckWidget->customMenuRequested (centerPoint);
26392637
26402638 QMenu* menu = healthCheckWidget->findChild <QMenu*>(" customMenu" );
@@ -2672,6 +2670,145 @@ void TestGui::testExcludedGroupEntryInReports()
26722670 QCOMPARE (m_dbWidget->currentMode (), DatabaseWidget::Mode::ViewMode);
26732671}
26742672
2673+ void TestGui::testExcludedGroupReincludeAllEntries ()
2674+ {
2675+ addGroup (" Finance" );
2676+ addGroup (" Entertainment" );
2677+
2678+ // Use bad passwords to make sure they all show up in health report
2679+ addEntry (" Finance" , " Chase" , " user1" , " password" );
2680+ addEntry (" Finance" , " Amex" , " user1" , " password123" );
2681+ addEntry (" Finance" , " Capital One" , " user1" , " password456" );
2682+
2683+ addEntry (" Entertainment" , " Netflix" , " user1" , " password" );
2684+ addEntry (" Entertainment" , " Hulu" , " user1" , " password321" );
2685+ addEntry (" Entertainment" , " Apple TV" , " user1" , " password123" );
2686+
2687+ Group* entertainmentGroup = m_dbWidget->currentGroup ()->findChildByName (" Entertainment" );
2688+ m_dbWidget->groupView ()->setCurrentGroup (entertainmentGroup);
2689+
2690+ auto * toolBar = m_mainWindow->findChild <QToolBar*>(" toolBar" );
2691+ QVERIFY (toolBar);
2692+
2693+ auto * editGroupAction = m_mainWindow->findChild <QAction*>(" actionGroupEdit" );
2694+ QVERIFY (editGroupAction->isEnabled ());
2695+ triggerAction (" actionGroupEdit" );
2696+
2697+ auto * editGroupWidget = m_dbWidget->findChild <EditGroupWidget*>(" editGroupWidget" );
2698+ QVERIFY (editGroupWidget);
2699+
2700+ // Bring up group edit page
2701+ QTest::mouseClick (editGroupWidget, Qt::LeftButton);
2702+
2703+ QLineEdit* nameEdit = editGroupWidget->findChild <QLineEdit*>(" editName" );
2704+ QCOMPARE (nameEdit->text (), QString (" Entertainment" ));
2705+
2706+ // Find database report exclusion checkbox and check it
2707+ QCheckBox* excludeGroupFromReportsCheckbox = editGroupWidget->findChild <QCheckBox*>(" excludeReportsCheckBox" );
2708+ QVERIFY (excludeGroupFromReportsCheckbox);
2709+
2710+ excludeGroupFromReportsCheckbox->setChecked (true );
2711+
2712+ auto * editGroupWidgetButtonBox = editGroupWidget->findChild <QDialogButtonBox*>(" buttonBox" );
2713+ QVERIFY (editGroupWidgetButtonBox);
2714+
2715+ // Apply and go back to main view
2716+ QTest::mouseClick (editGroupWidgetButtonBox->button (QDialogButtonBox::Apply), Qt::LeftButton);
2717+ QTest::mouseClick (editGroupWidgetButtonBox->button (QDialogButtonBox::Ok), Qt::LeftButton);
2718+ QCOMPARE (m_dbWidget->currentMode (), DatabaseWidget::Mode::ViewMode);
2719+
2720+ QVERIFY (entertainmentGroup->excludeFromReports ());
2721+
2722+ // Verify they don't show up in the report
2723+ auto * actionReports = m_mainWindow->findChild <QAction*>(" actionReports" );
2724+ QVERIFY (actionReports->isEnabled ());
2725+
2726+ QWidget* actionReportsWidget = toolBar->widgetForAction (actionReports);
2727+ QVERIFY (actionReportsWidget);
2728+ QVERIFY (actionReportsWidget->isVisible ());
2729+ QVERIFY (actionReportsWidget->isEnabled ());
2730+
2731+ QTest::mouseClick (actionReportsWidget, Qt::LeftButton);
2732+
2733+ auto * reportsDialog = m_dbWidget->findChild <ReportsDialog*>(" reportsDialog" );
2734+ QVERIFY (reportsDialog);
2735+
2736+ CategoryListWidget* categoryList = reportsDialog->findChild <CategoryListWidget*>(" categoryList" );
2737+ categoryList->setCurrentCategory (1 );
2738+
2739+ QStackedWidget* stackedWidget = reportsDialog->findChild <QStackedWidget*>(" stackedWidget" );
2740+ QVERIFY (stackedWidget);
2741+ stackedWidget->setCurrentIndex (1 );
2742+
2743+ ReportsWidgetHealthcheck* healthCheckWidget = reportsDialog->findChild <ReportsWidgetHealthcheck*>();
2744+ QVERIFY (healthCheckWidget);
2745+
2746+ QTest::mouseClick (healthCheckWidget, Qt::LeftButton);
2747+ QTableView* healthTable = healthCheckWidget->findChild <QTableView*>(" healthcheckTableView" );
2748+ QVERIFY (healthTable);
2749+
2750+ QSignalSpy healthCheckWidgetSpy (healthCheckWidget, &ReportsWidgetHealthcheck::tablePopulated);
2751+
2752+ QAbstractItemModel* healthModel = healthTable->model ();
2753+ QVERIFY (healthModel);
2754+
2755+ // There should be 3 showing
2756+ QTRY_COMPARE (healthCheckWidgetSpy.count (), 1 );
2757+ QCOMPARE (healthModel->rowCount (), 5 ); // account for 2 existing passwords at the start of each test case
2758+
2759+ QCheckBox* showExcludedCheckBox = healthCheckWidget->findChild <QCheckBox*>(" showExcluded" );
2760+ QVERIFY (showExcludedCheckBox);
2761+ QCOMPARE (showExcludedCheckBox->isChecked (), false );
2762+
2763+ showExcludedCheckBox->click ();
2764+ QVERIFY (showExcludedCheckBox->isChecked ());
2765+ QTRY_COMPARE (healthCheckWidgetSpy.count (), 2 );
2766+
2767+ healthModel = healthTable->model ();
2768+ QCOMPARE (healthModel->rowCount (), 8 ); // account for 2 existing passwords at the start of each test case
2769+
2770+ for (int i = 0 ; i < healthModel->rowCount (); ++i) {
2771+ QModelIndex index = healthModel->index (i, 1 );
2772+ QVariant data = healthModel->data (index);
2773+
2774+ if (data.toString ().contains (" Netflix" )) {
2775+ auto rect = healthTable->visualRect (index);
2776+ auto centerPoint = rect.center ();
2777+ QTest::mouseClick (healthTable->viewport (), Qt::LeftButton, Qt::NoModifier, centerPoint);
2778+ healthCheckWidget->customMenuRequested (centerPoint);
2779+
2780+ QMenu* menu = healthCheckWidget->findChild <QMenu*>(" customMenu" );
2781+ QVERIFY (menu);
2782+ QAction* excludeEntryAction = healthCheckWidget->findChild <QAction*>(" contextMenuExcludeAction" );
2783+ QVERIFY (excludeEntryAction);
2784+ MessageBox::setNextAnswer (MessageBox::Yes);
2785+
2786+ excludeEntryAction->trigger ();
2787+ QApplication::processEvents ();
2788+ break ;
2789+ }
2790+ }
2791+
2792+ QTRY_COMPARE (healthCheckWidgetSpy.count (), 3 );
2793+
2794+ for (int i = 0 ; i < healthModel->rowCount (); ++i) {
2795+ QModelIndex index = healthModel->index (i, 1 );
2796+ QVariant data = healthModel->data (index);
2797+
2798+ QVERIFY (!data.toString ().contains (" (Group Excluded)" ));
2799+ }
2800+
2801+ showExcludedCheckBox->click ();
2802+ QVERIFY (!showExcludedCheckBox->isChecked ());
2803+ QTRY_COMPARE (healthCheckWidgetSpy.count (), 4 );
2804+
2805+ QCOMPARE (healthModel->rowCount (), 8 ); // 2 existing passwords from start, 3 from Finance, 3 from Entertainment
2806+
2807+ auto * reportsDialogButtonBox = reportsDialog->findChild <QDialogButtonBox*>(" buttonBox" );
2808+ QTest::mouseClick (reportsDialogButtonBox->button (QDialogButtonBox::Close), Qt::LeftButton);
2809+ QCOMPARE (m_dbWidget->currentMode (), DatabaseWidget::Mode::ViewMode);
2810+ }
2811+
26752812void TestGui::addCannedEntries ()
26762813{
26772814 // Find buttons
0 commit comments