react-native-navigation的迁移库

ScreenStack.test.js 4.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. const Utils = require('./Utils');
  2. const testIDs = require('../playground/src/testIDs');
  3. const { elementByLabel, elementById } = Utils;
  4. describe('screen stack', () => {
  5. beforeEach(async () => {
  6. await device.relaunchApp();
  7. });
  8. it('push and pop screen', async () => {
  9. await elementById(testIDs.PUSH_BUTTON).tap();
  10. await expect(elementById(testIDs.PUSHED_SCREEN_HEADER)).toBeVisible();
  11. await elementById(testIDs.POP_BUTTON).tap();
  12. await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
  13. });
  14. it('pop screen deep in the stack', async () => {
  15. await elementById(testIDs.PUSH_BUTTON).tap();
  16. await expect(elementByLabel('Stack Position: 1')).toBeVisible();
  17. await elementById(testIDs.PUSH_BUTTON).tap();
  18. await expect(elementByLabel('Stack Position: 2')).toBeVisible();
  19. await elementById(testIDs.POP_PREVIOUS_BUTTON).tap();
  20. await expect(elementByLabel('Stack Position: 2')).toBeVisible();
  21. await elementById(testIDs.POP_BUTTON).tap();
  22. await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
  23. });
  24. it('pop to specific id', async () => {
  25. await elementById(testIDs.PUSH_BUTTON).tap();
  26. await elementById(testIDs.PUSH_BUTTON).tap();
  27. await elementById(testIDs.PUSH_BUTTON).tap();
  28. await expect(elementByLabel('Stack Position: 3')).toBeVisible();
  29. await elementById(testIDs.POP_STACK_POSITION_ONE_BUTTON).tap();
  30. await expect(elementByLabel('Stack Position: 1')).toBeVisible();
  31. });
  32. it('pop to root', async () => {
  33. await elementById(testIDs.PUSH_BUTTON).tap();
  34. await elementById(testIDs.PUSH_BUTTON).tap();
  35. await elementById(testIDs.PUSH_BUTTON).tap();
  36. await elementById(testIDs.POP_TO_ROOT).tap();
  37. await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
  38. });
  39. it('switch to tab', async () => {
  40. await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
  41. await expect(elementByLabel('This is tab 1')).toBeVisible();
  42. await elementById(testIDs.SWITCH_SECOND_TAB_BUTTON).tap();
  43. await expect(elementByLabel('This is tab 1')).toBeNotVisible();
  44. await expect(elementByLabel('This is tab 2')).toBeVisible();
  45. });
  46. it('switch to tab by cotnainerId', async () => {
  47. await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
  48. await expect(elementByLabel('This is tab 1')).toBeVisible();
  49. await elementById(testIDs.SWITCH_SECOND_TAB_BUTTON).tap();
  50. await expect(elementByLabel('This is tab 2')).toBeVisible();
  51. await elementById(testIDs.SWITCH_FIRST_TAB_BUTTON).tap();
  52. await expect(elementByLabel('This is tab 1')).toBeVisible();
  53. });
  54. it('show and dismiss overlay', async () => {
  55. await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
  56. await elementById(testIDs.SHOW_OVERLAY_BUTTON).tap();
  57. await expect(elementById(testIDs.DIALOG_HEADER)).toBeVisible();
  58. await elementById(testIDs.OK_BUTTON).tap();
  59. await expect(elementById(testIDs.DIALOG_HEADER)).toBeNotVisible();
  60. });
  61. it('overlay pass touches - true', async () => {
  62. await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
  63. await elementById(testIDs.SHOW_TOUCH_THROUGH_OVERLAY_BUTTON).tap();
  64. await expect(elementById(testIDs.DIALOG_HEADER)).toBeVisible();
  65. await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
  66. await elementById(testIDs.HIDE_TOP_BAR_BUTTON).tap();
  67. await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeNotVisible();
  68. });
  69. it('overlay pass touches - false', async () => {
  70. await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
  71. await elementById(testIDs.SHOW_OVERLAY_BUTTON).tap();
  72. await expect(elementById(testIDs.DIALOG_HEADER)).toBeVisible();
  73. await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
  74. await elementById(testIDs.HIDE_TOP_BAR_BUTTON).tap();
  75. await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
  76. });
  77. it('push stack with multiple children', async () => {
  78. await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
  79. await elementById(testIDs.MODAL_WITH_STACK_BUTTON).tap();
  80. await expect(elementByLabel('Screen 2')).toBeVisible();
  81. await Utils.tapBackIos();
  82. await expect(elementByLabel('Screen 1')).toBeVisible();
  83. });
  84. });