diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-03 20:34:32 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-03 20:34:32 +0000 |
commit | a47bbf7ce093a46ce83cd66da5d9ce3150324860 (patch) | |
tree | 36ee17fd93f50c371dba3e8829283fa4bfb98f99 /spec/frontend_integration | |
parent | 4bafeeda963a11ce4004bbe35a4ff2606bc4d10a (diff) | |
download | gitlab-ce-a47bbf7ce093a46ce83cd66da5d9ce3150324860.tar.gz |
Add latest changes from gitlab-org/gitlab@13-5-stable-ee
Diffstat (limited to 'spec/frontend_integration')
-rw-r--r-- | spec/frontend_integration/ide/ide_helper.js | 26 | ||||
-rw-r--r-- | spec/frontend_integration/ide/ide_integration_spec.js | 15 | ||||
-rw-r--r-- | spec/frontend_integration/test_helpers/setup/setup_globals.js | 2 |
3 files changed, 39 insertions, 4 deletions
diff --git a/spec/frontend_integration/ide/ide_helper.js b/spec/frontend_integration/ide/ide_helper.js index a43695fea8f..fea8bc24031 100644 --- a/spec/frontend_integration/ide/ide_helper.js +++ b/spec/frontend_integration/ide/ide_helper.js @@ -1,6 +1,6 @@ import { findAllByText, fireEvent, getByLabelText, screen } from '@testing-library/dom'; -const isFileRowOpen = row => row.matches('.is-open'); +const isFolderRowOpen = row => row.matches('.folder.is-open'); const getLeftSidebar = () => screen.getByTestId('left-sidebar'); @@ -24,6 +24,8 @@ const findAndSetEditorValue = async value => { const findTreeBody = () => screen.findByTestId('ide-tree-body', {}, { timeout: 5000 }); +const findRootActions = () => screen.findByTestId('ide-root-actions', {}, { timeout: 7000 }); + const findFileRowContainer = (row = null) => row ? Promise.resolve(row.parentElement) : findTreeBody(); @@ -35,7 +37,7 @@ const findFileChild = async (row, name, index = 0) => { }; const openFileRow = row => { - if (!row || isFileRowOpen(row)) { + if (!row || isFolderRowOpen(row)) { return; } @@ -74,6 +76,19 @@ const findAndSetFileName = async value => { createButton.click(); }; +const findAndClickRootAction = async name => { + const container = await findRootActions(); + const button = getByLabelText(container, name); + + button.click(); +}; + +export const openFile = async path => { + const row = await findAndTraverseToPath(path); + + openFileRow(row); +}; + export const createFile = async (path, content) => { const parentPath = path .split('/') @@ -81,7 +96,12 @@ export const createFile = async (path, content) => { .join('/'); const parentRow = await findAndTraverseToPath(parentPath); - clickFileRowAction(parentRow, 'New file'); + + if (parentRow) { + clickFileRowAction(parentRow, 'New file'); + } else { + await findAndClickRootAction('New file'); + } await findAndSetFileName(path); await findAndSetEditorValue(content); diff --git a/spec/frontend_integration/ide/ide_integration_spec.js b/spec/frontend_integration/ide/ide_integration_spec.js index c4d0c4df8de..1f5c1d38450 100644 --- a/spec/frontend_integration/ide/ide_integration_spec.js +++ b/spec/frontend_integration/ide/ide_integration_spec.js @@ -1,5 +1,6 @@ import { TEST_HOST } from 'helpers/test_constants'; import { waitForText } from 'helpers/wait_for_text'; +import waitForPromises from 'helpers/wait_for_promises'; import { useOverclockTimers } from 'test_helpers/utils/overclock_timers'; import { createCommitId } from 'test_helpers/factories/commit_id'; import { initIde } from '~/ide'; @@ -86,4 +87,18 @@ describe('WebIDE', () => { ], }); }); + + it('user adds file that starts with +', async () => { + createComponent(); + + await ideHelper.createFile('+test', 'Hello world!'); + await ideHelper.openFile('+test'); + + // Wait for monaco things + await waitForPromises(); + + // Assert that +test is the only open tab + const tabs = Array.from(document.querySelectorAll('.multi-file-tab')); + expect(tabs.map(x => x.textContent.trim())).toEqual(['+test']); + }); }); diff --git a/spec/frontend_integration/test_helpers/setup/setup_globals.js b/spec/frontend_integration/test_helpers/setup/setup_globals.js index 2b0e8f76c3c..b63a9a96372 100644 --- a/spec/frontend_integration/test_helpers/setup/setup_globals.js +++ b/spec/frontend_integration/test_helpers/setup/setup_globals.js @@ -6,7 +6,7 @@ beforeEach(() => { relative_url_root: '', }; - setTestTimeout(5000); + setTestTimeout(7000); jest.useRealTimers(); }); |