react-native-navigation的迁移库

ScreenStack.test.js 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. const Utils = require('./Utils');
  2. const testIDs = require('../playground/src/testIDs');
  3. const Android = require('./AndroidUtils');
  4. const { elementByLabel, elementById, sleep } = Utils;
  5. describe('screen stack', () => {
  6. beforeEach(async () => {
  7. await device.relaunchApp();
  8. });
  9. it('push and pop screen', async () => {
  10. await elementById(testIDs.PUSH_BUTTON).tap();
  11. await expect(elementById(testIDs.PUSHED_SCREEN_HEADER)).toBeVisible();
  12. await elementById(testIDs.POP_BUTTON).tap();
  13. await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
  14. });
  15. it('pop screen deep in the stack', async () => {
  16. await elementById(testIDs.PUSH_BUTTON).tap();
  17. await expect(elementByLabel('Stack Position: 1')).toBeVisible();
  18. await elementById(testIDs.PUSH_BUTTON).tap();
  19. await expect(elementByLabel('Stack Position: 2')).toBeVisible();
  20. await elementById(testIDs.POP_PREVIOUS_BUTTON).tap();
  21. await expect(elementByLabel('Stack Position: 2')).toBeVisible();
  22. await elementById(testIDs.POP_BUTTON).tap();
  23. await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
  24. });
  25. it('pop to specific id', async () => {
  26. await elementById(testIDs.PUSH_BUTTON).tap();
  27. await elementById(testIDs.PUSH_BUTTON).tap();
  28. await elementById(testIDs.PUSH_BUTTON).tap();
  29. await expect(elementByLabel('Stack Position: 3')).toBeVisible();
  30. await elementById(testIDs.POP_STACK_POSITION_ONE_BUTTON).tap();
  31. await expect(elementByLabel('Stack Position: 1')).toBeVisible();
  32. });
  33. it('pop to root', async () => {
  34. await elementById(testIDs.PUSH_BUTTON).tap();
  35. await elementById(testIDs.PUSH_BUTTON).tap();
  36. await elementById(testIDs.PUSH_BUTTON).tap();
  37. await elementById(testIDs.POP_TO_ROOT).tap();
  38. await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
  39. });
  40. it('switch to tab', async () => {
  41. await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
  42. await expect(elementByLabel('This is tab 1')).toBeVisible();
  43. await elementById(testIDs.SWITCH_SECOND_TAB_BUTTON).tap();
  44. await expect(elementByLabel('This is tab 1')).toBeNotVisible();
  45. await expect(elementByLabel('This is tab 2')).toBeVisible();
  46. });
  47. it('switch to tab by cotnainerId', async () => {
  48. await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
  49. await expect(elementByLabel('This is tab 1')).toBeVisible();
  50. await elementById(testIDs.SWITCH_SECOND_TAB_BUTTON).tap();
  51. await expect(elementByLabel('This is tab 2')).toBeVisible();
  52. await elementById(testIDs.SWITCH_FIRST_TAB_BUTTON).tap();
  53. await expect(elementByLabel('This is tab 1')).toBeVisible();
  54. });
  55. it('push stack with multiple children', async () => {
  56. await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
  57. await elementById(testIDs.MODAL_WITH_STACK_BUTTON).tap();
  58. await expect(elementByLabel('Screen 2')).toBeVisible();
  59. await elementById(testIDs.POP_BUTTON).tap();
  60. await expect(elementByLabel('Screen 1')).toBeVisible();
  61. });
  62. it('push external component with options', async () => {
  63. await elementById(testIDs.PUSH_EXTERNAL_COMPONENT_BUTTON).tap();
  64. await expect(elementByLabel('This is an external component')).toBeVisible();
  65. await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
  66. });
  67. });