mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-15 22:56:48 +00:00
feat(GODT-2782): Add category name in decribe issue view + apply review comments.
This commit is contained in:
@ -94,7 +94,7 @@ void BugReportFlowFixture::feedTempFile(const QString& json) {
|
||||
//****************************************************************************************************************************************************
|
||||
TEST_F(BugReportFlowFixture, noFile) {
|
||||
EXPECT_FALSE(flow_.parse(""));
|
||||
EXPECT_EQ(flow_.categories(), QStringList());
|
||||
EXPECT_EQ(flow_.categories(), QVariantList());
|
||||
EXPECT_EQ(flow_.questions(), QVariantList());
|
||||
}
|
||||
|
||||
@ -105,7 +105,7 @@ TEST_F(BugReportFlowFixture, noFile) {
|
||||
TEST_F(BugReportFlowFixture, emptyFile) {
|
||||
feedTempFile("");
|
||||
EXPECT_TRUE(flow_.parse(file_.fileName()));
|
||||
EXPECT_EQ(flow_.categories(), QStringList());
|
||||
EXPECT_EQ(flow_.categories(), QVariantList());
|
||||
EXPECT_EQ(flow_.questions(), QVariantList());
|
||||
}
|
||||
|
||||
@ -117,10 +117,12 @@ TEST_F(BugReportFlowFixture, validFile) {
|
||||
feedTempFile(goodJson);
|
||||
|
||||
EXPECT_TRUE(flow_.parse(file_.fileName()));
|
||||
QStringList categories = flow_.categories();
|
||||
QVariantList categories = flow_.categories();
|
||||
QVariantList questions = flow_.questions();
|
||||
EXPECT_EQ(categories.count(), 1);
|
||||
EXPECT_EQ(categories[0], "I can't receive mail");
|
||||
QVariantMap cat = categories[0].toMap();
|
||||
EXPECT_EQ(cat["name"].toString(), "I can't receive mail");
|
||||
EXPECT_EQ(cat["hint"].toString(), "");
|
||||
EXPECT_EQ(questions.count(), 1);
|
||||
QVariantMap q1 = questions[0].toMap();
|
||||
EXPECT_EQ(q1.value("id").toInt(), 0);
|
||||
@ -138,7 +140,7 @@ TEST_F(BugReportFlowFixture, validFile) {
|
||||
EXPECT_TRUE(flow_.setAnswer(0, "pwet"));
|
||||
EXPECT_FALSE(flow_.setAnswer(1, "pwet"));
|
||||
|
||||
EXPECT_EQ(flow_.collectAnswers(0), " - 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), "");
|
||||
@ -175,6 +177,6 @@ TEST_F(BugReportFlowFixture, badVersionFile) {
|
||||
"}");
|
||||
|
||||
EXPECT_TRUE(flow_.parse(file_.fileName()));
|
||||
EXPECT_EQ(flow_.categories(), QStringList());
|
||||
EXPECT_EQ(flow_.categories(), QVariantList());
|
||||
EXPECT_EQ(flow_.questions(), QVariantList());
|
||||
}
|
||||
@ -53,7 +53,7 @@ bool BugReportFlow::parse(const QString& filepath) {
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The value for the 'bugCategories' property.
|
||||
//****************************************************************************************************************************************************
|
||||
QStringList BugReportFlow::categories() const {
|
||||
QVariantList BugReportFlow::categories() const {
|
||||
return categories_;
|
||||
}
|
||||
|
||||
@ -98,7 +98,7 @@ bool BugReportFlow::setAnswer(quint8 questionId, QString const &answer) {
|
||||
QString BugReportFlow::getCategory(quint8 categoryId) const {
|
||||
QString category;
|
||||
if (categoryId <= categories_.count() - 1) {
|
||||
category = categories_[categoryId];
|
||||
category = categories_[categoryId].toMap()["name"].toString();
|
||||
}
|
||||
return category;
|
||||
}
|
||||
@ -131,7 +131,7 @@ QString BugReportFlow::collectAnswers(quint8 categoryId) const {
|
||||
const QString& answer = getAnswer(var.toInt());
|
||||
if (answer.isEmpty())
|
||||
continue;
|
||||
answers += " - " + questions_[var.toInt()].toMap()["text"].toString() + "\n\r";
|
||||
answers += " > " + questions_[var.toInt()].toMap()["text"].toString() + "\n\r";
|
||||
answers += answer + "\n\r";
|
||||
}
|
||||
return answers;
|
||||
@ -155,7 +155,10 @@ bool BugReportFlow::parseFile() {
|
||||
QJsonObject data = getJsonDataObj(getJsonRootObj());
|
||||
QJsonArray categoriesJson = data.value("categories").toArray();
|
||||
for (const QJsonValueRef &v : categoriesJson) {
|
||||
categories_.append(v.toObject()["name"].toString());
|
||||
QVariantMap cat;
|
||||
cat["name"] = v.toObject()["name"].toString();
|
||||
cat["hint"] = v.toObject()["hint"].toString();
|
||||
categories_.append(cat);
|
||||
questionsSet_.append(v.toObject()["questions"].toArray().toVariantList());
|
||||
}
|
||||
questions_ = data.value("questions").toArray().toVariantList();
|
||||
|
||||
@ -35,7 +35,7 @@ public: // member functions.
|
||||
|
||||
[[nodiscard]] bool parse(const QString& filepath); ///< Initialize the Bug Report Flow.
|
||||
|
||||
[[nodiscard]] QStringList categories() const; ///< Getter for the 'bugCategories' property.
|
||||
[[nodiscard]] QVariantList 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.
|
||||
@ -55,7 +55,7 @@ private: // member functions
|
||||
|
||||
private: // data members
|
||||
QString filepath_; ///< The file path of the BugReportFlow description file.
|
||||
QStringList categories_; ///< The list of Bug Category parsed from the description file.
|
||||
QVariantList categories_; ///< The list of Bug Category parsed from the description file.
|
||||
QVariantList questions_; ///< The list of Questions parsed from the description file.
|
||||
QList<QVariantList> questionsSet_; ///< Sets of questions per bug category.
|
||||
QMap<quint8, QString> answers_; ///< Map of QuestionId/Answer for the bug form.
|
||||
|
||||
Reference in New Issue
Block a user