From 44ba3290d20589c181e5fcbaf377f9cb54af7aaa Mon Sep 17 00:00:00 2001 From: Dmitry Romashov Date: Tue, 16 Apr 2019 18:35:32 +0300 Subject: [PATCH] autocompletion turn off (#16) * add webvisor * remove ya metrica in dev env * disable calc button if there is only one person * remove unused code * add tests * #6 fix backend error * fix #6 * #10 add healthcheck * add production config, please close #10 * fix healtcheck * add serilog and sentry, #9, #8; webvison 2; * update release version for Sentry * update manifest.json for mobile version * close #9; close #8; * add keywords for yandex search * Bug/case (#14) * catch corner case * ignore IDE files for Client app * Add tests for #12. Close #12 * remove unused code * remove unused file. Close #12 * Remove autocomplete, change Input to TextField * Update release version --- Izzy.Web/Client/.gitignore | 3 + Izzy.Web/Client/public/index.html | 18 +-- .../Client/src/__tests__/Calculator.spec.tsx | 2 +- .../Client/src/__tests__/Outcomes.spec.tsx | 56 ++++++++++ .../Client/src/components/incomes/Incomes.tsx | 7 +- .../src/components/outcomes/Transfers.tsx | 30 +++-- Izzy.Web/Program.cs | 104 +++++++++--------- base_path_solution.txt | 2 - 8 files changed, 140 insertions(+), 82 deletions(-) create mode 100644 Izzy.Web/Client/src/__tests__/Outcomes.spec.tsx delete mode 100644 base_path_solution.txt diff --git a/Izzy.Web/Client/.gitignore b/Izzy.Web/Client/.gitignore index 4d29575..9aafd65 100755 --- a/Izzy.Web/Client/.gitignore +++ b/Izzy.Web/Client/.gitignore @@ -21,3 +21,6 @@ npm-debug.log* yarn-debug.log* yarn-error.log* + +# IDE files +.idea/* diff --git a/Izzy.Web/Client/public/index.html b/Izzy.Web/Client/public/index.html index 34edb6c..991e772 100755 --- a/Izzy.Web/Client/public/index.html +++ b/Izzy.Web/Client/public/index.html @@ -7,21 +7,9 @@ name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> - - - - + + + Izzy - калькулятор для вечеринок diff --git a/Izzy.Web/Client/src/__tests__/Calculator.spec.tsx b/Izzy.Web/Client/src/__tests__/Calculator.spec.tsx index c0f0436..42da27a 100644 --- a/Izzy.Web/Client/src/__tests__/Calculator.spec.tsx +++ b/Izzy.Web/Client/src/__tests__/Calculator.spec.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; import { Provider } from 'react-redux'; -import { shallow, mount, ReactWrapper } from 'enzyme'; +import { mount, ReactWrapper } from 'enzyme'; import moxios from 'moxios'; import configureStore from '../store/configureStore'; diff --git a/Izzy.Web/Client/src/__tests__/Outcomes.spec.tsx b/Izzy.Web/Client/src/__tests__/Outcomes.spec.tsx new file mode 100644 index 0000000..390b4df --- /dev/null +++ b/Izzy.Web/Client/src/__tests__/Outcomes.spec.tsx @@ -0,0 +1,56 @@ +import * as React from 'react'; +import { mount, ReactWrapper } from 'enzyme'; +import { Outcomes } from '../components/outcomes/Outcomes'; + +describe('', () => { + let component: ReactWrapper; + + afterEach(() => { + component.unmount(); + }); + + it('"Я" should be transform to "Мне"', done => { + // Arrange + const transfers: any[] = [ + { from: 'Алиса', to: 'Я', roubles: 1 } + ]; + + // Act + component = mount(); + + // Assert + const toCell = component.find('#to1').hostNodes(); + expect(toCell.text()).toEqual('Мне'); + done(); + }); + + it('"я" should be transform to "яне"', done => { + // Arrange + const transfers: any[] = [ + { from: 'Алиса', to: 'я', roubles: 1 } + ]; + + // Act + component = mount(); + + // Assert + const toCell = component.find('#to1').hostNodes(); + expect(toCell.text()).toEqual('мне'); + done(); + }); + + it('"Боб" should be transform to "Бобу"', done => { + // Arrange + const transfers: any[] = [ + { from: 'Алиса', to: 'Боб', roubles: 1 } + ]; + + // Act + component = mount(); + + // Assert + const toCell = component.find('#to1').hostNodes(); + expect(toCell.text()).toEqual('Бобу'); + done(); + }); +}); diff --git a/Izzy.Web/Client/src/components/incomes/Incomes.tsx b/Izzy.Web/Client/src/components/incomes/Incomes.tsx index b97a6b1..56872d6 100644 --- a/Izzy.Web/Client/src/components/incomes/Incomes.tsx +++ b/Izzy.Web/Client/src/components/incomes/Incomes.tsx @@ -36,10 +36,11 @@ export class Incomes extends Component { ) => ( - { field.onChange(event) form.setFieldValue(`persons.${index}.name`, event.target.value) @@ -51,10 +52,12 @@ export class Incomes extends Component { ) => ( - { field.onChange(event) form.setFieldValue(`persons.${index}.roubles`, event.target.value) diff --git a/Izzy.Web/Client/src/components/outcomes/Transfers.tsx b/Izzy.Web/Client/src/components/outcomes/Transfers.tsx index 2f50db8..d3f8358 100644 --- a/Izzy.Web/Client/src/components/outcomes/Transfers.tsx +++ b/Izzy.Web/Client/src/components/outcomes/Transfers.tsx @@ -3,15 +3,25 @@ import TableCell from '@material-ui/core/TableCell'; import TableRow from '@material-ui/core/TableRow'; const petrovich = require('petrovich'); -export class Transfers extends Component { - destInPropriateCase(dest: string): string { - const first = dest.trim().split(' ')[0]; - const person = { gender: 'male', first }; - const result = petrovich(person, 'dative').first; - const withoutFirst = dest.replace(first, ''); - return result + withoutFirst; +function destInPropriateCase(dest: string): string { + const first = dest.trim().split(' ')[0]; + const result = conjugateToDativeCase(first); + const withoutFirst = dest.replace(first, ''); + return result + withoutFirst; +} + +function conjugateToDativeCase(origin: string): string { + if (origin === 'Я') { + return 'Мне'; } + if (origin === 'я') { + return 'мне'; + } + const person = { gender: 'male', first: origin }; + return petrovich(person, 'dative').first; +} +export class Transfers extends Component { render() { const { src } = this.props; let inputs = []; @@ -19,9 +29,9 @@ export class Transfers extends Component { for (const tr of src) { inputs.push( - {tr.from} - {this.destInPropriateCase(tr.to)} - {tr.roubles} + {tr.from} + {destInPropriateCase(tr.to)} + {tr.roubles} ) } diff --git a/Izzy.Web/Program.cs b/Izzy.Web/Program.cs index cb1b767..7d923a6 100644 --- a/Izzy.Web/Program.cs +++ b/Izzy.Web/Program.cs @@ -1,52 +1,52 @@ -using System; -using System.IO; -using System.Net; -using Microsoft.AspNetCore; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Sentry; -using Serilog; -using Serilog.Events; -using Serilog.Formatting.Compact; - -namespace Izzy.Web -{ - public class Program - { - public static void Main(string[] args) - { - CreateWebHostBuilder(args).Build().Run(); - } - - private static IWebHostBuilder CreateWebHostBuilder(string[] args) => - WebHost.CreateDefaultBuilder(args) - .UseStartup() - .UseUrls("http://0.0.0.0:5000") - .UseSerilog((h, c) => - c.Enrich.FromLogContext() - .MinimumLevel.Warning() - .MinimumLevel.Override("Izzy.Web", LogEventLevel.Information) - .WriteTo.ColoredConsole() - .WriteTo.Sentry(s => - { - s.MinimumBreadcrumbLevel = LogEventLevel.Debug; - s.MinimumEventLevel = LogEventLevel.Error; - - }) - ) - .UseSentry(options => - { - options.Release = "1.0.5"; - options.Environment = CurrentEnv(); - options.MaxQueueItems = 100; - options.ShutdownTimeout = TimeSpan.FromSeconds(5); - options.DecompressionMethods = DecompressionMethods.None; - }) - ; - - private static String CurrentEnv() - { - return Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Production"; - } - } -} +using System; +using System.IO; +using System.Net; +using Microsoft.AspNetCore; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Sentry; +using Serilog; +using Serilog.Events; +using Serilog.Formatting.Compact; + +namespace Izzy.Web +{ + public class Program + { + public static void Main(string[] args) + { + CreateWebHostBuilder(args).Build().Run(); + } + + private static IWebHostBuilder CreateWebHostBuilder(string[] args) => + WebHost.CreateDefaultBuilder(args) + .UseStartup() + .UseUrls("http://0.0.0.0:5000") + .UseSerilog((h, c) => + c.Enrich.FromLogContext() + .MinimumLevel.Warning() + .MinimumLevel.Override("Izzy.Web", LogEventLevel.Information) + .WriteTo.ColoredConsole() + .WriteTo.Sentry(s => + { + s.MinimumBreadcrumbLevel = LogEventLevel.Debug; + s.MinimumEventLevel = LogEventLevel.Error; + + }) + ) + .UseSentry(options => + { + options.Release = "1.0.6"; + options.Environment = CurrentEnv(); + options.MaxQueueItems = 100; + options.ShutdownTimeout = TimeSpan.FromSeconds(5); + options.DecompressionMethods = DecompressionMethods.None; + }) + ; + + private static String CurrentEnv() + { + return Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Production"; + } + } +} diff --git a/base_path_solution.txt b/base_path_solution.txt deleted file mode 100644 index b30c7fe..0000000 --- a/base_path_solution.txt +++ /dev/null @@ -1,2 +0,0 @@ -DOTNET_RUNNING_IN_CONTAINER=true -perl -pi -e 's/%IZZY_BASE_PATH%/$IZZY_BASE_PATH/g' Izzy.Web/Client/public/index.html