This repository has been archived by the owner on Apr 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 320
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into fb-optic-107/save-d…
…raft-view-all
- Loading branch information
Showing
4 changed files
with
102 additions
and
9 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
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,6 @@ | ||
export const createConfigWithHotkey = (hotkey: string) => `<View> | ||
<Image name="img" value="$image"/> | ||
<RectangleLabels name="tag" toName="img"> | ||
<Label value="Label" hotkey="${hotkey}" /> | ||
</RectangleLabels> | ||
</View>`; |
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,68 @@ | ||
import { Labels, LabelStudio } from '@heartexlabs/ls-test/helpers/LSF'; | ||
import { | ||
createConfigWithHotkey | ||
} from '../../data/core/hotkeys'; | ||
import { Generator } from '@heartexlabs/ls-test/helpers/common/Generator'; | ||
|
||
describe('Hotkeys', () => { | ||
const hotkeysToCheck = [ | ||
['L', 'r'], | ||
['ctrl+L', 'ctrl+r'], | ||
[','], | ||
[',',',',','], // it won't work with odd number of commas 'cause 2 calls of selecting label cancel each other | ||
['a',','], | ||
[',','b'], | ||
['a',',','b'], | ||
['ctrl+,','ctrl+.'], | ||
['ctrl+.','ctrl+,'], | ||
]; | ||
|
||
for (const hotkeys of hotkeysToCheck) { | ||
const hotkeyString = hotkeys.join(','); | ||
|
||
it(`should be able to use hotkey ${hotkeyString}`, () => { | ||
Generator.generateImageUrl({ width: 800, height: 50 }) | ||
.then(imageUrl => { | ||
LabelStudio.params() | ||
.config(createConfigWithHotkey(hotkeyString)) | ||
.data({ image: imageUrl }) | ||
.withResult([]) | ||
.init(); | ||
}); | ||
|
||
LabelStudio.waitForObjectsReady(); | ||
Labels.label.should('have.length', 1); | ||
|
||
cy.log('Check that hotkeys work'); | ||
for (const hotkey of hotkeys) { | ||
const hotkeyInput = hotkey.includes('+') ? `{${hotkey}}` : `${hotkey}`; | ||
|
||
// try to use hotkey | ||
cy.get('body').type(hotkeyInput); | ||
Labels.selectedLabel.contains('Label'); | ||
// deselect | ||
cy.get('body').type('{esc}'); | ||
} | ||
|
||
cy.log('Reload LS'); | ||
cy.window().then(win => { | ||
win.LabelStudio.destroyAll(); | ||
new win.LabelStudio('label-studio', win.LSF_CONFIG); | ||
}); | ||
|
||
LabelStudio.waitForObjectsReady(); | ||
Labels.label.should('have.length', 1); | ||
|
||
cy.log('Check that hotkeys still work'); | ||
for (const hotkey of hotkeys) { | ||
const hotkeyInput = hotkey.includes('+') ? `{${hotkey}}` : `${hotkey}`; | ||
|
||
// try to use hotkey | ||
cy.get('body').type(hotkeyInput); | ||
Labels.selectedLabel.contains('Label'); | ||
// deselect | ||
cy.get('body').type('{esc}'); | ||
} | ||
}); | ||
} | ||
}); |