From a901350985c00bd532fc78c56a8ab5f8b13cef0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Collonval?= Date: Thu, 26 Oct 2023 14:03:50 +0200 Subject: [PATCH] Fix commit message (#1283) * Fix commit message * Add test * Lint the code --- src/components/GitPanel.tsx | 8 ++++--- ui-tests/tests/commit.spec.ts | 44 +++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 ui-tests/tests/commit.spec.ts diff --git a/src/components/GitPanel.tsx b/src/components/GitPanel.tsx index caf4dc1c3..2acb17ab1 100644 --- a/src/components/GitPanel.tsx +++ b/src/components/GitPanel.tsx @@ -788,15 +788,17 @@ export class GitPanel extends React.Component { try { const author = await this._hasIdentity(this.props.model.pathRepository); - const message = this.props.trans.__('Committing changes...'); + const notificationMsg = this.props.trans.__('Committing changes...'); if (id !== null) { Notification.update({ id, - message, + message: notificationMsg, autoClose: false }); } else { - id = Notification.emit(message, 'in-progress', { autoClose: false }); + id = Notification.emit(notificationMsg, 'in-progress', { + autoClose: false + }); } if (this.state.commitAmend) { diff --git a/ui-tests/tests/commit.spec.ts b/ui-tests/tests/commit.spec.ts new file mode 100644 index 000000000..f21a0abd0 --- /dev/null +++ b/ui-tests/tests/commit.spec.ts @@ -0,0 +1,44 @@ +import { expect, test } from '@jupyterlab/galata'; +import path from 'path'; +import { extractFile } from './utils'; + +const baseRepositoryPath = 'test-repository.tar.gz'; +test.use({ autoGoto: false }); + +test.describe('Commit', () => { + test.beforeEach(async ({ page, request, tmpPath }) => { + await extractFile( + request, + path.resolve(__dirname, 'data', baseRepositoryPath), + path.join(tmpPath, 'repository.tar.gz') + ); + + // URL for merge conflict example repository + await page.goto(`tree/${tmpPath}/test-repository`); + }); + + test('should commit a change', async ({ page }) => { + await page + .getByRole('listitem', { name: 'Name: another_file.txt' }) + .dblclick(); + await page + .getByLabel('another_file.txt') + .getByRole('textbox') + .fill('My new content'); + await page.keyboard.press('Control+s'); + + await page.getByRole('tab', { name: 'Git' }).click(); + await page.getByTitle('another_file.txt • Modified').hover(); + await page.getByRole('button', { name: 'Stage this change' }).click(); + + await page + .getByPlaceholder('Summary (Ctrl+Enter to commit)') + .fill('My new commit'); + + await page.getByRole('button', { name: 'Commit', exact: true }).click(); + + await page.getByRole('tab', { name: 'History' }).click(); + + await expect(page.getByText('My new commit')).toBeVisible(); + }); +});