Skip to content

Commit

Permalink
feat(github): Use schema for issue objects (#27782)
Browse files Browse the repository at this point in the history
  • Loading branch information
zharinov committed Mar 10, 2024
1 parent 459fe17 commit 0cc759c
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 41 deletions.
1 change: 1 addition & 0 deletions lib/modules/platform/github/graphql.ts
Expand Up @@ -48,6 +48,7 @@ query(
state
title
body
updatedAt
}
}
}
Expand Down
110 changes: 101 additions & 9 deletions lib/modules/platform/github/index.spec.ts
Expand Up @@ -1632,11 +1632,15 @@ describe('modules/platform/github/index', () => {
number: 2,
state: 'open',
title: 'title-2',
body: 'body-2',
updatedAt: '2022-01-01T00:00:00Z',
},
{
number: 1,
state: 'open',
title: 'title-1',
body: 'body-1',
updatedAt: '2021-01-01T00:00:00Z',
},
],
},
Expand Down Expand Up @@ -1665,21 +1669,37 @@ describe('modules/platform/github/index', () => {
number: 2,
state: 'open',
title: 'title-2',
body: 'body-2',
updatedAt: '2022-01-01T00:00:00Z',
},
{
number: 1,
state: 'open',
title: 'title-1',
body: 'body-1',
updatedAt: '2021-01-01T00:00:00Z',
},
],
},
},
},
})
.get('/repos/undefined/issues/2')
.reply(200, { body: 'new-content' });
.reply(200, {
number: 2,
state: 'open',
title: 'title-2',
body: 'new-content',
updated_at: '2023-01-01T00:00:00Z',
});
const res = await github.findIssue('title-2');
expect(res).not.toBeNull();
expect(res).toEqual({
number: 2,
state: 'open',
title: 'title-2',
body: 'new-content',
lastModified: '2023-01-01T00:00:00Z',
});
});
});

