Unverified Commit 05b27e32 authored by Ivan Gabriele's avatar Ivan Gabriele Committed by GitHub
Browse files

fix(contrib): non draft answers index (#343)

* contrib/libs/postgrest: make quoted strings optional in eq() method
* contrib/sagas/answers: enforce quoted strings for agreement_idcc eq() in load() function
* readme: update
* contrib/yarn: add coveralls
* travis: push tests coverage data to Coveralls
parent fd39a08b
......@@ -36,7 +36,9 @@ jobs:
script:
- yarn test --coverage --silent
after_script:
# Push the coverage data into Codecov:
# Push tests coverage data to Coveralls:
- ./packages/contrib/node_modules/.bin/coveralls < ./packages/contrib/coverage/lcov.info
# Push tests coverage data to Codecov:
- npx codecov
- stage: Test
......
......@@ -8,6 +8,8 @@
Ce dépôt regroupe les applications d'administration des données du
[code du travail numérique][link-cdtn].
---
## Contribuer au projet
### Pré-requis
......@@ -73,7 +75,7 @@ Pendant le développement, vous pouvez soit tester manuellement :
yarn test:unit
```
ou faire tourner les tests unitaires en continu (ajouter `--coverage` pour
soit faire tourner les tests unitaires en continu (ajouter `--coverage` pour
afficher l'état de couverture des tests) :
```bash
......@@ -82,7 +84,7 @@ yarn test:watch
#### Analyse statique
Vous pouvez éxecuter l'analyse statique du code en exécutant :
Vous pouvez exécuter l'analyse statique du code en exécutant :
```bash
yarn test:lint
......@@ -90,14 +92,14 @@ yarn test:lint
#### Tests de bout en bout
Vous pouvez éxecuter les tests de bout en bout du code en exécutant (votre site
Vous pouvez exécuter les tests de bout en bout du code en exécutant (votre site
doit alors touner localement) :
```bash
yarn test:e2e
```
ou vous pouvez simuler l'exécution des tests bout en bout tels qu'ils sont
Vous pouvez aussi simuler l'exécution des tests bout en bout tels qu'ils sont
exécutés par la CI (en mode production et entièrement docker-isés):
```bash
......@@ -135,17 +137,18 @@ echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo s
Le code source de ce dépôt est distribué sous la
[licence Apache 2.0][link-license].
[link-cdtn]: https://codedutravail.num.social.gouv.fr
---
[img-codacy]: https://img.shields.io/codacy/grade/4c5aebc238b94d3795371b49fa6041de.svg?style=flat-square
[img-codecov]: https://img.shields.io/codecov/c/github/SocialGouv/code-du-travail-backoffice/dev.svg?style=flat-square
[img-gitlab]: https://gitlab.factory.social.gouv.fr/SocialGouv/code-du-travail-backoffice/badges/dev/pipeline.svg?style=flat-square
[img-travis]: https://img.shields.io/travis/SocialGouv/code-du-travail-backoffice/dev.svg?style=flat-square
[link-cdtn]: https://codedutravail.num.social.gouv.fr
[link-codacy]: https://app.codacy.com/project/SocialGouv/code-du-travail-backoffice/dashboard
[link-codecov]: https://codecov.io/gh/SocialGouv/code-du-travail-backoffice
[link-license]: https://github.com/SocialGouv/code-du-travail-backoffice/blob/master/LICENSE
[link-gitlab]: https://gitlab.factory.social.gouv.fr/SocialGouv/code-du-travail-backoffice/pipelines
[link-travis]: https://travis-ci.com/SocialGouv/code-du-travail-backoffice
[link-issue-1]: https://github.com/docker/docker-credential-helpers/issues/103#issuecomment-421822269
[link-issue-2]: https://github.com/facebook/jest/issues/3254#issuecomment-297214395
[link-license]: https://github.com/SocialGouv/code-du-travail-backoffice/blob/master/LICENSE
[link-travis]: https://travis-ci.com/SocialGouv/code-du-travail-backoffice
......@@ -57,6 +57,7 @@
"babel-eslint": "10.0.2",
"babel-jest": "24.8.0",
"babel-plugin-styled-components": "1.10.6",
"coveralls": "3.0.5",
"dotenv": "8.0.0",
"eslint": "6.0.1",
"identity-obj-proxy": "3.0.0",
......
......@@ -24,7 +24,8 @@ describe("lib/postgrest()", () => {
await query
.eq("eqFieldNumber", 123)
.eq("eqFieldString", "A string")
.eq("eqFieldString1", "aString")
.eq("eqFieldString2", "A quoted string", true)
.like("likeField", "Another string")
.ilike("ilikeField", "Yet another string")
.orderBy("ascField")
......@@ -33,7 +34,7 @@ describe("lib/postgrest()", () => {
.get(TEST_PATH);
expect(global.axios.get).toHaveBeenCalledWith(
`${TEST_PATH}?eqFieldNumber=eq.123&eqFieldString=eq."A string"&likeField=like."*Another string*"&ilikeField=ilike."*Yet another string*"&limit=10&offset=10&select=*&order=ascField.asc,descField.desc`,
`${TEST_PATH}?eqFieldNumber=eq.123&eqFieldString1=eq.aString&eqFieldString2=eq."A quoted string"&likeField=like."*Another string*"&ilikeField=ilike."*Yet another string*"&limit=10&offset=10&select=*&order=ascField.asc,descField.desc`,
{}
);
});
......
......@@ -131,13 +131,13 @@ class Postgrest {
return this;
}
eq(column, _value) {
eq(column, _value, areQuotedStrings = false) {
if (typeof _value === "boolean" || _value === null) {
return this.is(column, _value);
}
const isNot = this.isNot ? "not." : "";
const value = typeof _value === "string" ? `"${_value}"` : _value;
const value = areQuotedStrings ? `"${_value}"` : _value;
if (this.isAnd) {
this.ands.push(`${column}.eq.${value}`);
......
......@@ -153,7 +153,7 @@ function* load({ meta: { pageIndex, query, states } }) {
if (!isNaN(query)) {
request = request.or
.eq("agreement_idcc", query.padStart(4, "0"))
.eq("agreement_idcc", query.padStart(4, "0"), true)
.eq("question_index", Number(query));
}
}
......
......@@ -2423,6 +2423,18 @@ cosmiconfig@^5.0.0:
js-yaml "^3.13.1"
parse-json "^4.0.0"
coveralls@3.0.5:
version "3.0.5"
resolved "https://registry.yarnpkg.com/coveralls/-/coveralls-3.0.5.tgz#28d7274c6c9827aa85537eab82d66e7e62d0d527"
integrity sha512-/KD7PGfZv/tjKB6LoW97jzIgFqem0Tu9tZL9/iwBnBd8zkIZp7vT1ZSHNvnr0GSQMV/LTMxUstWg8WcDDUVQKg==
dependencies:
growl "~> 1.10.0"
js-yaml "^3.13.1"
lcov-parse "^0.0.10"
log-driver "^1.2.7"
minimist "^1.2.0"
request "^2.86.0"
create-ecdh@^4.0.0:
version "4.0.3"
resolved "https://registry.yarnpkg.com/create-ecdh/-/create-ecdh-4.0.3.tgz#c9111b6f33045c4697f144787f9254cdc77c45ff"
......@@ -3620,6 +3632,11 @@ graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2:
resolved "https://registry.yarnpkg.com/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725"
integrity sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=
"growl@~> 1.10.0":
version "1.10.5"
resolved "https://registry.yarnpkg.com/growl/-/growl-1.10.5.tgz#f2735dc2283674fa67478b10181059355c369e5e"
integrity sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==
growly@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081"
......@@ -4903,6 +4920,11 @@ lcid@^2.0.0:
dependencies:
invert-kv "^2.0.0"
lcov-parse@^0.0.10:
version "0.0.10"
resolved "https://registry.yarnpkg.com/lcov-parse/-/lcov-parse-0.0.10.tgz#1b0b8ff9ac9c7889250582b70b71315d9da6d9a3"
integrity sha1-GwuP+ayceIklBYK3C3ExXZ2m2aM=
left-pad@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/left-pad/-/left-pad-1.3.0.tgz#5b8a3a7765dfe001261dde915589e782f8c94d1e"
......@@ -5023,6 +5045,11 @@ lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.4, lodash@^4.17.5:
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.14.tgz#9ce487ae66c96254fe20b599f21b6816028078ba"
integrity sha512-mmKYbW3GLuJeX+iGP+Y7Gp1AiGHGbXHCOh/jZmrawMmsE7MS4znI3RL2FsjbqOyMayHInjOeykW7PEajUk1/xw==
log-driver@^1.2.7:
version "1.2.7"
resolved "https://registry.yarnpkg.com/log-driver/-/log-driver-1.2.7.tgz#63b95021f0702fedfa2c9bb0a24e7797d71871d8"
integrity sha512-U7KCmLdqsGHBLeWqYlFA0V0Sl6P08EE1ZrmA9cxjUE0WVqT9qnyVDPz1kzpFEP0jdJuFnasWIfSd7fsaNXkpbg==
loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf"
......@@ -6749,7 +6776,7 @@ request-promise-native@^1.0.5:
stealthy-require "^1.1.1"
tough-cookie "^2.3.3"
request@^2.87.0:
request@^2.86.0, request@^2.87.0:
version "2.88.0"
resolved "https://registry.yarnpkg.com/request/-/request-2.88.0.tgz#9c2fca4f7d35b592efe57c7f0a55e81052124fef"
integrity sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment