Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(deck-options): discard changes dialog #17851

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

david-allison
Copy link
Member

Purpose / Description

@Arthur-Milchior said this would be hard. I knew he was right, and I did it anyway. I would regret my time spent here, but it will hopefully lead to more regression coverage for our backend pages

Issue

Approach

How Has This Been Tested?

  • My personal S21 (Android 14)
  • API 30 emulator

Warning

This needs a number of reruns in CI to be sure it's stable

Learning (optional, can help others)

This is the first test of anki.pages, and hopefully will allow us to stop a few 'brown paper bag' bugs in future, such as when we broke Statistics

onView can't be called inside onActivity. There feels like a lot of bad advice here, and the easy option is to move the assertion outside onActivity: https://stackoverflow.com/questions/61953249/how-to-access-activity-from-activityscenariorule

Checklist

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

@david-allison david-allison force-pushed the 2-21-discard-changes branch 2 times, most recently from 01090ff to 6f5452b Compare January 22, 2025 05:46
Mostly to get a framework in place for testing
DeckOptions

Some of it will want to be abstracted at a later date

The WebView based timing issues are painful.
As is 'actuallyClose', which launches a task to close

10ms was sufficient for the WebView, but I wanted some leeway
for CI

`isClosingFragment` seemed easier than waiting on tasks,
even if less architecturally pure. It also means we
listen to task start, rather than task finish

Issue 14438
Issue 14438

----

This was a difficult change to make:

* timing considerations on WebView callbacks

I spent time time trying to use `onView` inside `onActivity`.

After research, `onView` should be outside the `onActivity`
hook: https://stackoverflow.com/a/64284563
@mikehardy mikehardy force-pushed the 2-21-discard-changes branch from 6f5452b to 51e1cbd Compare January 27, 2025 00:21
@mikehardy
Copy link
Member

I'm in here working on this for the last commit. I'll have an emulator test workflow change that lets you specify iteration count in few minutes. Or maybe a half hour, but I'll get it. May be noisy though as I develop it, apologies

@mikehardy mikehardy force-pushed the 2-21-discard-changes branch 3 times, most recently from cc502ea to f52f656 Compare January 27, 2025 00:33
@mikehardy
Copy link
Member

emulator workflow matrix construction is correct now, generated runs are named well, just need to re-align the "required" check list. I think a close/open will do that? Unsure but the name I'm generating appears correct now and matches the unit test style.

@mikehardy mikehardy closed this Jan 27, 2025
@mikehardy mikehardy reopened this Jan 27, 2025
@mikehardy
Copy link
Member

Not quite, but close. Will wait for the run to complete then examine the settings to see if the check name is different, try remove/re-add from branch protection rules etc.

Copy link
Member

@mikehardy mikehardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all looks fine - nice set of solutions to make it all work.
I'm taking the opportunity based on the prompt to run it a lot in CI to add the unit test iteration feature to the emulator workflow

Bear with me while I get it correct. Then we can hammer this one and make sure it doesn't flake.

this is the same idea from the unit test workflow that lets us
dynamically expand our matrix based on manual workflow input
from GitHub web UI
@mikehardy mikehardy force-pushed the 2-21-discard-changes branch from f52f656 to 48b3658 Compare January 27, 2025 00:58
@mikehardy
Copy link
Member

got it. zero-based array for the iteration in the name, not 1-based, I was generating iteration 1 as the first (and default only) run, but the required check was looking for iteration 0.

Should pass now. And we should be able to hammer it now.

@mikehardy
Copy link
Member

I have a 30 iteration run going on my fork, if it passes, I'm good with it

https://github.com/mikehardy/Anki-Android/actions/runs/12980212524

@mikehardy mikehardy added Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) and removed Needs Review labels Jan 27, 2025
@david-allison
Copy link
Member Author

image

Gotta hit this one with the flake hammer. Cheers!

@david-allison david-allison added Needs Author Reply Waiting for a reply from the original author and removed Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) labels Jan 27, 2025
@david-allison david-allison marked this pull request as draft January 27, 2025 01:38
@mikehardy
Copy link
Member

10% flakes :-), so it needs some work. But finding the problem is step 1
No rush fixing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Author Reply Waiting for a reply from the original author
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants