react-native-navigation的迁移库

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. const Utils = require('./Utils');
  2. const Android = require('./AndroidUtils');
  3. const TestIDs = require('../playground/src/testIDs');
  4. const { elementById, elementByLabel } = Utils;
  5. describe('Options', () => {
  6. beforeEach(async () => {
  7. await device.relaunchApp();
  8. await elementById(TestIDs.OPTIONS_TAB).tap();
  9. });
  10. it('declare options on a component', async () => {
  11. await expect(elementByLabel('Styling Options')).toBeVisible();
  12. });
  13. it('change title on component component', async () => {
  14. await expect(elementByLabel('Styling Options')).toBeVisible();
  15. await elementById(TestIDs.CHANGE_TITLE_BTN).tap();
  16. await expect(elementByLabel('Title Changed')).toBeVisible();
  17. });
  18. it('hides TopBar when pressing on Hide TopBar and shows it when pressing on Show TopBar', async () => {
  19. await elementById(TestIDs.HIDE_TOP_BAR_BTN).tap();
  20. await expect(elementById(TestIDs.TOP_BAR)).toBeNotVisible();
  21. await elementById(TestIDs.SHOW_TOP_BAR_BTN).tap();
  22. await expect(elementById(TestIDs.TOP_BAR)).toBeVisible();
  23. });
  24. it('sets right buttons', async () => {
  25. await expect(elementById(TestIDs.BUTTON_ONE)).toBeVisible();
  26. await expect(elementById(TestIDs.ROUND_BUTTON)).toBeVisible();
  27. });
  28. it('set left buttons', async () => {
  29. await expect(elementById(TestIDs.LEFT_BUTTON)).toBeVisible();
  30. });
  31. it('pass props to custom button component', async () => {
  32. await expect(elementByLabel('Two')).toExist();
  33. });
  34. it('pass props to custom button component should exist after push pop', async () => {
  35. await expect(elementByLabel('Two')).toExist();
  36. await elementById(TestIDs.PUSH_BTN).tap();
  37. await elementById(TestIDs.POP_BTN).tap();
  38. await expect(elementByLabel('Two')).toExist();
  39. });
  40. it('custom button is clickable', async () => {
  41. await elementByLabel('Two').tap();
  42. await expect(elementByLabel('Thanks for that :)')).toExist();
  43. });
  44. it('default options should apply to all screens in stack', async () => {
  45. await elementById(TestIDs.HIDE_TOPBAR_DEFAULT_OPTIONS).tap();
  46. await expect(elementById(TestIDs.TOP_BAR)).toBeVisible();
  47. await elementById(TestIDs.PUSH_BTN).tap();
  48. await expect(elementById(TestIDs.PUSHED_SCREEN_HEADER)).toBeNotVisible();
  49. await elementById(TestIDs.PUSH_BTN).tap();
  50. await expect(elementById(TestIDs.PUSHED_SCREEN_HEADER)).toBeNotVisible();
  51. });
  52. it('default options should not override static options', async () => {
  53. await elementById(TestIDs.HIDE_TOPBAR_DEFAULT_OPTIONS).tap();
  54. await elementById(TestIDs.PUSH_BTN).tap();
  55. await elementById(TestIDs.POP_BTN).tap();
  56. await expect(elementById(TestIDs.TOP_BAR)).toBeVisible();
  57. await expect(elementByLabel('Styling Options')).toBeVisible();
  58. });
  59. it('set title component', async () => {
  60. await elementById(TestIDs.SET_REACT_TITLE_VIEW).tap();
  61. await expect(elementByLabel('Press Me')).toBeVisible();
  62. });
  63. it('set title after setting react component', async () => {
  64. await elementById(TestIDs.SET_REACT_TITLE_VIEW).tap();
  65. await expect(elementByLabel('Press Me')).toBeVisible();
  66. await elementById(TestIDs.CHANGE_TITLE_BTN).tap();
  67. await expect(elementByLabel('Title Changed')).toBeVisible();
  68. });
  69. it('Popping screen with yellow box should not crash', async () => {
  70. await elementById(TestIDs.SHOW_YELLOW_BOX_BTN).tap();
  71. await elementById(TestIDs.PUSH_BTN).tap();
  72. await elementById(TestIDs.POP_BTN).tap();
  73. await expect(elementByLabel('Styling Options')).toBeVisible();
  74. });
  75. xit('hides topBar onScroll down and shows it on scroll up', async () => {
  76. await elementById(TestIDs.PUSH_OPTIONS_BUTTON).tap();
  77. await elementById(TestIDs.SCROLLVIEW_SCREEN_BUTTON).tap();
  78. await elementById(TestIDs.TOGGLE_TOP_BAR_HIDE_ON_SCROLL).tap();
  79. await expect(elementById(TestIDs.TOP_BAR)).toBeVisible();
  80. await element(by.id(TestIDs.SCROLLVIEW_ELEMENT)).swipe('up', 'slow');
  81. await expect(elementById(TestIDs.TOP_BAR)).toBeNotVisible();
  82. await element(by.id(TestIDs.SCROLLVIEW_ELEMENT)).swipe('down', 'fast');
  83. await expect(elementById(TestIDs.TOP_BAR)).toBeVisible();
  84. });
  85. });