| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 | const Utils = require('./Utils');
const elementByLabel = Utils.elementByLabel;
describe('modal', () => {
  beforeEach(async () => {
    await device.relaunchApp();
  });
  it('show modal', async () => {
    await elementByLabel('Show Modal').tap();
    await expect(elementByLabel('Modal Screen')).toBeVisible();
  });
  it('dismiss modal', async () => {
    await elementByLabel('Show Modal').tap();
    await expect(elementByLabel('Modal Screen')).toBeVisible();
    await elementByLabel('Dismiss Modal').tap();
    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
  });
  it('show multiple modals', async () => {
    await elementByLabel('Show Modal').tap();
    await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
    await elementByLabel('Show Modal').tap();
    await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
    await elementByLabel('Dismiss Modal').tap();
    await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
    await elementByLabel('Dismiss Modal').tap();
    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
  });
  it('dismiss unknown screen id', async () => {
    await elementByLabel('Show Modal').tap();
    await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
    await elementByLabel('Dismiss Unknown Modal').tap();
    await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
    await elementByLabel('Dismiss Modal').tap();
    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
  });
  it('dismiss modal by id which is not the top most', async () => {
    await elementByLabel('Show Modal').tap();
    await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
    await elementByLabel('Show Modal').tap();
    await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
    await elementByLabel('Dismiss Previous Modal').tap();
    await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
    await elementByLabel('Dismiss Modal').tap();
    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
  });
  it('dismiss all previous modals by id when they are below top presented modal', async () => {
    await elementByLabel('Show Modal').tap();
    await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
    await elementByLabel('Show Modal').tap();
    await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
    await elementByLabel('Show Modal').tap();
    await expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
    await elementByLabel('Dismiss ALL Previous Modals').tap();
    await expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
    await elementByLabel('Dismiss Modal').tap();
    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
  });
  it('dismiss some modal by id deep in the stack', async () => {
    await elementByLabel('Show Modal').tap();
    await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
    await elementByLabel('Show Modal').tap();
    await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
    await elementByLabel('Show Modal').tap();
    await expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
    await elementByLabel('Dismiss First In Stack').tap();
    await expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
    await elementByLabel('Dismiss Modal').tap();
    await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
    await elementByLabel('Dismiss Modal').tap();
    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
  });
  it('dismissAllModals', async () => {
    await elementByLabel('Show Modal').tap();
    await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
    await elementByLabel('Show Modal').tap();
    await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
    await elementByLabel('Dismiss All Modals').tap();
    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
  });
});
 |