Merge pull request #384 from feilongfl/dev-undo
add `guiUndo` action for undo review
This commit is contained in:
commit
41ce156114
26
README.md
26
README.md
@ -1469,6 +1469,32 @@ corresponding to when the API was available for use.
|
||||
```
|
||||
</details>
|
||||
|
||||
#### `guiUndo`
|
||||
|
||||
* Undo the last action / card; returns `true` if succeeded or `false` otherwise.
|
||||
|
||||
<details>
|
||||
<summary><i>Sample request:</i></summary>
|
||||
|
||||
```json
|
||||
{
|
||||
"action": "guiUndo",
|
||||
"version": 6
|
||||
}
|
||||
```
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><i>Sample result:</i></summary>
|
||||
|
||||
```json
|
||||
{
|
||||
"result": true,
|
||||
"error": null
|
||||
}
|
||||
```
|
||||
</details>
|
||||
|
||||
#### `guiDeckOverview`
|
||||
|
||||
* Opens the *Deck Overview* dialog for the deck with the given name; returns `true` if succeeded or `false` otherwise.
|
||||
|
@ -1801,6 +1801,12 @@ class AnkiConnect:
|
||||
return True
|
||||
|
||||
|
||||
@util.api()
|
||||
def guiUndo(self):
|
||||
self.window().undo()
|
||||
return True
|
||||
|
||||
|
||||
@util.api()
|
||||
def guiDeckOverview(self, name):
|
||||
collection = self.collection()
|
||||
|
@ -102,6 +102,19 @@ class TestReviewActions:
|
||||
reviews_after = ac.cardReviews(deck="test_deck", startID=0)
|
||||
assert len(reviews_after) == len(reviews_before) + 1
|
||||
|
||||
def test_guiUndo(self, reviewing_started):
|
||||
ac.guiShowAnswer()
|
||||
reviews_before = ac.cardReviews(deck="test_deck", startID=0)
|
||||
assert ac.guiAnswerCard(ease=4) is True
|
||||
|
||||
reviews_after_answer = ac.cardReviews(deck="test_deck", startID=0)
|
||||
assert len(reviews_after_answer) == len(reviews_before) + 1
|
||||
|
||||
assert ac.guiUndo() is True
|
||||
|
||||
reviews_after_undo = ac.cardReviews(deck="test_deck", startID=0)
|
||||
assert len(reviews_after_undo) == len(reviews_before)
|
||||
|
||||
|
||||
class TestSelectedNotes:
|
||||
def test_with_valid_deck_query(self, setup):
|
||||
|
Loading…
Reference in New Issue
Block a user