react-native-navigation的迁移库

ScreenStyle.test.js 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 navigationOptions on container component', async () => {
  9. await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
  10. await expect(element(by.label('Static Title'))).toBeVisible();
  11. });
  12. it('change title on container component', async () => {
  13. await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
  14. await expect(element(by.label('Static Title'))).toBeVisible();
  15. await elementById(testIDs.DYNAMIC_OPTIONS_BUTTON).tap();
  16. await expect(element(by.label('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('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', 'fast');
  37. await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeNotVisible();
  38. await element(by.id(testIDs.SCROLLVIEW_ELEMENT)).swipe('down', 'fast');
  39. await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
  40. });
  41. it('makes topBar transparent and opaque', async () => {
  42. await elementByLabel('Push Options Screen').tap();
  43. await elementByLabel('Top Bar Transparent').tap();
  44. await expect(element(by.type('_UIVisualEffectBackdropView'))).toBeNotVisible();
  45. await elementByLabel('Top Bar Opaque').tap();
  46. await expect(element(by.type('_UIVisualEffectBackdropView')).atIndex(1)).toBeVisible();
  47. });
  48. it('set Tab Bar badge on a current Tab', async () => {
  49. await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
  50. await elementById(testIDs.SET_TAB_BADGE_BUTTON).tap();
  51. await expect(element(by.text('TeSt'))).toBeVisible();
  52. });
  53. it('hide Tab Bar', async () => {
  54. await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
  55. await expect(elementById(testIDs.BOTTOM_TABS_ELEMENT)).toBeVisible();
  56. await elementById(testIDs.HIDE_BOTTOM_TABS_BUTTON).tap();
  57. await expect(elementById(testIDs.BOTTOM_TABS_ELEMENT)).toBeNotVisible();
  58. });
  59. it('show Tab Bar', async () => {
  60. await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
  61. await elementById(testIDs.HIDE_BOTTOM_TABS_BUTTON).tap();
  62. await expect(elementById(testIDs.BOTTOM_TABS_ELEMENT)).toBeNotVisible();
  63. await elementById(testIDs.SHOW_BOTTOM_TABS_BUTTON).tap();
  64. await expect(elementById(testIDs.BOTTOM_TABS_ELEMENT)).toBeVisible();
  65. });
  66. it('side menu visibility - left', async () => {
  67. await elementById(testIDs.TAB_BASED_APP_SIDE_BUTTON).tap();
  68. await elementById(testIDs.SHOW_LEFT_SIDE_MENU_BUTTON).tap();
  69. await expect(elementById(testIDs.HIDE_LEFT_SIDE_MENU_BUTTON)).toBeVisible();
  70. await elementById(testIDs.HIDE_LEFT_SIDE_MENU_BUTTON).tap();
  71. await expect(elementById(testIDs.CENTERED_TEXT_HEADER)).toBeVisible();
  72. });
  73. it('side menu visibility - right', async () => {
  74. await elementById(testIDs.TAB_BASED_APP_SIDE_BUTTON).tap();
  75. await elementById(testIDs.SHOW_RIGHT_SIDE_MENU_BUTTON).tap();
  76. await expect(elementById(testIDs.HIDE_RIGHT_SIDE_MENU_BUTTON)).toBeVisible();
  77. await elementById(testIDs.HIDE_RIGHT_SIDE_MENU_BUTTON).tap();
  78. await expect(elementById(testIDs.CENTERED_TEXT_HEADER)).toBeVisible();
  79. });
  80. it('set right buttons', async () => {
  81. await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
  82. await expect(elementById('buttonOne')).toBeVisible();
  83. await elementById('buttonOne').tap();
  84. await expect(elementById('buttonTwo')).toBeVisible();
  85. await elementById('buttonTwo').tap();
  86. await expect(elementById('buttonOne')).toBeVisible();
  87. });
  88. it('set left buttons', async () => {
  89. await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
  90. await expect(elementById('buttonLeft')).toBeVisible();
  91. });
  92. });