Skip to content

Commit

Permalink
fix(api-headless-cms): add missing date field storage transform
Browse files Browse the repository at this point in the history
  • Loading branch information
brunozoric committed Nov 19, 2024
1 parent 3301775 commit 0eb806e
Show file tree
Hide file tree
Showing 17 changed files with 713 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,18 @@ const contentEntryQueryData = {
},
{
title: "Hero Title #1",
date: "2021-01-01",
time: "12:00:00",
dateTimeWithTimezone: "2021-01-01T12:00:00+01:00",
dateTimeWithoutTimezone: "2021-01-01T12:00:00.000Z",
__typename: `${singularPageApiName}_Content_Hero`
},
{
title: "Hero Title #2",
date: "2021-02-05",
time: "14:00:00",
dateTimeWithTimezone: "2021-02-05T12:00:00+01:00",
dateTimeWithoutTimezone: "2021-02-05T12:00:00.000Z",
__typename: `${singularPageApiName}_Content_Hero`
},
{
Expand All @@ -36,10 +44,18 @@ const contentEntryQueryData = {
__typename: `${singularPageApiName}_Content_Objecting_NestedObject`,
objectNestedObject: [
{
nestedObjectNestedTitle: "Content Objecting nested title #1"
nestedObjectNestedTitle: "Content Objecting nested title #1",
date: "2021-01-01",
time: "12:00:00",
dateTimeWithTimezone: "2021-01-01T12:00:00+01:00",
dateTimeWithoutTimezone: "2021-01-01T12:00:00.000Z"
},
{
nestedObjectNestedTitle: "Content Objecting nested title #2"
nestedObjectNestedTitle: "Content Objecting nested title #2",
date: "2021-02-05",
time: "14:00:00",
dateTimeWithTimezone: "2021-02-05T12:00:00+01:00",
dateTimeWithoutTimezone: "2021-02-05T12:00:00.000Z"
}
],
objectTitle: "Objective title #1"
Expand Down Expand Up @@ -77,10 +93,18 @@ const contentEntryQueryData = {
nestedObject: {
objectNestedObject: [
{
nestedObjectNestedTitle: "Objective nested title #1"
nestedObjectNestedTitle: "Objective nested title #1",
date: "2021-01-01",
time: "12:00:00",
dateTimeWithTimezone: "2021-01-01T12:00:00+01:00",
dateTimeWithoutTimezone: "2021-01-01T12:00:00.000Z"
},
{
nestedObjectNestedTitle: "Objective nested title #2"
nestedObjectNestedTitle: "Objective nested title #2",
date: "2021-02-05",
time: "14:00:00",
dateTimeWithTimezone: "2021-02-05T12:00:00+01:00",
dateTimeWithoutTimezone: "2021-02-05T12:00:00.000Z"
}
],
objectTitle: "Objective title #1",
Expand Down Expand Up @@ -138,21 +162,41 @@ const contentEntryMutationData = {
SimpleText: { text: "Simple Text #1" }
},
{
Hero: { title: "Hero Title #1" }
Hero: {
title: "Hero Title #1",
date: "2021-01-01",
time: "12:00:00",
dateTimeWithTimezone: "2021-01-01T12:00:00+01:00",
dateTimeWithoutTimezone: "2021-01-01T12:00:00.000Z"
}
},
{
Hero: { title: "Hero Title #2" }
Hero: {
title: "Hero Title #2",
date: "2021-02-05",
time: "14:00:00",
dateTimeWithTimezone: "2021-02-05T12:00:00+01:00",
dateTimeWithoutTimezone: "2021-02-05T12:00:00.000Z"
}
},
{
Objecting: {
nestedObject: {
objectTitle: "Objective title #1",
objectNestedObject: [
{
nestedObjectNestedTitle: "Content Objecting nested title #1"
nestedObjectNestedTitle: "Content Objecting nested title #1",
date: "2021-01-01",
time: "12:00:00",
dateTimeWithTimezone: "2021-01-01T12:00:00+01:00",
dateTimeWithoutTimezone: "2021-01-01T12:00:00.000Z"
},
{
nestedObjectNestedTitle: "Content Objecting nested title #2"
nestedObjectNestedTitle: "Content Objecting nested title #2",
date: "2021-02-05",
time: "14:00:00",
dateTimeWithTimezone: "2021-02-05T12:00:00+01:00",
dateTimeWithoutTimezone: "2021-02-05T12:00:00.000Z"
}
]
},
Expand Down Expand Up @@ -210,10 +254,18 @@ const contentEntryMutationData = {
],
objectNestedObject: [
{
nestedObjectNestedTitle: "Objective nested title #1"
nestedObjectNestedTitle: "Objective nested title #1",
date: "2021-01-01",
time: "12:00:00",
dateTimeWithTimezone: "2021-01-01T12:00:00+01:00",
dateTimeWithoutTimezone: "2021-01-01T12:00:00.000Z"
},
{
nestedObjectNestedTitle: "Objective nested title #2"
nestedObjectNestedTitle: "Objective nested title #2",
date: "2021-02-05",
time: "14:00:00",
dateTimeWithTimezone: "2021-02-05T12:00:00+01:00",
dateTimeWithoutTimezone: "2021-02-05T12:00:00.000Z"
}
]
}
Expand Down Expand Up @@ -480,7 +532,7 @@ describe("dynamicZone field", () => {
}
});

const tplIsConverted = <T>(tpl: T) => "_templateId" in tpl;
const tplIsConverted = <T extends object>(tpl: T) => "_templateId" in tpl;

expect(eventEntryContent.beforeCreate?.values.content.every(tplIsConverted)).toEqual(true);
expect(eventEntryContent.afterCreate?.values.content.every(tplIsConverted)).toEqual(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,62 @@ export const pageModel: CmsModel = {
}
],
fieldId: "title"
},
{
settings: {
type: "date"
},
renderer: {
name: "date-time-input"
},
label: "Date",
id: "eyqi5168",
type: "datetime",
validation: [],
fieldId: "date",
storageId: "datetime@eyqi5168"
},
{
settings: {
type: "time"
},
renderer: {
name: "date-time-input"
},
label: "Time",
id: "zwnirh2r",
type: "datetime",
validation: [],
fieldId: "time",
storageId: "datetime@zwnirh2r"
},
{
settings: {
type: "dateTimeWithTimezone"
},
renderer: {
name: "date-time-input"
},
label: "Date Time With Timezone",
id: "wwn7s1rp",
type: "datetime",
validation: [],
fieldId: "dateTimeWithTimezone",
storageId: "datetime@wwn7s1rp"
},
{
settings: {
type: "dateTimeWithoutTimezone"
},
renderer: {
name: "date-time-input"
},
label: "Date Time Without Timezone",
id: "521a5932",
type: "datetime",
validation: [],
fieldId: "dateTimeWithoutTimezone",
storageId: "datetime@521a5932"
}
],
validation: [
Expand Down Expand Up @@ -186,6 +242,62 @@ export const pageModel: CmsModel = {
message: `"nestedObject.objectNestedObject.nestedObjectNestedTitle" is required.`
}
]
},
{
settings: {
type: "date"
},
renderer: {
name: "date-time-input"
},
label: "Date",
id: "6he8oex2",
type: "datetime",
validation: [],
fieldId: "date",
storageId: "datetime@6he8oex2"
},
{
settings: {
type: "time"
},
renderer: {
name: "date-time-input"
},
label: "Time",
id: "3k56vyr9",
type: "datetime",
validation: [],
fieldId: "time",
storageId: "datetime@3k56vyr9"
},
{
settings: {
type: "dateTimeWithTimezone"
},
renderer: {
name: "date-time-input"
},
label: "Date Time With Timezone",
id: "dualjcdv",
type: "datetime",
validation: [],
fieldId: "dateTimeWithTimezone",
storageId: "datetime@dualjcdv"
},
{
settings: {
type: "dateTimeWithoutTimezone"
},
renderer: {
name: "date-time-input"
},
label: "Date Time Without Timezone",
id: "7y789p8j",
type: "datetime",
validation: [],
fieldId: "dateTimeWithoutTimezone",
storageId: "datetime@7y789p8j"
}
]
}
Expand Down Expand Up @@ -466,6 +578,62 @@ export const pageModel: CmsModel = {
message: `"nestedObjectNestedTitle" is required.`
}
]
},
{
settings: {
type: "date"
},
renderer: {
name: "date-time-input"
},
label: "Date",
id: "6he8oex2",
type: "datetime",
validation: [],
fieldId: "date",
storageId: "datetime@6he8oex2"
},
{
settings: {
type: "time"
},
renderer: {
name: "date-time-input"
},
label: "Time",
id: "3k56vyr9",
type: "datetime",
validation: [],
fieldId: "time",
storageId: "datetime@3k56vyr9"
},
{
settings: {
type: "dateTimeWithTimezone"
},
renderer: {
name: "date-time-input"
},
label: "Date Time With Timezone",
id: "dualjcdv",
type: "datetime",
validation: [],
fieldId: "dateTimeWithTimezone",
storageId: "datetime@dualjcdv"
},
{
settings: {
type: "dateTimeWithoutTimezone"
},
renderer: {
name: "date-time-input"
},
label: "Date Time Without Timezone",
id: "7y789p8j",
type: "datetime",
validation: [],
fieldId: "dateTimeWithoutTimezone",
storageId: "datetime@7y789p8j"
}
]
}
Expand Down
Loading

0 comments on commit 0eb806e

Please sign in to comment.