react-native-navigation的迁移库

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. const Utils = require('./Utils');
  2. const testIDs = require('../playground/src/testIDs');
  3. const { elementByLabel, elementById } = Utils;
  4. describe('modal', () => {
  5. beforeEach(async () => {
  6. await device.relaunchApp();
  7. });
  8. it('show modal', async () => {
  9. await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
  10. await expect(elementById(testIDs.MODAL_SCREEN)).toBeVisible();
  11. });
  12. it('dismiss modal', async () => {
  13. await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
  14. await expect(elementById(testIDs.MODAL_SCREEN)).toBeVisible();
  15. await elementById(testIDs.DISMISS_MODAL_BUTTON).tap();
  16. await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
  17. });
  18. it('show multiple modals', async () => {
  19. await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
  20. await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
  21. await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
  22. await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
  23. await elementById(testIDs.DISMISS_MODAL_BUTTON).tap();
  24. await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
  25. await elementById(testIDs.DISMISS_MODAL_BUTTON).tap();
  26. await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
  27. });
  28. it('dismiss unknown screen id', async () => {
  29. await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
  30. await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
  31. await elementById(testIDs.DISMISS_UNKNOWN_MODAL_BUTTON).tap();
  32. await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
  33. await elementById(testIDs.DISMISS_MODAL_BUTTON).tap();
  34. await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
  35. });
  36. it('dismiss modal by id which is not the top most', async () => {
  37. await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
  38. await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
  39. await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
  40. await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
  41. await elementById(testIDs.DISMISS_PREVIOUS_MODAL_BUTTON).tap();
  42. await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
  43. await elementById(testIDs.DISMISS_MODAL_BUTTON).tap();
  44. await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
  45. });
  46. it('dismiss all previous modals by id when they are below top presented modal', async () => {
  47. await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
  48. await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
  49. await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
  50. await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
  51. await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
  52. await expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
  53. await elementById(testIDs.DISMISS_ALL_PREVIOUS_MODAL_BUTTON).tap();
  54. await expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
  55. await elementById(testIDs.DISMISS_MODAL_BUTTON).tap();
  56. await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
  57. });
  58. it('dismiss some modal by id deep in the stack', async () => {
  59. await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
  60. await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
  61. await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
  62. await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
  63. await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
  64. await expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
  65. await elementById(testIDs.DISMISS_FIRST_MODAL_BUTTON).tap();
  66. await expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
  67. await elementById(testIDs.DISMISS_MODAL_BUTTON).tap();
  68. await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
  69. await elementById(testIDs.DISMISS_MODAL_BUTTON).tap();
  70. await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
  71. });
  72. it('dismissAllModals', async () => {
  73. await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
  74. await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
  75. await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
  76. await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
  77. await elementById(testIDs.DISMISS_ALL_MODALS_BUTTON).tap();
  78. await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
  79. });
  80. });