Files
react-native/RNTester/e2e/__tests__/DatePickerIOS-test.js
Mike Grabowski 8270de9c2c Fix DatePickerIOS e2e tests (#23861)
Summary:
DatePickerIOS tests stopped working after US changed their time zone on CircleCI. I decided to update the tests to be more reliable, by:
- removing "timezoneoffset" from the examples - I don't think it's needed. We don't demonstrate other props and it was causing us some troubles when timezones actually changed
- changing "interval" example from "time-only" to "datetime" because there's a known bug that prevented the previous example from working https://github.com/facebook/react-native/issues/9566
- splitting the label to two: one for date and other one for time, so that we can match the date only when we test "date" mode only

[IOS] [FIXED] - Improved reliability of DatePickerIOS e2e tests
Pull Request resolved: https://github.com/facebook/react-native/pull/23861

Differential Revision: D14434324

Pulled By: cpojer

fbshipit-source-id: 0f82b7e94bb1cb6ce75b44badd0064d1754370b9
2019-03-12 18:35:02 -07:00

69 lines
2.1 KiB
JavaScript

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @emails oncall+react_native
* @format
*/
/* global element, by, expect, device */
const {
openComponentWithLabel,
openExampleWithTitle,
} = require('../e2e-helpers');
describe('DatePickerIOS', () => {
beforeAll(async () => {
await device.reloadReactNative();
await openComponentWithLabel(
'<DatePickerIOS>',
'<DatePickerIOS> Select dates and times using the native UIDatePicker.',
);
});
it('Should change indicator with datetime picker', async () => {
await openExampleWithTitle('Date and time picker');
const testID = 'date-and-time';
const testElement = await element(
by.type('UIPickerView').withAncestor(by.id(testID)),
);
const dateIndicator = await element(by.id('date-indicator'));
const timeIndicator = await element(by.id('time-indicator'));
await expect(testElement).toBeVisible();
await expect(dateIndicator).toBeVisible();
await expect(timeIndicator).toBeVisible();
await testElement.setColumnToValue(0, 'Dec 4');
await testElement.setColumnToValue(1, '4');
await testElement.setColumnToValue(2, '10');
await testElement.setColumnToValue(3, 'AM');
await expect(dateIndicator).toHaveText('12/4/2005');
await expect(timeIndicator).toHaveText('4:10 AM');
});
it('Should change indicator with date-only picker', async () => {
await openExampleWithTitle('Date only picker');
const testID = 'date-only';
const testElement = await element(
by.type('UIPickerView').withAncestor(by.id(testID)),
);
const indicator = await element(by.id('date-indicator'));
await expect(testElement).toBeVisible();
await expect(indicator).toBeVisible();
await testElement.setColumnToValue(0, 'November');
await testElement.setColumnToValue(1, '3');
await testElement.setColumnToValue(2, '2006');
await expect(indicator).toHaveText('11/3/2006');
});
});