-
Notifications
You must be signed in to change notification settings - Fork 588
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(api-headless-cms): dates and identity in entry input (#3718)
- Loading branch information
1 parent
d6385e3
commit b63c1f8
Showing
42 changed files
with
890 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
packages/api-file-manager/__tests__/file.customDates.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import useGqlHandler from "./utils/useGqlHandler"; | ||
import { fileAData, ids } from "./mocks/files"; | ||
|
||
describe("file custom dates", () => { | ||
const { createFile, updateFile } = useGqlHandler(); | ||
|
||
it("should create and update file with custom dates", async () => { | ||
const [createResponse] = await createFile( | ||
{ | ||
data: { | ||
...fileAData, | ||
createdOn: "1995-01-01T00:00:00.000Z", | ||
savedOn: "1995-01-01T00:00:00.000Z" | ||
} | ||
}, | ||
["createdOn", "savedOn"] | ||
); | ||
expect(createResponse).toEqual({ | ||
data: { | ||
fileManager: { | ||
createFile: { | ||
data: { | ||
...fileAData, | ||
createdOn: "1995-01-01T00:00:00.000Z", | ||
savedOn: "1995-01-01T00:00:00.000Z" | ||
}, | ||
error: null | ||
} | ||
} | ||
} | ||
}); | ||
|
||
const [updateResponse] = await updateFile( | ||
{ | ||
id: ids.A, | ||
data: { | ||
createdOn: "2005-01-01T00:00:00.000Z", | ||
savedOn: "2005-01-01T00:00:00.000Z" | ||
} | ||
}, | ||
["createdOn", "savedOn"] | ||
); | ||
expect(updateResponse).toEqual({ | ||
data: { | ||
fileManager: { | ||
updateFile: { | ||
data: { | ||
...fileAData, | ||
createdOn: "2005-01-01T00:00:00.000Z", | ||
savedOn: "2005-01-01T00:00:00.000Z" | ||
}, | ||
error: null | ||
} | ||
} | ||
} | ||
}); | ||
}); | ||
}); |
107 changes: 107 additions & 0 deletions
107
packages/api-file-manager/__tests__/file.customIdentities.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import useGqlHandler from "./utils/useGqlHandler"; | ||
import { fileAData } from "./mocks/files"; | ||
import { SecurityIdentity } from "@webiny/api-security/types"; | ||
|
||
const extraFields = ["createdBy {id displayName type}", "modifiedBy {id displayName type}"]; | ||
describe("file custom identities", () => { | ||
const { createFile, updateFile, identity: defaultIdentity } = useGqlHandler(); | ||
|
||
const mockIdentityOne: SecurityIdentity = { | ||
id: "mock-identity-one", | ||
displayName: "Mock Identity One", | ||
type: "mockOne" | ||
}; | ||
const mockIdentityTwo: SecurityIdentity = { | ||
id: "mock-identity-two", | ||
displayName: "Mock Identity Two", | ||
type: "mockTwo" | ||
}; | ||
|
||
it("should create a file with custom identity", async () => { | ||
const [createRegularResponse] = await createFile( | ||
{ | ||
data: { | ||
...fileAData | ||
} | ||
}, | ||
extraFields | ||
); | ||
expect(createRegularResponse).toEqual({ | ||
data: { | ||
fileManager: { | ||
createFile: { | ||
data: { | ||
...fileAData, | ||
createdBy: defaultIdentity, | ||
modifiedBy: null | ||
}, | ||
error: null | ||
} | ||
} | ||
} | ||
}); | ||
|
||
const [createCustomIdentityResponse] = await createFile( | ||
{ | ||
data: { | ||
...fileAData, | ||
createdBy: mockIdentityOne, | ||
modifiedBy: mockIdentityTwo | ||
} | ||
}, | ||
extraFields | ||
); | ||
expect(createCustomIdentityResponse).toEqual({ | ||
data: { | ||
fileManager: { | ||
createFile: { | ||
data: { | ||
...fileAData, | ||
createdBy: mockIdentityOne, | ||
modifiedBy: mockIdentityTwo | ||
}, | ||
error: null | ||
} | ||
} | ||
} | ||
}); | ||
}); | ||
|
||
it("should update a file with custom identity", async () => { | ||
const [createResponse] = await createFile( | ||
{ | ||
data: { | ||
...fileAData | ||
} | ||
}, | ||
extraFields | ||
); | ||
|
||
const id = createResponse.data.fileManager.createFile.data.id; | ||
|
||
const [updateResponse] = await updateFile( | ||
{ | ||
id, | ||
data: { | ||
createdBy: mockIdentityOne, | ||
modifiedBy: mockIdentityTwo | ||
} | ||
}, | ||
extraFields | ||
); | ||
expect(updateResponse).toEqual({ | ||
data: { | ||
fileManager: { | ||
updateFile: { | ||
data: { | ||
...fileAData, | ||
createdBy: mockIdentityOne, | ||
modifiedBy: mockIdentityTwo | ||
}, | ||
error: null | ||
} | ||
} | ||
} | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.