Merge pull request #384 from feilongfl/dev-undo

add `guiUndo` action for undo review
This commit is contained in:
Alexei Yatskov 2023-05-23 19:18:15 -07:00 committed by GitHub
commit 41ce156114
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 0 deletions

View File

@ -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.

View File

@ -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()

View File

@ -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):