Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(github): Use schema for issue objects #27782

Merged
merged 4 commits into from Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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