feat(GODT-2816): Wait until mandatory fields are filled then fill body and title.

This commit is contained in:
Romain LE JEUNE
2023-07-28 16:35:52 +02:00
committed by Romain Le Jeune
parent 3d64c5f894
commit 80d729e3e5
15 changed files with 885 additions and 766 deletions

View File

@ -137,13 +137,13 @@ TEST_F(BugReportFlowFixture, validFile) {
EXPECT_TRUE(flow_.setAnswer(0, "pwet"));
EXPECT_FALSE(flow_.setAnswer(1, "pwet"));
qDebug() << flow_.collectAnswers(0);
EXPECT_EQ(flow_.collectAnswers(0), "Category: I can't receive mail\n\r - What happened?\n\rpwet\n\r");
EXPECT_EQ(flow_.collectAnswers(0), " - What happened?\n\rpwet\n\r");
EXPECT_EQ(flow_.collectAnswers(1), "");
EXPECT_EQ(flow_.getAnswer(0), "pwet");
EXPECT_EQ(flow_.getAnswer(1), "");
flow_.clearAnswers();
EXPECT_EQ(flow_.collectAnswers(0), "Category: I can't receive mail\n\r");
EXPECT_EQ(flow_.collectAnswers(0), "");
}

View File

@ -53,17 +53,17 @@ bool BugReportFlow::parse(const QString& filepath) {
//****************************************************************************************************************************************************
/// \return The value for the 'bugCategories' property.
//****************************************************************************************************************************************************
QStringList BugReportFlow::categories() const {
return categories_;
}
QStringList BugReportFlow::categories() const {
return categories_;
}
//****************************************************************************************************************************************************
/// \return The value for the 'bugQuestions' property.
//****************************************************************************************************************************************************
QVariantList BugReportFlow::questions() const {
return questions_;
}
QVariantList BugReportFlow::questions() const {
return questions_;
}
//****************************************************************************************************************************************************
@ -91,6 +91,19 @@ bool BugReportFlow::setAnswer(quint8 questionId, QString const &answer) {
}
//****************************************************************************************************************************************************
/// \param[in] questionId The id of the question.
/// \return answer the given question.
//****************************************************************************************************************************************************
QString BugReportFlow::getCategory(quint8 categoryId) const {
QString category;
if (categoryId <= categories_.count() - 1) {
category = categories_[categoryId];
}
return category;
}
//****************************************************************************************************************************************************
/// \param[in] questionId The id of the question.
/// \return answer the given question.
@ -113,7 +126,6 @@ QString BugReportFlow::collectAnswers(quint8 categoryId) const {
if (categoryId > categories_.count() - 1)
return answers;
answers += "Category: " + categories_[categoryId] + "\n\r";
QVariantList sets = this->questionSet(categoryId);
for (QVariant const &var: sets) {
const QString& answer = getAnswer(var.toInt());

View File

@ -38,9 +38,9 @@ public: // member functions.
[[nodiscard]] QStringList categories() const; ///< Getter for the 'bugCategories' property.
[[nodiscard]] QVariantList questions() const; ///< Getter for the 'bugQuestions' property.
[[nodiscard]] QVariantList questionSet(quint8 categoryId) const; ///< Retrieve the set of question for a given bug category.
[[nodiscard]] bool setAnswer(quint8 questionId, QString const &answer); ///< Feed an answer for a given question.
[[nodiscard]] QString getAnswer(quint8 questionId) const; ///< Collect answer for a given questions.
[[nodiscard]] QString getCategory(quint8 categoryId) const; ///< Get category name.
[[nodiscard]] QString getAnswer(quint8 questionId) const; ///< Get answer for a given question.
[[nodiscard]] QString collectAnswers(quint8 categoryId) const; ///< Collect answer for a given set of questions.
void clearAnswers(); ///< Clear all collected answers.

View File

@ -353,16 +353,18 @@ grpc::Status GRPCClient::currentEmailClient(QString &outName) {
//****************************************************************************************************************************************************
/// \param[in] category The category of the bug.
/// \param[in] description The description of the bug.
/// \param[in] address The email address.
/// \param[in] emailClient The email client.
/// \param[in] includeLogs Should the report include the logs.
/// \return The status for the gRPC call.
//****************************************************************************************************************************************************
grpc::Status GRPCClient::reportBug(QString const &description, QString const &address, QString const &emailClient, bool includeLogs) {
grpc::Status GRPCClient::reportBug(QString const &category, QString const &description, QString const &address, QString const &emailClient, bool includeLogs) {
ReportBugRequest request;
request.set_ostype(QSysInfo::productType().toStdString());
request.set_osversion(QSysInfo::prettyProductName().toStdString());
request.set_title(category.toStdString());
request.set_description(description.toStdString());
request.set_address(address.toStdString());
request.set_emailclient(emailClient.toStdString());

View File

@ -77,7 +77,7 @@ public: // member functions.
grpc::Status colorSchemeName(QString &outName); ///< Performs the "colorSchemeName' gRPC call.
grpc::Status setColorSchemeName(QString const &name); ///< Performs the "setColorSchemeName' gRPC call.
grpc::Status currentEmailClient(QString &outName); ///< Performs the 'currentEmailClient' gRPC call.
grpc::Status reportBug(QString const &description, QString const &address, QString const &emailClient, bool includeLogs); ///< Performs the 'ReportBug' gRPC call.
grpc::Status reportBug(QString const &category, QString const &description, QString const &address, QString const &emailClient, bool includeLogs); ///< Performs the 'ReportBug' gRPC call.
grpc::Status exportTLSCertificates(QString const &folderPath); ///< Performs the 'ExportTLSCertificates' gRPC call.
grpc::Status quit(); ///< Perform the "Quit" gRPC call.
grpc::Status restart(); ///< Performs the Restart gRPC call.