Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-10-29 12:08:38 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-10-29 12:08:38 +0300
commitc3ea5eada6f28b5e46cc4114f315729cde58de87 (patch)
treefc45e7af9ceb19da47f8988bbbdc73166f1d8b8a /spec/frontend_integration/ide
parent4bc1e04a7adb4b183c713e5faff726579e909d1c (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend_integration/ide')
-rw-r--r--spec/frontend_integration/ide/ide_helper.js26
-rw-r--r--spec/frontend_integration/ide/ide_integration_spec.js15
2 files changed, 38 insertions, 3 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']);
+ });
});