Skip to content
Permalink
Browse files

fix(multilang): remove country code for translations

  • Loading branch information...
anehx committed Aug 12, 2019
1 parent 274405b commit 17725910de339182866ed2e5d84d2b3f5aa2707e
@@ -7,7 +7,7 @@ import { setupIntl } from "ember-intl/test-support";
module("Acceptance | navigation", function(hooks) {
setupApplicationTest(hooks);
setupMirage(hooks);
setupIntl(hooks, "en-us");
setupIntl(hooks);

hooks.beforeEach(function() {
this.server.create("form", {
@@ -13,7 +13,7 @@ export default Route.extend(RouteQueryManager, {
init() {
this._super(...arguments);

this.intl.setLocale([...navigator.languages, "en-us"]);
this.intl.setLocale([...navigator.languages, "en"]);

if (ENV.environment !== "production") {
this.calumaOptions.registerComponentOverride({
@@ -4,10 +4,12 @@ import { render, fillIn } from "@ember/test-helpers";
import hbs from "htmlbars-inline-precompile";
import Document from "ember-caluma/lib/document";
import setupMirage from "ember-cli-mirage/test-support/setup-mirage";
import { setupIntl } from "ember-intl/test-support";

module("Integration | Component | cf-field", function(hooks) {
setupRenderingTest(hooks);
setupMirage(hooks);
setupIntl(hooks);

hooks.beforeEach(function() {
this.validator = this.server.create("format-validator", {
@@ -109,7 +111,7 @@ module("Integration | Component | cf-field", function(hooks) {

assert
.dom("span.validation-errors")
.hasText("The value of this field can't be longer than 2 characters");
.hasText('t:caluma.form.validation.tooLong:("max":2,"value":"Test")');
});

test("it hides the label", async function(assert) {
@@ -127,7 +129,11 @@ module("Integration | Component | cf-field", function(hooks) {

await fillIn("input", "Test");

assert.dom("span.validation-errors").hasText(this.validator.errorMsg);
assert
.dom("span.validation-errors")
.hasText(
`t:caluma.form.validation.format:("errorMsg":"${this.validator.errorMsg}","value":"Test")`
);
});

test("it saves the valid email address", async function(assert) {
@@ -4,9 +4,11 @@ import { render } from "@ember/test-helpers";
import hbs from "htmlbars-inline-precompile";
import Document from "ember-caluma/lib/document";
import ValidatorServiceStub from "dummy/tests/helpers/validator-service-stub";
import { setupIntl } from "ember-intl/test-support";

module("Integration | Component | cf-field/label", function(hooks) {
setupRenderingTest(hooks);
setupIntl(hooks);

hooks.beforeEach(function() {
this.owner.register("service:validator", ValidatorServiceStub);
@@ -55,6 +57,6 @@ module("Integration | Component | cf-field/label", function(hooks) {

this.set("field.question.isRequired", "false");

assert.dom("label").hasText("Test (Optional)");
assert.dom("label").hasText("Test (t:caluma.form.optional:())");
});
});
@@ -4,10 +4,12 @@ import { render, click, fillIn, blur, settled } from "@ember/test-helpers";
import hbs from "htmlbars-inline-precompile";
import { setupMirage } from "ember-cli-mirage/test-support";
import graphqlError from "dummy/tests/helpers/graphql-error";
import { setupIntl } from "ember-intl/test-support";

module("Integration | Component | cfb-form-editor/general", function(hooks) {
setupRenderingTest(hooks);
setupMirage(hooks);
setupIntl(hooks);

test("it renders", async function(assert) {
assert.expect(4);
@@ -177,7 +179,9 @@ module("Integration | Component | cfb-form-editor/general", function(hooks) {

await render(hbs`{{cfb-form-editor/general slug='test-slug'}}`);

assert.dom("p").hasText("No form with slug 'test-slug' found");
assert
.dom("p")
.hasText('t:caluma.form-builder.form.not-found:("slug":"test-slug")');
});

test("it validates the slug", async function(assert) {
@@ -194,7 +198,7 @@ module("Integration | Component | cfb-form-editor/general", function(hooks) {

assert
.dom("input[name=slug] + span")
.hasText("A form with this slug already exists");
.hasText("t:caluma.form-builder.validations.form.slug:()");

await fillIn("input[name=slug]", "valid-slug");
await blur("input[name=slug]");
@@ -209,6 +213,6 @@ module("Integration | Component | cfb-form-editor/general", function(hooks) {

assert
.dom("input[name=slug] + span")
.hasText("A form with this slug already exists");
.hasText("t:caluma.form-builder.validations.form.slug:()");
});
});
@@ -4,12 +4,14 @@ import { render, click, find, fillIn, triggerEvent } from "@ember/test-helpers";
import hbs from "htmlbars-inline-precompile";
import { setupMirage } from "ember-cli-mirage/test-support";
import graphqlError from "dummy/tests/helpers/graphql-error";
import { setupIntl } from "ember-intl/test-support";

module("Integration | Component | cfb-form-editor/question-list", function(
hooks
) {
setupRenderingTest(hooks);
setupMirage(hooks);
setupIntl(hooks);

hooks.beforeEach(function() {
this.form = this.server.create("form", {
@@ -41,21 +43,19 @@ module("Integration | Component | cfb-form-editor/question-list", function(
assert.dom("[data-test-question-list-empty]").exists();
assert
.dom("[data-test-question-list-empty]")
.hasText(
"You have not yet added a question. Press the plus button above to do so!"
);
.hasText("t:caluma.form-builder.question.empty:()");

this.set("mode", "add");
await fillIn("input[type=search]", "thisslugisveryunlikelytoexist");
assert
.dom("[data-test-question-list-empty]")
.hasText("No results found. Adjust your search to get better results.");
.hasText("t:caluma.form-builder.global.empty-search:()");

this.set("mode", "remove");
await fillIn("input[type=search]", "thisslugisveryunlikelytoexist");
assert
.dom("[data-test-question-list-empty]")
.hasText("No results found. Adjust your search to get better results.");
.hasText("t:caluma.form-builder.global.empty-search:()");
});

test("it can reorder questions", async function(assert) {
@@ -2,11 +2,13 @@ import { module, test } from "qunit";
import { setupRenderingTest } from "ember-qunit";
import { render, settled } from "@ember/test-helpers";
import hbs from "htmlbars-inline-precompile";
import { setupIntl } from "ember-intl/test-support";

module("Integration | Component | cfb-form-editor/question-list/item", function(
hooks
) {
setupRenderingTest(hooks);
setupIntl(hooks);

test("it renders", async function(assert) {
assert.expect(6);
@@ -24,7 +26,11 @@ module("Integration | Component | cfb-form-editor/question-list/item", function(
{{cfb-form-editor/question-list/item question=question mode=mode}}
`);

assert.dom("li").hasText("test-question Test Question? Text");
assert
.dom("li")
.hasText(
"test-question Test Question? t:caluma.form-builder.question.types.TextQuestion:()"
);
assert.dom(".cfb-form-editor__question-list__item__required").exists();

this.set("question.isRequired", "false");
@@ -5,10 +5,12 @@ import hbs from "htmlbars-inline-precompile";
import { setupMirage } from "ember-cli-mirage/test-support";
import graphqlError from "dummy/tests/helpers/graphql-error";
import { selectChoose } from "ember-power-select/test-support";
import { setupIntl } from "ember-intl/test-support";

module("Integration | Component | cfb-form-editor/question", function(hooks) {
setupRenderingTest(hooks);
setupMirage(hooks);
setupIntl(hooks);

hooks.beforeEach(function() {
this.server.create("format-validator", { slug: "email" });
@@ -136,7 +138,9 @@ module("Integration | Component | cfb-form-editor/question", function(hooks) {

await render(hbs`{{cfb-form-editor/question slug='test-slug'}}`);

assert.dom("p").hasText("No question with slug 'test-slug' found");
assert
.dom("p")
.hasText('t:caluma.form-builder.question.not-found:("slug":"test-slug")');
});

test("it suggests a slug", async function(assert) {
@@ -477,7 +481,7 @@ module("Integration | Component | cfb-form-editor/question", function(hooks) {

assert
.dom("input[name=slug] + span")
.hasText("A question with this slug already exists");
.hasText("t:caluma.form-builder.validations.question.slug:()");

await fillIn("input[name=slug]", "valid-slug");
await blur("input[name=slug]");
@@ -491,7 +495,7 @@ module("Integration | Component | cfb-form-editor/question", function(hooks) {

assert
.dom("input[name=slug] + span")
.hasText("A question with this slug already exists");
.hasText("t:caluma.form-builder.validations.question.slug:()");
});

test("it auto-suggests the slug if it has not been manually changed", async function(assert) {
@@ -2,9 +2,11 @@ import { module, test } from "qunit";
import { setupRenderingTest } from "ember-qunit";
import { render } from "@ember/test-helpers";
import hbs from "htmlbars-inline-precompile";
import { setupIntl } from "ember-intl/test-support";

module("Integration | Component | cfb-label", function(hooks) {
setupRenderingTest(hooks);
setupIntl(hooks);

test("it renders", async function(assert) {
assert.expect(3);
@@ -17,7 +19,11 @@ module("Integration | Component | cfb-label", function(hooks) {

this.set("required", false);

assert.dom("label").hasText("Test (Optional)");
assert.dom("span.uk-text-muted.uk-text-lowercase").hasText("(Optional)");
assert
.dom("label")
.hasText("Test (t:caluma.form-builder.global.optional:())");
assert
.dom("span.uk-text-muted.uk-text-lowercase")
.hasText("(t:caluma.form-builder.global.optional:())");
});
});
@@ -2,14 +2,16 @@ import { module, test } from "qunit";
import { setupRenderingTest } from "ember-qunit";
import { render } from "@ember/test-helpers";
import hbs from "htmlbars-inline-precompile";
import { setupIntl } from "ember-intl/test-support";

module("Integration | Component | cfb-loading-dots", function(hooks) {
setupRenderingTest(hooks);
setupIntl(hooks);

test("it renders", async function(assert) {
await render(hbs`{{cfb-loading-dots}}`);

assert.dom("span").hasText("Loading...");
assert.dom("span").hasText("t:caluma.form-builder.global.loading:()...");

await render(hbs`{{#cfb-loading-dots}}Test{{/cfb-loading-dots}}`);

@@ -4,9 +4,11 @@ import { settled } from "@ember/test-helpers";
import Field from "ember-caluma/lib/field";
import Document from "ember-caluma/lib/document";
import ValidatorServiceStub from "dummy/tests/helpers/validator-service-stub";
import { setupIntl } from "ember-intl/test-support";

module("Unit | Library | field", function(hooks) {
setupTest(hooks);
setupIntl(hooks);

hooks.beforeEach(async function() {
this.owner.register("service:validator", ValidatorServiceStub);
@@ -194,7 +196,9 @@ module("Unit | Library | field", function(hooks) {
});

await field.validate.perform();
assert.deepEqual(field.errors, ["This field can't be blank"]);
assert.deepEqual(field.errors, [
't:caluma.form.validation.blank:("presence":true,"value":"")'
]);
});

test("it ignores optional fields", async function(assert) {
@@ -238,7 +242,7 @@ module("Unit | Library | field", function(hooks) {
field.set("answer.value", "Testx");
await field.validate.perform();
assert.deepEqual(field.errors, [
"The value of this field can't be longer than 4 characters"
't:caluma.form.validation.tooLong:("max":4,"value":"Testx")'
]);
});

@@ -264,7 +268,7 @@ module("Unit | Library | field", function(hooks) {
field.set("answer.value", "Testx");
await field.validate.perform();
assert.deepEqual(field.errors, [
"The value of this field can't be longer than 4 characters"
't:caluma.form.validation.tooLong:("max":4,"value":"Testx")'
]);
});

@@ -291,19 +295,19 @@ module("Unit | Library | field", function(hooks) {
field.set("answer.integerValue", 1);
await field.validate.perform();
assert.deepEqual(field.errors, [
"The value of this field must be greater than or equal to 2"
't:caluma.form.validation.greaterThanOrEqualTo:("gte":2,"integer":true,"lte":2,"value":1)'
]);

field.set("answer.integerValue", 3);
await field.validate.perform();
assert.deepEqual(field.errors, [
"The value of this field must be less than or equal to 2"
't:caluma.form.validation.lessThanOrEqualTo:("gte":2,"integer":true,"lte":2,"value":3)'
]);

field.set("answer.integerValue", 1.5);
await field.validate.perform();
assert.deepEqual(field.errors, [
"The value of this field must be an integer"
't:caluma.form.validation.notAnInteger:("gte":2,"integer":true,"lte":2,"value":1.5)'
]);
});

@@ -334,14 +338,14 @@ module("Unit | Library | field", function(hooks) {

await field.validate.perform();
assert.deepEqual(field.errors, [
"The value of this field must be greater than or equal to 1.5"
't:caluma.form.validation.greaterThanOrEqualTo:("gte":1.5,"lte":2.5,"value":1.4)'
]);

field.set("answer.floatValue", 2.6);

await field.validate.perform();
assert.deepEqual(field.errors, [
"The value of this field must be less than or equal to 2.5"
't:caluma.form.validation.lessThanOrEqualTo:("gte":1.5,"lte":2.5,"value":2.6)'
]);
});

@@ -375,7 +379,7 @@ module("Unit | Library | field", function(hooks) {
field.set("answer.value", "invalid-option");
await field.validate.perform();
assert.deepEqual(field.errors, [
"'invalid-option' is not a valid value for this field"
't:caluma.form.validation.inclusion:("allowBlank":true,"in":["option-1"],"value":"invalid-option")'
]);
});

@@ -409,14 +413,14 @@ module("Unit | Library | field", function(hooks) {
field.set("answer.listValue", ["option-1", "invalid-option"]);
await field.validate.perform();
assert.deepEqual(field.errors, [
"'invalid-option' is not a valid value for this field"
't:caluma.form.validation.inclusion:("in":["option-1"],"value":"invalid-option")'
]);

field.set("answer.listValue", ["invalid-option", "other-invalid-option"]);
await field.validate.perform();
assert.deepEqual(field.errors, [
"'invalid-option' is not a valid value for this field",
"'other-invalid-option' is not a valid value for this field"
't:caluma.form.validation.inclusion:("in":["option-1"],"value":"invalid-option")',
't:caluma.form.validation.inclusion:("in":["option-1"],"value":"other-invalid-option")'
]);
});
});
File renamed without changes.
File renamed without changes.

0 comments on commit 1772591

Please sign in to comment.
You can’t perform that action at this time.