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(kit): Date, DateTime, DateRange supports strict and non-strict modes #1218

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ff694ee
feat(kit): added strict mode for min-max-date-postprocessor
KrollikRoddzer Apr 26, 2024
da6847b
feat(kit): added strcit for date, date-range, changed for min-max str…
KrollikRoddzer Apr 26, 2024
6f0c16e
feat(kit): added strict mode for min-max-date-time-postprocessor, and…
KrollikRoddzer Apr 26, 2024
a18f3f4
feat(kit): general logic is moved to a separate function
KrollikRoddzer Apr 26, 2024
36fa0e9
refactor(kit): applied general logic function
KrollikRoddzer Apr 26, 2024
35de222
docs(demo): added strict to docs api date, date-time, date-range
KrollikRoddzer Apr 26, 2024
c5491df
feat(kit): created Date and DateTime segments validation postprocessors
KrollikRoddzer Apr 29, 2024
dca1e68
refactor(kit): removed date validation logic from min-max-date-time-p…
KrollikRoddzer Apr 29, 2024
258d189
refactor(kit): removed date validation logic from min-max-date-postpr…
KrollikRoddzer Apr 29, 2024
1b195c5
feat(kit): applied new logic for date-time, date, date-range
KrollikRoddzer Apr 29, 2024
53e8f23
refactor(kit): min-max-date and date-time postprocessors
KrollikRoddzer Apr 30, 2024
7bcdf60
chore: apply changes after linting [bot]
taiga-family-bot Apr 30, 2024
13eae3c
test(demo-integrations): date-strict-mode
KrollikRoddzer Apr 30, 2024
02f217b
test(demo-integrations): date-range-strict-mode
KrollikRoddzer Apr 30, 2024
a27e4d1
test(demo-integrations): date-time-strict-mode
KrollikRoddzer Apr 30, 2024
c5cfedb
refactor(demo): api
KrollikRoddzer Apr 30, 2024
20b6875
docs(demo): added docs for strict mode in date
KrollikRoddzer May 2, 2024
9c52959
docs(demo): added strict mode doc for date range
KrollikRoddzer May 2, 2024
3aaa13c
docs(demo): added docs for strict mode in datetime
KrollikRoddzer May 2, 2024
bb26ad8
docs(demo): added default values for date-time and date-range in api
KrollikRoddzer May 2, 2024
3aba490
test(demo-integrations): refactored
KrollikRoddzer May 3, 2024
9541993
test(demo-integrations): created tests for enabled strict mode
KrollikRoddzer May 3, 2024
46155dd
refactor(demo): removed min-max from strict
KrollikRoddzer May 3, 2024
fdd783c
docs(demo-integrations): moved strict mode description into separate …
KrollikRoddzer May 3, 2024
cd74e26
refactor(kit): refactored validation processors
KrollikRoddzer May 11, 2024
8e5bf0e
docs(demo): added description for strict mode
KrollikRoddzer May 11, 2024
ed4d917
docs(demo): added full description for strict mode
KrollikRoddzer May 11, 2024
c2b166b
refactor(demo): renamed folder
KrollikRoddzer May 11, 2024
978c3fd
refactor(kit): strictdateTimeModeValidation
KrollikRoddzer May 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
import {DemoPath} from '@demo/constants';

