Skip to content

Commit

Permalink
[SDESK-6972] fix(api): Allow Event dates.tz to have a null value (#1816)
Browse files Browse the repository at this point in the history
* fix(api): Allow dates.tz to have a null value

* Add tests
  • Loading branch information
MarkLark86 authored Jun 27, 2023
1 parent 6d5a6a5 commit 3dc04d4
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 5 deletions.
67 changes: 64 additions & 3 deletions e2e/cypress/e2e/events/edit_event.cy.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import {setup, login, waitForPageLoad, SubNavBar, Workqueue, Modal} from '../../support/common';
import {cloneDeep} from 'lodash';

import {setup, login, waitForPageLoad, SubNavBar, Workqueue, Modal, addItems} from '../../support/common';
import {EventEditor, PlanningList} from '../../support/planning';
import {TEST_EVENTS} from '../../fixtures/events';

const list = new PlanningList();
const editor = new EventEditor();

describe('Planning.Events: edit metadata', () => {
const editor = new EventEditor();
const subnav = new SubNavBar();
const list = new PlanningList();
const workqueue = new Workqueue();
const modal = new Modal();
let event;
Expand Down Expand Up @@ -173,3 +177,60 @@ describe('Planning.Events: edit metadata', () => {
.should('be.enabled');
});
});

describe('Planing.Events: edit existing events', () => {
beforeEach(() => {
setup({fixture_profile: 'planning_prepopulate_data'}, '/#/planning');
addItems('events', [{
...cloneDeep(TEST_EVENTS.date_01_02_2045),
dates: {
start: TEST_EVENTS.date_01_02_2045.dates.start,
end: TEST_EVENTS.date_01_02_2045.dates.end,
},
}, {
...cloneDeep(TEST_EVENTS.date_02_02_2045),
dates: {
start: TEST_EVENTS.date_02_02_2045.dates.start,
end: TEST_EVENTS.date_02_02_2045.dates.end,
tz: null,
},
}]);
login();

waitForPageLoad.planning();
});

it('SDESK-6972: Edit events with no timezone', () => {
// Test if we can edit an Event without a timezone value
list.item(0)
.dblclick();
editor.waitTillOpen();
editor.waitLoadingComplete();

editor.type({definition_short: 'Modifying 1st event'});
editor.waitForAutosave();
editor.saveButton
.should('exist')
.click();
editor.closeButton
.should('exist')
.click();
editor.waitTillClosed();

// test if we can edit an Event with a timezone value of `null`
list.item(1)
.dblclick();
editor.waitTillOpen();
editor.waitLoadingComplete();

editor.type({definition_short: 'Modifying 2nd event'});
editor.waitForAutosave();
editor.saveButton
.should('exist')
.click();
editor.closeButton
.should('exist')
.click();
editor.waitTillClosed();
});
});
30 changes: 29 additions & 1 deletion server/features/events.feature
Original file line number Diff line number Diff line change
Expand Up @@ -1376,4 +1376,32 @@ Feature: Events
{
"assignment_id": null
}
"""
"""

@auth
Scenario: Create events without a timezone
When we post to "/events"
"""
[{
"guid": "event1",
"name": "No timezone defined",
"dates": {
"start": "2029-11-21T12:00:00.000Z",
"end": "2029-11-21T14:00:00.000Z"
}
}]
"""
Then we get OK response
When we post to "/events"
"""
[{
"guid": "event2",
"name": "null timezone",
"dates": {
"start": "2029-11-21T12:00:00.000Z",
"end": "2029-11-21T14:00:00.000Z",
"tz": null
}
}]
"""
Then we get OK response
5 changes: 4 additions & 1 deletion server/planning/events/events_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@
"type": "datetime",
"nullable": True,
},
"tz": {"type": "string"},
"tz": {
"type": "string",
"nullable": True,
},
"end_tz": {"type": "string"},
"all_day": {"type": "boolean"},
"no_end_time": {"type": "boolean"},
Expand Down

0 comments on commit 3dc04d4

Please sign in to comment.