react-native-navigation的迁移库

ScreenStyle.test.js 5.9KB

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