Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/ADF-1595/update-lodash-v4 #518

Merged
merged 11 commits into from
Oct 19, 2023
2 changes: 1 addition & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
run: npm run coverage:clover
- name: Report coverage
if: always()
uses: slavcodev/coverage-monitor-action@1.1.0
uses: slavcodev/coverage-monitor-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
clover_file: coverage/clover.xml
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/release-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Release NPM package

on:
pull_request:
branches:
- develop
types: [closed]

jobs:
auto-release:
if: github.event.pull_request.merged == true
name: Automated package release
runs-on: ubuntu-latest

steps:
- name: Clone the repository
uses: actions/checkout@v3
with:
fetch-depth: 0 #avoid unrelated history error
token: ${{ secrets.SEMVER_GH_TOKEN }} #bypass branch protection rule

- name: Configure git user
#configuring git for runner
run: |
git config --global user.name "oat-github-bot"
git config --global user.email "oat-github-bot@taotesting.com"

- name: Install and apply the release tool
env:
GITHUB_TOKEN: ${{ secrets.SEMVER_GH_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.CI_NPM_RELEASE_TOKEN }}
run: |
# setup the place
npm config set //registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}
npm i -g @oat-sa/tao-extension-release
# install the package
npm ci
#create tag and release a new version
taoRelease npmRelease --release-branch master --no-interactive
64 changes: 30 additions & 34 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@
"@oat-sa/eslint-config-tao": "^2.0.0",
"@oat-sa/prettier-config": "^0.1.1",
"@oat-sa/rollup-plugin-wildcard-external": "^1.0.0",
"@oat-sa/tao-core-libs": "^0.5.3",
"@oat-sa/tao-core-sdk": "^2.0.1",
"@oat-sa/tao-core-ui": "^2.0.0",
"@oat-sa/tao-item-runner": "^0.8.2",
"@oat-sa/tao-item-runner-qti": "^1.11.1",
"@oat-sa/tao-core-libs": "^1.0.0",
"@oat-sa/tao-core-sdk": "^3.0.0",
"@oat-sa/tao-core-ui": "^3.0.1",
"@oat-sa/tao-item-runner": "^1.0.0",
"@oat-sa/tao-item-runner-qti": "^2.0.1",
"@oat-sa/tao-qunit-testrunner": "^2.0.0",
"@oat-sa/tao-test-runner": "^0.9.1",
"@oat-sa/tao-test-runner": "^1.0.0",
"async": "0.2.10",
"autoprefixer": "^10.4.14",
"dompurify": "^2.4.0",
Expand All @@ -76,7 +76,7 @@
"jquery": "1.9.1",
"jquery-mockjax": "^2.5.0",
"jquery-simulate": "^1.0.2",
"lodash": "2.4.1",
"lodash": "^4.17.21",
"moment": "^2.29.4",
"moment-timezone": "^0.5.43",
"nyc": "^15.1.0",
Expand Down
5 changes: 2 additions & 3 deletions src/branchRule/types/match.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
/**
* @author Péter Halász <peter@taotesting.com>
*/
import _ from 'lodash';

