-
Notifications
You must be signed in to change notification settings - Fork 551
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add proof of concept drag & drop e2e test
- Loading branch information
Showing
14 changed files
with
174 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eu -o pipefail | ||
|
||
DATA_DIR="$HOME/.local/share/com.gitbutler.app.test" | ||
if [ ! -d "$DATA_DIR" ]; then | ||
echo "Creating data dir: $DATA_DIR" | ||
mkdir -p $DATA_DIR | ||
fi | ||
echo "Confirming analytics" | ||
echo '{"appAnalyticsConfirmed":true}' > $DATA_DIR/settings.json | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eu -o pipefail | ||
|
||
TEMP_DIR=${1:?The first argument is a temp dir} | ||
# Convert to absolute path | ||
TEMP_DIR=$(realpath "$TEMP_DIR") | ||
|
||
|
||
CLI=$(realpath "../../target/debug/gitbutler-cli") | ||
|
||
DATA_DIR="$HOME/.local/share/com.gitbutler.app.test" | ||
if [ -d "$DATA_DIR" ]; then | ||
rm -rf $DATA_DIR | ||
fi | ||
|
||
function setGitDefaults() { | ||
git config user.email "[email protected]" | ||
git config user.name "Test User" | ||
git config init.defaultBranch master | ||
} | ||
|
||
function tick() { | ||
if test -z "${tick+set}"; then | ||
tick=1675176957 | ||
else | ||
tick=$($tick + 60) | ||
fi | ||
GIT_COMMITTER_DATE="$tick +0100" | ||
GIT_AUTHOR_DATE="$tick +0100" | ||
export GIT_COMMITTER_DATE GIT_AUTHOR_DATE | ||
} | ||
tick | ||
|
||
if [ -d "$TEMP_DIR" ]; then | ||
rm -rf "$TEMP_DIR" | ||
fi | ||
mkdir "$TEMP_DIR" | ||
|
||
( | ||
cd "$TEMP_DIR" | ||
git init remote | ||
cd remote | ||
setGitDefaults | ||
echo first >file | ||
git add . && git commit -m "init" | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,32 @@ | ||
import { spawnAndLog, findAndClick, setElementValue } from '../utils.js'; | ||
|
||
const TEMP_DIR = '/tmp/gitbutler-add-project'; | ||
const REPO_NAME = 'one-vbranch-on-integration'; | ||
|
||
describe('Project', () => { | ||
before(() => { | ||
spawnAndLog('bash', [ | ||
'-c', | ||
'./e2e/scripts/init-repositories.sh ../../target/debug/gitbutler-cli' | ||
` | ||
source ./e2e/scripts/init.sh ${TEMP_DIR} | ||
cd ${TEMP_DIR}; | ||
git clone remote ${REPO_NAME} && cd ${REPO_NAME} | ||
$CLI project -s dev add --switch-to-workspace "$(git rev-parse --symbolic-full-name "@{u}")" | ||
$CLI branch create virtual | ||
` | ||
]); | ||
}); | ||
|
||
it('should add a local project', async () => { | ||
await findAndClick('button[data-testid="analytics-continue"]'); | ||
|
||
const dirInput = await $('input[data-testid="test-directory-path"]'); | ||
setElementValue(dirInput, '/tmp/gb-e2e-repos/one-vbranch-on-integration'); | ||
setElementValue(dirInput, `${TEMP_DIR}/${REPO_NAME}`); | ||
|
||
await findAndClick('button[data-testid="add-local-project"]'); | ||
await findAndClick('button[data-testid="set-base-branch"]'); | ||
await findAndClick('button[data-testid="accept-git-auth"]'); | ||
await $('button[data-testid="add-local-project"]').then(async (b) => await b.click()); | ||
await $('button[data-testid="set-base-branch"]').then(async (b) => await b.click()); | ||
await $('button[data-testid="accept-git-auth"]').then(async (b) => await b.click()); | ||
|
||
const workspaceButton = await $('button=Workspace'); | ||
await expect(workspaceButton).toExist(); | ||
await expect($('button=Workspace')).toExist(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { spawnAndLog } from '../utils.js'; | ||
import { codeForSelectors as dragAndDrop } from 'html-dnd'; | ||
|
||
const TEMP_DIR = '/tmp/gitbutler-drag-files'; | ||
const REPO_NAME = 'simple-drag-test'; | ||
|
||
describe('Drag', () => { | ||
before(() => { | ||
spawnAndLog('bash', [ | ||
'-c', | ||
` | ||
source ./e2e/scripts/init.sh ${TEMP_DIR} | ||
bash ./e2e/scripts/confirm-analytics.sh | ||
cd ${TEMP_DIR}; | ||
git clone remote ${REPO_NAME} && cd ${REPO_NAME} | ||
setGitDefaults | ||
$CLI project -s test add --switch-to-workspace "$(git rev-parse --symbolic-full-name "@{u}")" | ||
$CLI branch create virtual-one | ||
$CLI branch create virtual-two | ||
echo "hello world" > hello | ||
` | ||
]); | ||
}); | ||
|
||
it('drag file from one lane to another', async () => { | ||
const fileSelector = '[data-testid="file-hello"]'; | ||
const dropSelector = '[data-testid="virtual-two-files-dz"]'; | ||
|
||
const fileItem = await $(fileSelector); | ||
const dropTarget = await $(dropSelector); | ||
await fileItem.waitForDisplayed(); | ||
await dropTarget.waitForDisplayed(); | ||
|
||
// The actual drop target can be different from the element with the `dropZone` directive.. | ||
await driver.executeScript(dragAndDrop, [fileSelector, dropSelector + ' .dropzone-target']); | ||
|
||
const finishSelector = await $('[data-testid="branch-virtual-two"] [data-testid="file-hello"]'); | ||
await finishSelector.waitForDisplayed(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.