react-native-navigation的迁移库

ScreenStyle.test.js 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. it('declare a options on component component', async () => {
  9. await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
  10. await expect(elementByLabel('Static Title')).toBeVisible();
  11. });
  12. it('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. it('set dynamic options with valid options will do something and not crash', async () => {
  19. await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
  20. await elementById(testIDs.DYNAMIC_OPTIONS_BUTTON).tap();
  21. await expect(elementById(testIDs.OPTIONS_SCREEN_HEADER)).toBeVisible();
  22. });
  23. it('hides Tab Bar when pressing on Hide Top Bar and shows it when pressing on Show Top Bar', async () => {
  24. await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
  25. await elementById(testIDs.HIDE_TOP_BAR_BUTTON).tap();
  26. await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeNotVisible();
  27. await elementById(testIDs.SHOW_TOP_BAR_BUTTON).tap();
  28. await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
  29. });
  30. xit('hides topBar onScroll down and shows it on scroll up', async () => {
  31. await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
  32. await elementById(testIDs.SCROLLVIEW_SCREEN_BUTTON).tap();
  33. await elementById(testIDs.TOGGLE_TOP_BAR_HIDE_ON_SCROLL).tap();
  34. await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
  35. await element(by.id(testIDs.SCROLLVIEW_ELEMENT)).swipe('up', 'slow');
  36. await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeNotVisible();
  37. await element(by.id(testIDs.SCROLLVIEW_ELEMENT)).swipe('down', 'fast');
  38. await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
  39. });
  40. it('set Tab Bar badge on a current Tab', async () => {
  41. await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
  42. await elementById(testIDs.SET_TAB_BADGE_BUTTON).tap();
  43. await expect(element(by.text('TeSt'))).toBeVisible();
  44. });
  45. it('hide Tab Bar', async () => {
  46. await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
  47. await expect(elementById(testIDs.BOTTOM_TABS_ELEMENT)).toBeVisible();
  48. await elementById(testIDs.HIDE_BOTTOM_TABS_BUTTON).tap();
  49. await expect(elementById(testIDs.BOTTOM_TABS_ELEMENT)).toBeNotVisible();
  50. });
  51. it('show Tab Bar', async () => {
  52. await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
  53. await elementById(testIDs.HIDE_BOTTOM_TABS_BUTTON).tap();
  54. await expect(elementById(testIDs.BOTTOM_TABS_ELEMENT)).toBeNotVisible();
  55. await elementById(testIDs.SHOW_BOTTOM_TABS_BUTTON).tap();
  56. await expect(elementById(testIDs.BOTTOM_TABS_ELEMENT)).toBeVisible();
  57. });
  58. it('side menu visibility - left', async () => {
  59. await elementById(testIDs.TAB_BASED_APP_SIDE_BUTTON).tap();
  60. await elementById(testIDs.SHOW_LEFT_SIDE_MENU_BUTTON).tap();
  61. await expect(elementById(testIDs.HIDE_LEFT_SIDE_MENU_BUTTON)).toBeVisible();
  62. await elementById(testIDs.HIDE_LEFT_SIDE_MENU_BUTTON).tap();
  63. await expect(elementById(testIDs.CENTERED_TEXT_HEADER)).toBeVisible();
  64. });
  65. it('side menu visibility - right', async () => {
  66. await elementById(testIDs.TAB_BASED_APP_SIDE_BUTTON).tap();
  67. await elementById(testIDs.SHOW_RIGHT_SIDE_MENU_BUTTON).tap();
  68. await expect(elementById(testIDs.HIDE_RIGHT_SIDE_MENU_BUTTON)).toBeVisible();
  69. await elementById(testIDs.HIDE_RIGHT_SIDE_MENU_BUTTON).tap();
  70. await expect(elementById(testIDs.CENTERED_TEXT_HEADER)).toBeVisible();
  71. });
  72. it('set right buttons', async () => {
  73. await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
  74. await expect(elementById('buttonOne')).toBeVisible();
  75. await elementById('buttonOne').tap();
  76. await expect(elementById('buttonTwo')).toBeVisible();
  77. await elementById('buttonTwo').tap();
  78. await expect(elementById('buttonOne')).toBeVisible();
  79. });
  80. it('set left buttons', async () => {
  81. await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
  82. await expect(elementById('buttonLeft')).toBeVisible();
  83. });
  84. it('tab bar items visibility', async () => {
  85. await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
  86. await expect(elementById(testIDs.FIRST_TAB_BAR_BUTTON)).toBeVisible();
  87. await expect(elementById(testIDs.SECOND_TAB_BAR_BUTTON)).toBeVisible();
  88. });
  89. it('default options should apply to all screens in stack', async () => {
  90. await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
  91. await elementById(testIDs.PUSH_DEFAULT_OPTIONS_BUTTON).tap();
  92. await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeNotVisible();
  93. await elementById(testIDs.PUSH_BUTTON).tap();
  94. await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeNotVisible();
  95. });
  96. it('default options should not override static options', async () => {
  97. await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
  98. await elementById(testIDs.PUSH_DEFAULT_OPTIONS_BUTTON).tap();
  99. await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeNotVisible();
  100. await elementById(testIDs.POP_BUTTON).tap();
  101. await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
  102. });
  103. it('supports user-provided id', async () => {
  104. await elementById(testIDs.PROVIDED_ID).tap();
  105. await expect(elementByLabel('User provided id')).toBeVisible();
  106. });
  107. it('stack options should not override component options', async () => {
  108. await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
  109. await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
  110. });
  111. it('set title component', async () => {
  112. await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
  113. await elementById(testIDs.SHOW_TOPBAR_REACT_VIEW).tap();
  114. await expect(elementByLabel('Press Me')).toBeVisible();
  115. });
  116. });