Skip to content

test: add device orientation tests - #308

Open
gmegidish wants to merge 1 commit into
mainfrom
tests-orientation-tests
Open

test: add device orientation tests#308
gmegidish wants to merge 1 commit into
mainfrom
tests-orientation-tests

Conversation

@gmegidish

Copy link
Copy Markdown
Member

No description provided.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Walkthrough

Adds an iOS Simulator test that relaunches the playground app, opens the Basic UI screen, verifies orientation-specific elements, and checks screenshot dimensions in portrait and landscape. Adds helpers for tapping named elements, reading and setting device orientation, and asserting that elements are absent from the UI hierarchy.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive No description was provided, so there is no meaningful change summary to evaluate. Add a short description explaining the new device orientation test coverage and helper changes.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: adding device orientation tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch tests-orientation-tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/simulator.spec.ts`:
- Around line 264-304: Update the “should rotate the playground app between
portrait and landscape” test to capture the simulator’s original orientation,
set portrait before app navigation and initial assertions, and wrap the rotation
flow in try/finally. In the finally block, restore the captured orientation so
failures cannot leave the simulator in landscape.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ff103dd4-4d6a-4f74-9172-b0db22d1cc27

📥 Commits

Reviewing files that changed from the base of the PR and between dbb1e9c and a6ad79c.

📒 Files selected for processing (1)
  • test/simulator.spec.ts

Comment thread test/simulator.spec.ts
Comment on lines +264 to +304
test('should rotate the playground app between portrait and landscape', async () => {
test.skip(!simulatorId, 'simulator not found');

// starting the device agent dismisses whatever is in the foreground,
// so warm it up before launching the app under test
dumpUI(simulatorId);

// relaunch so the app starts at its root menu instead of a previously visited screen
terminateApp(simulatorId, 'com.mobilenext.playground');
await new Promise(resolve => setTimeout(resolve, 2000));
launchApp(simulatorId, 'com.mobilenext.playground');
await new Promise(resolve => setTimeout(resolve, 5000));

tapElementByName(simulatorId, 'Basic UI');
await new Promise(resolve => setTimeout(resolve, 3000));
verifyElementExists(dumpUI(simulatorId), 'Reset Counter');

expect(getOrientation(simulatorId)).toBe('portrait');
const portraitScreenshot = getScreenshotDimensions(simulatorId);
expect(portraitScreenshot.height).toBeGreaterThan(portraitScreenshot.width);

setOrientation(simulatorId, 'landscape');
await new Promise(resolve => setTimeout(resolve, 3000));
expect(getOrientation(simulatorId)).toBe('landscape');

// the shorter landscape viewport pushes Reset Counter below the fold,
// while Text Input stays visible at the top of the form
const landscapeDump = dumpUI(simulatorId);
verifyElementDoesNotExist(landscapeDump, 'Reset Counter');
verifyElementExists(landscapeDump, 'Text Input');

const landscapeScreenshot = getScreenshotDimensions(simulatorId);
expect(landscapeScreenshot.width).toBeGreaterThan(landscapeScreenshot.height);

setOrientation(simulatorId, 'portrait');
await new Promise(resolve => setTimeout(resolve, 3000));
expect(getOrientation(simulatorId)).toBe('portrait');

const restoredScreenshot = getScreenshotDimensions(simulatorId);
expect(restoredScreenshot.height).toBeGreaterThan(restoredScreenshot.width);
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Make orientation setup and cleanup failure-safe.

The simulator can begin in landscape, causing the portrait assertions to fail before line 285. Also, any failure after rotation skips lines 298-300 and leaks landscape state into subsequent tests. Capture the original orientation, explicitly set portrait before navigating, and restore the original state in try/finally.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/simulator.spec.ts` around lines 264 - 304, Update the “should rotate the
playground app between portrait and landscape” test to capture the simulator’s
original orientation, set portrait before app navigation and initial assertions,
and wrap the rotation flow in try/finally. In the finally block, restore the
captured orientation so failures cannot leave the simulator in landscape.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant