fix: techdocs cookie mocking date

Co-authored-by: Fredrik Adelöw <freben@gmail.com>
Signed-off-by: Camila Belo <camilaibs@gmail.com>
This commit is contained in:
Camila Belo
2024-03-12 08:39:54 +01:00
parent 048b875dbf
commit 43bf40c812
3 changed files with 8 additions and 6 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
---
'@backstage/plugin-techdocs-react': patch
'@backstage/plugin-techdocs-react': minor
---
Create a new api method for issuing user cookie.
@@ -127,8 +127,9 @@ class TechDocsDevApi implements TechDocsApi {
this.identityApi = identityApi;
}
async issueUserCookie(): Promise<{ expiresAt: string }> {
return { expiresAt: new Date().toISOString() };
async getCookie(): Promise<{ expiresAt: string }> {
const tenMinutesFromNow = new Date(Date.now() + 10 * 60 * 1000);
return { expiresAt: tenMinutesFromNow.toISOString() };
}
async getApiOrigin() {
@@ -48,9 +48,10 @@ const { renderToStaticMarkup } =
const techdocsApi = {
getTechDocsMetadata: jest.fn(),
getEntityMetadata: jest.fn(),
issueUserCookie: jest
.fn()
.mockReturnValue({ expiresAt: new Date().toISOString() }),
getCookie: jest.fn().mockReturnValue({
// Expires in 10 minutes
expiresAt: new Date(Date.now() + 10 * 60 * 1000).toISOString(),
}),
};
const techdocsStorageApi = {