/**
* MATCH branching rule
Expand Down Expand Up @@ -48,8 +47,8 @@ export default function matchBranchRuleFactory(
return Promise.all([
responseStore.getCorrectResponse(correctIdentifier),
responseStore.getResponse(variableIdentifier)
]).then(function(result) {
return _.contains(result[0], result[1]);
]).then(function (result) {
return result[0].includes(result[1]);
});
}
};
Expand Down
27 changes: 11 additions & 16 deletions src/helpers/currentItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ var currentItemHelper = {
*/
getResponseDeclaration: function getResponseDeclaration(runner, identifier) {
var found = null;
_.forEach(currentItemHelper.getDeclarations(runner), function(declaration) {
_.forEach(currentItemHelper.getDeclarations(runner), function (declaration) {
var attributes = declaration.attributes || {};
if (attributes.identifier === identifier) {
found = declaration;
Expand Down Expand Up @@ -100,9 +100,9 @@ var currentItemHelper = {
if (baseType === 'boolean') {
transform = v => v === true || v === 'true';
} else if (baseType === 'integer') {
transform = v => typeof v === 'number' ? v : parseInt(v);
transform = v => (typeof v === 'number' ? v : parseInt(v));
} else if (baseType === 'float') {
transform = v => typeof v === 'number' ? v : parseFloat(v);
transform = v => (typeof v === 'number' ? v : parseFloat(v));
} else if (baseType === 'directedPair' || baseType === 'pair') {
transform = v => {
if (_.isString(v)) {
Expand Down Expand Up @@ -155,11 +155,7 @@ var currentItemHelper = {

const stringyValue = 'string' === baseType || 'integer' === baseType || 'float' === baseType;

return (
null === value ||
(stringyValue && value === '') ||
(cardinality !== 'single' && _.isEmpty(value))
);
return null === value || (stringyValue && value === '') || (cardinality !== 'single' && _.isEmpty(value));
},

/**
Expand Down Expand Up @@ -200,7 +196,7 @@ var currentItemHelper = {

var constraintValues = {};

_.forEach(interactions, function(interaction) {
_.forEach(interactions, function (interaction) {
var attributes = interaction.attributes || {};
var qtiClass = interaction.__proto__.qtiClass;
var constraintProperty;
Expand Down Expand Up @@ -233,7 +229,7 @@ var currentItemHelper = {
declarations = currentItemHelper.getDeclarations(runner);
constraintValues = currentItemHelper.guessInteractionConstraintValues(runner);

_.forEach(declarations, function(declaration) {
_.forEach(declarations, function (declaration) {
var attributes = declaration.attributes || {};
var response = responses[attributes.identifier];
var baseType = attributes.baseType;
Expand Down Expand Up @@ -272,12 +268,11 @@ var currentItemHelper = {

return _(interactions)
.values()
.filter(function(element) {
.filter(function (element) {
return element.qtiClass === 'include';
})
.pluck('attributes')
.pluck('href')
.value();
.value()
.map(val => (val.attributes ? val.attributes.href : null));
},

/**
Expand All @@ -291,9 +286,9 @@ var currentItemHelper = {
var textStimuli;
if (stimuli.length > 0) {
// Filter the ones containing text:
textStimuli = stimuli.filter(function(stimulusHref) {
textStimuli = stimuli.filter(function (stimulusHref) {
var domNode = document.querySelector(`.qti-include[data-href="${stimulusHref}"]`);
return _(domNode.childNodes).some(function(child) {
return _(domNode.childNodes).some(function (child) {
return child.nodeType === child.TEXT_NODE;
});
});
Expand Down
14 changes: 3 additions & 11 deletions src/navigator/navigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import testContextBuilder from 'taoQtiTest/runner/helpers/testContextBuilder';
* @throws {TypeError} if the given parameters aren't objects
*/
var navigatorFactory = function navigatorFactory(testContext, testMap) {
if (!_.all([testContext, testMap], _.isPlainObject)) {
if (![testContext, testMap].every(_.isPlainObject)) {
throw new TypeError('The navigator must be built with a testData, a testContext and a testMap');
}

Expand All @@ -64,23 +64,15 @@ var navigatorFactory = function navigatorFactory(testContext, testMap) {
* @returns {Object} the new test context
*/
nextItem: function nextItem() {
return testContextBuilder.buildTestContextFromPosition(
testContext,
testMap,
testContext.itemPosition + 1
);
return testContextBuilder.buildTestContextFromPosition(testContext, testMap, testContext.itemPosition + 1);
},

/**
* Navigate to the next item
* @returns {Object} the new test context
*/
previousItem: function previsousItem() {
return testContextBuilder.buildTestContextFromPosition(
testContext,
testMap,
testContext.itemPosition - 1
);
return testContextBuilder.buildTestContextFromPosition(testContext, testMap, testContext.itemPosition - 1);
},

/**
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/controls/timer/strategy/strategyHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ export default function getStrategyHandler(testRunner, strategies) {
*/
var applyToStrategies = function applyToStrategies(timerId, action) {
var api = _.keys(strategyHandler);
if (_.isEmpty(timerId) || _.isEmpty(action) || !_.contains(api, action)) {
if (_.isEmpty(timerId) || _.isEmpty(action) || !api.includes(action)) {
throw new TypeError('Invalid timer id or unauthorized action');
}

if (!_.isArray(actives[timerId])) {
return Promise.resolve();
}
return Promise.all(
_.map(actives[timerId], function(strategy) {
_.map(actives[timerId], function (strategy) {
if (_.isFunction(strategy[action])) {
return strategy[action]();
}
Expand All @@ -96,7 +96,7 @@ export default function getStrategyHandler(testRunner, strategies) {
* @returns {Promise} resolves once the set up is done
*/
setUp: function setUp(timer) {
_.forEach(availableStrategies, function(availableStrategy) {
_.forEach(availableStrategies, function (availableStrategy) {
var strategy = availableStrategy(testRunner, timer);
if (strategy !== false) {
actives[timer.id] = actives[timer.id] || [];
Expand Down Expand Up @@ -152,7 +152,7 @@ export default function getStrategyHandler(testRunner, strategies) {
* @returns {Promise}
*/
tearDown: function tearDown(timer) {
return applyToStrategies(timer.id, 'tearDown').then(function() {
return applyToStrategies(timer.id, 'tearDown').then(function () {
actives = _.omit(actives, timer.id);
});
}
Expand Down
Loading
Loading