@@ -24,12 +24,28 @@ const test = baseTest
24
24
await withTempDir ( async dir => {
25
25
// Initialize a git repository there
26
26
await spawn ( 'git' , [ 'init' ] , { cwd : dir } )
27
+ await spawn ( 'git' , [ 'config' , 'user.name' , 'Test User' ] , {
28
+ cwd : dir ,
29
+ } )
30
+ await spawn ( 'git' , [ 'config' , 'user.email' , 'test@example.host' ] , { cwd : dir } )
27
31
28
32
// Add Cody ignore
29
33
await fs . mkdir ( path . join ( dir , '.cody' ) , { recursive : true } )
30
34
await fs . writeFile ( path . join ( dir , '.cody' , 'ignore' ) , 'ignored.js' )
31
35
32
- // Add some content
36
+ // Add empty files to change later
37
+ await Promise . all ( [
38
+ fs . writeFile ( path . join ( dir , 'index.js' ) , '' ) ,
39
+ fs . writeFile ( path . join ( dir , 'ignored.js' ) , '' ) ,
40
+ ] )
41
+
42
+ // Commit initial files
43
+ await spawn ( 'git' , [ 'add' , '.' ] , { cwd : dir } )
44
+ await spawn ( 'git' , [ 'commit' , '-m' , 'Initial commit' ] , {
45
+ cwd : dir ,
46
+ } )
47
+
48
+ // Add some content to try to commit in our tests
33
49
await Promise . all ( [
34
50
fs . writeFile ( path . join ( dir , 'index.js' ) , '// Hello World' ) ,
35
51
fs . writeFile ( path . join ( dir , 'ignored.js' ) , '// Ignore me!' ) ,
@@ -44,7 +60,7 @@ test.beforeEach(() => {
44
60
mockServer . resetLoggedEvents ( )
45
61
} )
46
62
47
- test ( 'commit message generation - happy path' , async ( { page, sidebar } ) => {
63
+ test ( 'commit message generation - happy path with staged changes ' , async ( { page, sidebar } ) => {
48
64
// Sign into Cody
49
65
await sidebarSignin ( page , sidebar )
50
66
@@ -55,7 +71,7 @@ test('commit message generation - happy path', async ({ page, sidebar }) => {
55
71
. click ( )
56
72
57
73
// Check the change is showing as a Git change
58
- const gitChange = page . getByLabel ( 'index.js, Untracked ' )
74
+ const gitChange = page . getByLabel ( 'index.js • Modified ' )
59
75
await expect ( gitChange ) . toBeVisible ( )
60
76
61
77
// Stage Git change
@@ -80,6 +96,38 @@ test('commit message generation - happy path', async ({ page, sidebar }) => {
80
96
) . toBeVisible ( )
81
97
} )
82
98
99
+ test ( 'commit message generation - happy path with no staged changes' , async ( { page, sidebar } ) => {
100
+ // Sign into Cody
101
+ await sidebarSignin ( page , sidebar )
102
+
103
+ // Open the Source Control view
104
+ await page
105
+ . getByLabel ( / S o u r c e C o n t r o l / )
106
+ . nth ( 2 )
107
+ . click ( )
108
+
109
+ // Check the change is showing as a Git change
110
+ const gitChange = page . getByLabel ( 'index.js • Modified' )
111
+ await expect ( gitChange ) . toBeVisible ( )
112
+
113
+ // Activate the Cody commit message feature
114
+ const generateCommitMessageCta = await page . getByLabel ( 'Generate Commit Message (Cody)' )
115
+ expect ( generateCommitMessageCta ) . toBeVisible ( )
116
+ await generateCommitMessageCta . hover ( )
117
+ await generateCommitMessageCta . click ( )
118
+
119
+ const expectedEvents = [
120
+ 'CodyVSCodeExtension:command:generateCommitMessage:clicked' ,
121
+ 'CodyVSCodeExtension:command:generateCommitMessage:executed' ,
122
+ ]
123
+ await assertEvents ( mockServer . loggedEvents , expectedEvents )
124
+
125
+ // Check generated content is displayed in the source control input
126
+ await expect (
127
+ page . getByLabel ( 'Source Control Input' ) . getByText ( 'hello from the assistant' )
128
+ ) . toBeVisible ( )
129
+ } )
130
+
83
131
test ( 'commit message generation - cody ignore' , async ( { page, sidebar } ) => {
84
132
// Sign into Cody
85
133
await sidebarSignin ( page , sidebar )
@@ -91,7 +139,7 @@ test('commit message generation - cody ignore', async ({ page, sidebar }) => {
91
139
. click ( )
92
140
93
141
// Check the change is showing as a Git change
94
- const gitChange = page . getByLabel ( 'ignored.js, Untracked ' )
142
+ const gitChange = page . getByLabel ( 'ignored.js • Modified ' )
95
143
await expect ( gitChange ) . toBeVisible ( )
96
144
97
145
// Stage Git change
0 commit comments