describe('DateRange | Strict mode', () => {
describe('Disabled', () => {
describe("doesn't fix wrong dates", () => {
beforeEach(() => {
cy.visit(`/${DemoPath.DateRange}/API?strict=false`);
cy.get('#demo-content input')
.should('be.visible')
.first()
.focus()
.as('input');
});

it('30.02.2004 => 30.02.2004 - 31.02.2004', () => {
cy.get('@input')
.type('30022004')
.should('have.value', '30.02.2004')
.type('31022004')
.should('have.value', '30.02.2004 – 31.02.2004');
});

it('29.02.2003 => 29.02.2003 - 31.04.2004', () => {
cy.get('@input')
.type('29022003')
.should('have.value', '29.02.2003')
.type('31042004')
.should('have.value', '29.02.2003 – 31.04.2004');
});

it('31.06.2004 => 31.06.2004 - 31.09.2004', () => {
cy.get('@input')
.type('31062004')
.should('have.value', '31.06.2004')
.type('31092004')
.should('have.value', '31.06.2004 – 31.09.2004');
});
});

describe('swaps range ends with wrong dates', () => {
beforeEach(() => {
cy.visit(`/${DemoPath.DateRange}/API?strict=false`);
cy.get('#demo-content input')
.should('be.visible')
.first()
.focus()
.as('input');
});

it('31.02.2004 - 30.02.2004 => 30.02.2004 - 31.02.2004', () => {
cy.get('@input')
.type('3102200430022004')
.should('have.value', '30.02.2004 – 31.02.2004');
});

it('31.04.2004 - 29.02.2003 => 29.02.2003 - 31.04.2004', () => {
cy.get('@input')
.type('3104200429022003')
.should('have.value', '29.02.2003 – 31.04.2004');
});

it('01.01.2012 - 31.02.1999 => 31.02.1999 - 01.01.2012', () => {
cy.get('@input')
.type('0101201231021999')
.should('have.value', '31.02.1999 – 01.01.2012');
});
});

describe('replaces dates to max and min, when date greater max 10.05.2025 and less min 01.01.2000', () => {
beforeEach(() => {
cy.visit(
`/${DemoPath.DateRange}/API?strict=false&max=2025-05-10&min=2000-01-01`,
);
cy.get('#demo-content input')
.should('be.visible')
.first()
.focus()
.as('input');
});

it('30.02.1999 - 31.11.2029 => 01.01.2000 - 10.05.2025', () => {
cy.get('@input')
.type('3002199931112029')
.should('have.value', '01.01.2000 – 10.05.2025');
});

it('31.11.2029 - 30.02.1999 => 01.01.2000 - 10.05.2025', () => {
cy.get('@input')
.type('3111202930021999')
.should('have.value', '01.01.2000 – 10.05.2025');
});
});
});

describe('Enabled', () => {
describe('fixes wrong dates', () => {
beforeEach(() => {
cy.visit(`/${DemoPath.DateRange}/API?strict=true`);
cy.get('#demo-content input')
.should('be.visible')
.first()
.focus()
.as('input');
});

it('30.02.2004 => 30.02.2004 - 31.02.2004', () => {
cy.get('@input')
.type('30022004')
.should('have.value', '01.03.2004')
.type('31022004')
.should('have.value', '01.03.2004 – 02.03.2004');
});

it('29.02.2003 => 29.02.2003 - 31.04.2004', () => {
cy.get('@input')
.type('29022003')
.should('have.value', '01.03.2003')
.type('31042004')
.should('have.value', '01.03.2003 – 01.05.2004');
});

it('31.06.2004 => 31.06.2004 - 31.09.2004', () => {
cy.get('@input')
.type('31062004')
.should('have.value', '01.07.2004')
.type('31092004')
.should('have.value', '01.07.2004 – 01.10.2004');
});
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
import {DemoPath} from '@demo/constants';

describe('DateTime | Strict mode', () => {
describe('Disabled', () => {
describe("doesn't fix wrong dates", () => {
beforeEach(() => {
cy.visit(`/${DemoPath.DateTime}/API?strict=false`);
cy.get('#demo-content input')
.should('be.visible')
.first()
.focus()
.as('input');
});

it('30.02.2004, 23:21', () => {
cy.get('@input')
.type('300220042321')
.should('have.value', '30.02.2004, 23:21');
});

it('31.02.2004, 12:21', () => {
cy.get('@input')
.type('310220041221')
.should('have.value', '31.02.2004, 12:21');
});

it('29.02.2003, 00:00', () => {
cy.get('@input')
.type('290220030000')
.should('have.value', '29.02.2003, 00:00');
});

it('31.04.2004, 10:00', () => {
cy.get('@input')
.type('310420041000')
.should('have.value', '31.04.2004, 10:00');
});

it('31.04.2004, 23:21', () => {
cy.get('@input')
.type('310420042321')
.should('have.value', '31.04.2004, 23:21');
});

it('31.06.2004, 23:21', () => {
cy.get('@input')
.type('310620042321')
.should('have.value', '31.06.2004, 23:21');
});

it('31.09.2004, 23:21', () => {
cy.get('@input')
.type('310920042321')
.should('have.value', '31.09.2004, 23:21');
});

it('31.11.2004, 23:21', () => {
cy.get('@input')
.type('311120042321')
.should('have.value', '31.11.2004, 23:21');
});
});

describe('replaces dates to min, when date less min 01.01.2000, 12:30', () => {
beforeEach(() => {
cy.visit(`/${DemoPath.DateTime}/API?strict=false&min=2000-01-01T12:30`);
cy.get('#demo-content input')
.should('be.visible')
.first()
.focus()
.as('input');
});

it('30.02.2004 => 30.02.2004, 12:20', () => {
cy.get('@input')
.type('30022004')
.should('have.value', '30.02.2004')
.type('1220')
.should('have.value', '30.02.2004, 12:20');
});

it('31.11.1009 => 01.01.2000 => 01.01.2000, 12:30', () => {
cy.get('@input')
.type('31111009')
.should('have.value', '01.01.2000')
.type('1220')
.should('have.value', '01.01.2000, 12:30');
});
});

describe('replaces dates to max, when date greater max 10.05.2025, 18:30', () => {
beforeEach(() => {
cy.visit(`/${DemoPath.DateTime}/API?strict=false&max=2025-05-10T18:30`);
cy.get('#demo-content input')
.should('be.visible')
.first()
.focus()
.as('input');
});

it('31.04.2025 => 31.04.2025. 20:20', () => {
cy.get('@input')
.type('31042025')
.should('have.value', '31.04.2025')
.type('2020')
.should('have.value', '31.04.2025, 20:20');
});

it('29.02.2027 => 10.05.2025 => 10.05.2025, 18:30,', () => {
cy.get('@input')
.type('29022027')
.should('have.value', '10.05.2025')
.type('19:19')
.should('have.value', '10.05.2025, 18:30');
});
});
});

describe('Enabled', () => {
describe('fixse wrong dates', () => {
beforeEach(() => {
cy.visit(`/${DemoPath.DateTime}/API?strict=true`);
cy.get('#demo-content input')
.should('be.visible')
.first()
.focus()
.as('input');
});

it('30.02.2004, 23:21', () => {
cy.get('@input')
.type('300220042321')
.should('have.value', '01.03.2004, 23:21');
});

it('31.02.2004, 12:21', () => {
cy.get('@input')
.type('310220041221')
.should('have.value', '02.03.2004, 12:21');
});

it('29.02.2003, 00:00', () => {
cy.get('@input')
.type('290220030000')
.should('have.value', '01.03.2003, 00:00');
});

it('31.04.2004, 10:00', () => {
cy.get('@input')
.type('310420041000')
.should('have.value', '01.05.2004, 10:00');
});

it('31.06.2004, 23:21', () => {
cy.get('@input')
.type('310620042321')
.should('have.value', '01.07.2004, 23:21');
});

it('31.09.2004, 23:21', () => {
cy.get('@input')
.type('310920042321')
.should('have.value', '01.10.2004, 23:21');
});

it('31.11.2004, 23:21', () => {
cy.get('@input')
.type('311120042321')
.should('have.value', '01.12.2004, 23:21');
});
});
});
});
Loading
Loading