Expand All @@ -1704,11 +1724,15 @@ describe('modules/platform/github/index', () => {
number: 2,
state: 'open',
title: 'title-2',
body: 'body-2',
updatedAt: '2022-01-01T00:00:00Z',
},
{
number: 1,
state: 'open',
title: 'title-1',
body: 'body-1',
updatedAt: '2021-01-01T00:00:00Z',
},
],
},
Expand Down Expand Up @@ -1744,11 +1768,15 @@ describe('modules/platform/github/index', () => {
number: 2,
state: 'open',
title: 'title-2',
body: 'body-2',
updatedAt: '2022-01-01T00:00:00Z',
},
{
number: 1,
state: 'closed',
title: 'title-1',
body: 'body-1',
updatedAt: '2021-01-01T00:00:00Z',
},
],
},
Expand Down Expand Up @@ -1782,11 +1810,15 @@ describe('modules/platform/github/index', () => {
number: 2,
state: 'open',
title: 'title-2',
body: 'body-2',
updatedAt: '2022-01-01T00:00:00Z',
},
{
number: 1,
state: 'closed',
title: 'title-1',
body: 'body-1',
updatedAt: '2021-01-01T00:00:00Z',
},
],
},
Expand Down Expand Up @@ -1852,16 +1884,22 @@ describe('modules/platform/github/index', () => {
number: 3,
state: 'open',
title: 'title-1',
body: 'body-1',
updatedAt: '2021-01-01T00:00:00Z',
},
{
number: 2,
state: 'open',
title: 'title-2',
body: 'body-2',
updatedAt: '2022-01-01T00:00:00Z',
},
{
number: 1,
state: 'closed',
title: 'title-1',
body: 'body-1',
updatedAt: '2021-01-01T00:00:00Z',
},
],
},
Expand Down Expand Up @@ -1899,19 +1937,29 @@ describe('modules/platform/github/index', () => {
number: 2,
state: 'open',
title: 'title-2',
body: 'body-2',
updatedAt: '2022-01-01T00:00:00Z',
},
{
number: 1,
state: 'open',
title: 'title-1',
body: 'body-1',
updatedAt: '2021-01-01T00:00:00Z',
},
],
},
},
},
})
.get('/repos/some/repo/issues/2')
.reply(200, { body: 'new-content' })
.reply(200, {
number: 2,
state: 'open',
title: 'title-2',
body: 'new-content',
updated_at: '2023-01-01T00:00:00Z',
})
.patch('/repos/some/repo/issues/2')
.reply(200);
const res = await github.ensureIssue({
Expand Down Expand Up @@ -1942,19 +1990,29 @@ describe('modules/platform/github/index', () => {
number: 2,
state: 'open',
title: 'title-2',
body: 'body-2',
updatedAt: '2022-01-01T00:00:00Z',
},
{
number: 1,
state: 'open',
title: 'title-1',
body: 'body-1',
updatedAt: '2021-01-01T00:00:00Z',
},
],
},
},
},
})
.get('/repos/some/repo/issues/2')
.reply(200, { body: 'new-content' })
.reply(200, {
number: 2,
state: 'open',
title: 'title-2',
body: 'new-content',
updated_at: '2023-01-01T00:00:00Z',
})
.patch('/repos/some/repo/issues/2')
.reply(200);
const res = await github.ensureIssue({
Expand Down Expand Up @@ -1986,11 +2044,15 @@ describe('modules/platform/github/index', () => {
number: 2,
state: 'open',
title: 'title-2',
body: 'newer-content',
updatedAt: '2022-01-01T00:00:00Z',
},
{
number: 1,
state: 'open',
title: 'title-1',
body: 'new-content',
updatedAt: '2021-01-01T00:00:00Z',
},
],
},
Expand Down Expand Up @@ -2026,21 +2088,31 @@ describe('modules/platform/github/index', () => {
number: 2,
state: 'open',
title: 'title-1',
body: 'body-1',
updatedAt: '2021-01-01T00:00:00Z',
},
{
number: 1,
state: 'open',
title: 'title-1',
body: 'body-1',
updatedAt: '2021-01-01T00:00:00Z',
},
],
},
},
},
})
.patch('/repos/some/repo/issues/1')
.reply(200)
.get('/repos/some/repo/issues/2')
.reply(200, { body: 'newer-content' });
.reply(200, {
number: 2,
state: 'open',
title: 'title-1',
body: 'newer-content',
updated_at: '2021-01-01T00:00:00Z',
})
.patch('/repos/some/repo/issues/1')
.reply(200);
const res = await github.ensureIssue({
title: 'title-1',
body: 'newer-content',
Expand Down Expand Up @@ -2068,14 +2140,22 @@ describe('modules/platform/github/index', () => {
number: 2,
state: 'close',
title: 'title-2',
body: 'body-2',
updatedAt: '2022-01-01T00:00:00Z',
},
],
},
},
},
})
.get('/repos/some/repo/issues/2')
.reply(200, { body: 'new-content' })
.reply(200, {
number: 2,
state: 'closed',
title: 'title-2',
body: 'new-content',
updated_at: '2023-01-01T00:00:00Z',
})
.post('/repos/some/repo/issues')
.reply(200);
const res = await github.ensureIssue({
Expand Down Expand Up @@ -2107,14 +2187,22 @@ describe('modules/platform/github/index', () => {
number: 2,
state: 'open',
title: 'title-2',
body: 'body-2',
updatedAt: '2022-01-01T00:00:00Z',
},
],
},
},
},
})
.get('/repos/some/repo/issues/2')
.reply(200, { body: 'new-content' });
.reply(200, {
number: 2,
state: 'open',
title: 'title-2',
body: 'new-content',
updated_at: '2023-01-01T00:00:00Z',
});
const res = await github.ensureIssue({
title: 'title-2',
body: 'new-content',
Expand Down Expand Up @@ -2144,11 +2232,15 @@ describe('modules/platform/github/index', () => {
number: 2,
state: 'open',
title: 'title-2',
body: 'body-2',
updatedAt: '2022-01-01T00:00:00Z',
},
{
number: 1,
state: 'open',
title: 'title-1',
body: 'body-1',
updatedAt: '2021-01-01T00:00:00Z',
},
],
},
Expand Down

0 comments on commit 0cc759c

Please sign in to comment.