react-native-navigation的迁移库

ScreenStyle.test.js 6.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. const Utils = require('./Utils');
  2. const testIDs = require('../playground/src/testIDs');
  3. const { elementById, elementByLabel } = Utils;
  4. describe('screen style', () => {
  5. beforeEach(async () => {
  6. await device.relaunchApp();
  7. });
  8. test('declare a options on component component', async () => {
  9. await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
  10. await expect(elementByLabel('Static Title')).toBeVisible();
  11. });
  12. test('change title on component component', async () => {
  13. await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
  14. await expect(elementByLabel('Static Title')).toBeVisible();
  15. await elementById(testIDs.DYNAMIC_OPTIONS_BUTTON).tap();
  16. await expect(elementByLabel('Dynamic Title')).toBeVisible();
  17. });
  18. test(
  19. 'set dynamic options with valid options will do something and not crash',
  20. async () => {
  21. await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
  22. await elementById(testIDs.DYNAMIC_OPTIONS_BUTTON).tap();
  23. await expect(elementById(testIDs.OPTIONS_SCREEN_HEADER)).toBeVisible();
  24. }
  25. );
  26. test(
  27. 'hides Tab Bar when pressing on Hide Top Bar and shows it when pressing on Show Top Bar',
  28. async () => {
  29. await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
  30. await elementById(testIDs.HIDE_TOP_BAR_BUTTON).tap();
  31. await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeNotVisible();
  32. await elementById(testIDs.SHOW_TOP_BAR_BUTTON).tap();
  33. await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
  34. }
  35. );
  36. xit('hides topBar onScroll down and shows it on scroll up', async () => {
  37. await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
  38. await elementById(testIDs.SCROLLVIEW_SCREEN_BUTTON).tap();
  39. await elementById(testIDs.TOGGLE_TOP_BAR_HIDE_ON_SCROLL).tap();
  40. await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
  41. await element(by.id(testIDs.SCROLLVIEW_ELEMENT)).swipe('up', 'slow');
  42. await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeNotVisible();
  43. await element(by.id(testIDs.SCROLLVIEW_ELEMENT)).swipe('down', 'fast');
  44. await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
  45. });
  46. test('set Tab Bar badge on a current Tab', async () => {
  47. await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
  48. await elementById(testIDs.SET_TAB_BADGE_BUTTON).tap();
  49. await expect(element(by.text('TeSt'))).toBeVisible();
  50. });
  51. test('hide Tab Bar', async () => {
  52. await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
  53. await expect(elementById(testIDs.BOTTOM_TABS_ELEMENT)).toBeVisible();
  54. await elementById(testIDs.HIDE_BOTTOM_TABS_BUTTON).tap();
  55. await expect(elementById(testIDs.BOTTOM_TABS_ELEMENT)).toBeNotVisible();
  56. });
  57. test('show Tab Bar', async () => {
  58. await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
  59. await elementById(testIDs.HIDE_BOTTOM_TABS_BUTTON).tap();
  60. await expect(elementById(testIDs.BOTTOM_TABS_ELEMENT)).toBeNotVisible();
  61. await elementById(testIDs.SHOW_BOTTOM_TABS_BUTTON).tap();
  62. await expect(elementById(testIDs.BOTTOM_TABS_ELEMENT)).toBeVisible();
  63. });
  64. test('side menu visibility - left', async () => {
  65. await elementById(testIDs.TAB_BASED_APP_SIDE_BUTTON).tap();
  66. await elementById(testIDs.SHOW_LEFT_SIDE_MENU_BUTTON).tap();
  67. await expect(elementById(testIDs.HIDE_LEFT_SIDE_MENU_BUTTON)).toBeVisible();
  68. await elementById(testIDs.HIDE_LEFT_SIDE_MENU_BUTTON).tap();
  69. await expect(elementById(testIDs.CENTERED_TEXT_HEADER)).toBeVisible();
  70. });
  71. test('side menu visibility - right', async () => {
  72. await elementById(testIDs.TAB_BASED_APP_SIDE_BUTTON).tap();
  73. await elementById(testIDs.SHOW_RIGHT_SIDE_MENU_BUTTON).tap();
  74. await expect(elementById(testIDs.HIDE_RIGHT_SIDE_MENU_BUTTON)).toBeVisible();
  75. await elementById(testIDs.HIDE_RIGHT_SIDE_MENU_BUTTON).tap();
  76. await expect(elementById(testIDs.CENTERED_TEXT_HEADER)).toBeVisible();
  77. });
  78. test('set right buttons', async () => {
  79. await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
  80. await expect(elementById('buttonOne')).toBeVisible();
  81. await elementById('buttonOne').tap();
  82. await expect(elementById('buttonTwo')).toBeVisible();
  83. await elementById('buttonTwo').tap();
  84. await expect(elementById('buttonOne')).toBeVisible();
  85. });
  86. test('set left buttons', async () => {
  87. await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
  88. await expect(elementById('buttonLeft')).toBeVisible();
  89. });
  90. test('pass props to custom button component', async () => {
  91. await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
  92. await expect(elementByLabel(`Two`)).toExist();
  93. });
  94. test('tab bar items visibility', async () => {
  95. await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
  96. await expect(elementById(testIDs.FIRST_TAB_BAR_BUTTON)).toBeVisible();
  97. await expect(elementById(testIDs.SECOND_TAB_BAR_BUTTON)).toBeVisible();
  98. });
  99. test('default options should apply to all screens in stack', async () => {
  100. await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
  101. await elementById(testIDs.PUSH_DEFAULT_OPTIONS_BUTTON).tap();
  102. await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeNotVisible();
  103. await elementById(testIDs.PUSH_BUTTON).tap();
  104. await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeNotVisible();
  105. });
  106. test('default options should not override static options', async () => {
  107. await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
  108. await elementById(testIDs.PUSH_DEFAULT_OPTIONS_BUTTON).tap();
  109. await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeNotVisible();
  110. await elementById(testIDs.POP_BUTTON).tap();
  111. await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
  112. });
  113. test('supports user-provided id', async () => {
  114. await elementById(testIDs.PROVIDED_ID).tap();
  115. await expect(elementByLabel('User provided id')).toBeVisible();
  116. });
  117. test('stack options should not override component options', async () => {
  118. await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
  119. await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
  120. });
  121. test('set title component', async () => {
  122. await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
  123. await elementById(testIDs.SHOW_TOPBAR_REACT_VIEW).tap();
  124. await expect(elementByLabel('Press Me')).toBeVisible();
  125. });
  126. test(':ios: set searchBar and handle onSearchUpdated event', async () => {
  127. await elementById(testIDs.SHOW_TOPBAR_SEARCHBAR).tap();
  128. await expect(elementByLabel('Start Typing')).toBeVisible();
  129. await elementByLabel('Start Typing').tap();
  130. const query = '124';
  131. await elementByLabel('Start Typing').typeText(query);
  132. await expect(elementById(testIDs.SEARCH_RESULT_ITEM)).toHaveText(`Item ${query}`);
  133. });
  134. });