react-native-navigation的迁移库

ScreenStack.test.js 3.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. const Utils = require('./Utils');
  2. const testIDs = require('../playground/src/testIDs');
  3. const { elementByLabel, elementById } = Utils;
  4. describe('screen stack', () => {
  5. beforeEach(async () => {
  6. await device.relaunchApp();
  7. });
  8. it('push and pop screen', async () => {
  9. await elementById(testIDs.PUSH_BUTTON).tap();
  10. await expect(elementById(testIDs.PUSHED_SCREEN_HEADER)).toBeVisible();
  11. await elementById(testIDs.POP_BUTTON).tap();
  12. await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
  13. });
  14. it('pop screen deep in the stack', async () => {
  15. await elementById(testIDs.PUSH_BUTTON).tap();
  16. await expect(elementByLabel('Stack Position: 1')).toBeVisible();
  17. await elementById(testIDs.PUSH_BUTTON).tap();
  18. await expect(elementByLabel('Stack Position: 2')).toBeVisible();
  19. await elementById(testIDs.POP_PREVIOUS_BUTTON).tap();
  20. await expect(elementByLabel('Stack Position: 2')).toBeVisible();
  21. await elementById(testIDs.POP_BUTTON).tap();
  22. await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
  23. });
  24. it('pop to specific id', async () => {
  25. await elementById(testIDs.PUSH_BUTTON).tap();
  26. await elementById(testIDs.PUSH_BUTTON).tap();
  27. await elementById(testIDs.PUSH_BUTTON).tap();
  28. await expect(elementByLabel('Stack Position: 3')).toBeVisible();
  29. await elementById(testIDs.POP_STACK_POSITION_ONE_BUTTON).tap();
  30. await expect(elementByLabel('Stack Position: 1')).toBeVisible();
  31. });
  32. it('pop to root', async () => {
  33. await elementById(testIDs.PUSH_BUTTON).tap();
  34. await elementById(testIDs.PUSH_BUTTON).tap();
  35. await elementById(testIDs.PUSH_BUTTON).tap();
  36. await elementById(testIDs.POP_TO_ROOT).tap();
  37. await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
  38. });
  39. it('switch to tab', async () => {
  40. await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
  41. await expect(elementByLabel('This is tab 1')).toBeVisible();
  42. await elementById(testIDs.SWITCH_SECOND_TAB_BUTTON).tap();
  43. await expect(elementByLabel('This is tab 1')).toBeNotVisible();
  44. await expect(elementByLabel('This is tab 2')).toBeVisible();
  45. });
  46. it('switch to tab by cotnainerId', async () => {
  47. await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
  48. await expect(elementByLabel('This is tab 1')).toBeVisible();
  49. await elementById(testIDs.SWITCH_SECOND_TAB_BUTTON).tap();
  50. await expect(elementByLabel('This is tab 2')).toBeVisible();
  51. await elementById(testIDs.SWITCH_FIRST_TAB_BUTTON).tap();
  52. await expect(elementByLabel('This is tab 1')).toBeVisible();
  53. });
  54. it('push stack with multiple children', async () => {
  55. await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
  56. await elementById(testIDs.MODAL_WITH_STACK_BUTTON).tap();
  57. await expect(elementByLabel('Screen 2')).toBeVisible();
  58. await elementById(testIDs.POP_BUTTON).tap();
  59. await expect(elementByLabel('Screen 1')).toBeVisible();
  60. });
  61. it(':ios: push native component with options', async () => {
  62. await elementById(testIDs.PUSH_NATIVE_COMPONENT_BUTTON).tap();
  63. await expect(elementById('TestLabel')).toBeVisible();
  64. await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
  65. });
  66. });