Skip to content

Commit

Permalink
fix: terminology update for priority 3 (MAY), passed/failing -> suppo…
Browse files Browse the repository at this point in the history
…rted/unsupported (#1150)

This change does the following:
* Adds migrator for mayFormatted
* Updates UI strings for MAY assertion priorities from 'passed' to 'supported'
  • Loading branch information
stalgiag authored Jul 15, 2024
1 parent 5f44b31 commit 1f61c87
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 2 deletions.
9 changes: 8 additions & 1 deletion client/components/common/TestPlanResultsTable/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ import nextId from 'react-id-generator';
import { getMetrics } from 'shared';
import './TestPlanResultsTable.css';

const getAssertionResultText = (passed, priority) => {
if (priority === 'MAY') {
return passed ? 'Supported' : 'Unsupported';
}
return passed ? 'Passed' : 'Failed';
};

const renderAssertionRow = (assertionResult, priorityString) => {
return (
<tr key={`${assertionResult.id}__${nextId()}`}>
Expand All @@ -16,7 +23,7 @@ const renderAssertionRow = (assertionResult, priorityString) => {
: assertionResult.assertion.text.charAt(0).toUpperCase() +
assertionResult.assertion.text.slice(1)}
</td>
<td>{assertionResult.passed ? 'Passed' : 'Failed'}</td>
<td>{getAssertionResultText(assertionResult.passed, priorityString)}</td>
</tr>
);
};
Expand Down
54 changes: 54 additions & 0 deletions server/migrations/20240711160607-update-may-terminology.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
'use strict';

/** @type {import('sequelize-cli').Migration} */
const updateMetricsTerminology = async (
queryInterface,
Sequelize,
oldTerm,
newTerm
) => {
const [reports] = await queryInterface.sequelize.query(
'SELECT id, metrics FROM "TestPlanReport";'
);

const updatePromises = reports.map(report => {
const { metrics } = report;

if (metrics.mayFormatted) {
metrics.mayFormatted = metrics.mayFormatted.replace(oldTerm, newTerm);
}

return queryInterface.sequelize.query(
'UPDATE "TestPlanReport" SET metrics = :metrics WHERE id = :id',
{
replacements: {
metrics: JSON.stringify(metrics),
id: report.id
},
type: Sequelize.QueryTypes.UPDATE
}
);
});

await Promise.all(updatePromises);
};

module.exports = {
up: async (queryInterface, Sequelize) => {
await updateMetricsTerminology(
queryInterface,
Sequelize,
'passed',
'supported'
);
},

down: async (queryInterface, Sequelize) => {
await updateMetricsTerminology(
queryInterface,
Sequelize,
'supported',
'passed'
);
}
};
2 changes: 1 addition & 1 deletion shared/getMetrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ const getMetrics = ({
const mayFormatted =
mayAssertionsCount === 0
? false
: `${mayAssertionsPassedCount} of ${mayAssertionsCount} passed`;
: `${mayAssertionsPassedCount} of ${mayAssertionsCount} supported`;

const unexpectedBehaviorCount = countUnexpectedBehaviors({ ...result });
const unexpectedBehaviorsFormatted =
Expand Down

0 comments on commit 1f61c87

Please sign in to comment.