Oksana Stepanenko
11 months ago
15 changed files with 171 additions and 13 deletions
@ -0,0 +1,85 @@
@@ -0,0 +1,85 @@
|
||||
const { config } = require('@/config') |
||||
const { insertPhoneAndEnter, goToCreateTaskScreen } = require('./snippets') |
||||
|
||||
const requiredFields = ['executor', 'initiator', 'description', 'title'] |
||||
const currentDate = new Date() |
||||
|
||||
const checkFieldHasError = async fieldName => { |
||||
const field = `task${fieldName.charAt(0).toUpperCase()}${fieldName.slice( |
||||
1, |
||||
)}` |
||||
await waitFor( |
||||
element( |
||||
by |
||||
.id(`${field}Error`) |
||||
.and(by.text("Поле обов'язкове до заповнення")), |
||||
), |
||||
) |
||||
.toBeVisible() |
||||
.whileElement(by.id('editTaskScreenScroll')) |
||||
.scroll(250, 'up') |
||||
} |
||||
|
||||
describe('Create task reason', () => { |
||||
beforeAll(async () => { |
||||
await device.launchApp({ |
||||
permissions: { |
||||
notifications: 'YES', |
||||
}, |
||||
newInstance: true, |
||||
delete: true, |
||||
}) |
||||
}) |
||||
|
||||
it('Should success sign in the app with default phone number (need no confirmation)', async () => { |
||||
await insertPhoneAndEnter(config.defaultPhoneNumber) |
||||
await expect(element(by.id('homeScreen'))).toExist() |
||||
}) |
||||
|
||||
it('Should navigate to create task screen', async () => { |
||||
await goToCreateTaskScreen() |
||||
await expect(element(by.text('Нова задача'))).toBeVisible() |
||||
}) |
||||
|
||||
// ***** TEST SAVE EMPTY FIELDS *****
|
||||
|
||||
it('Should show errors under required fields when trying to create task without filling in those fields', async () => { |
||||
await element(by.id('editTaskScreenScroll')).scrollTo('bottom') |
||||
await element(by.id('saveTaskBtn')).tap() |
||||
|
||||
for await (const field of requiredFields) { |
||||
await checkFieldHasError(field) |
||||
} |
||||
}) |
||||
|
||||
it("Should show error when trying to create task with end date that doesn't meet requirements", async () => { |
||||
await element(by.id('editTaskScreenScroll')).scrollTo('top') |
||||
await element(by.id('taskStartDate')).tap() |
||||
if (device.getPlatform() === 'android') { |
||||
const date = currentDate.getDate() |
||||
await element(by.text(date.toString())).swipe('up', 'slow') |
||||
await element(by.id('datePickerView')).tap({ x: 30, y: -200 }) |
||||
} else { |
||||
const datePicker = element(by.id('datePicker')) |
||||
await datePicker.setDatePickerDate( |
||||
new Date( |
||||
currentDate.setDate(currentDate.getDate() + 2), |
||||
).toISOString(), |
||||
'ISO8601', |
||||
) |
||||
await element(by.type('RCTRootContentView')).tap({ x: 0, y: 0 }) |
||||
} |
||||
|
||||
await element(by.id('editTaskScreenScroll')).scrollTo('bottom') |
||||
await element(by.id('saveTaskBtn')).tap() |
||||
|
||||
await waitFor(element(by.id('taskDateError'))) |
||||
.toBeVisible() |
||||
.whileElement(by.id('editTaskScreenScroll')) |
||||
.scroll(250, 'up') |
||||
await expect(element(by.id('taskDateError'))).toBeVisible() |
||||
await expect(element(by.id('taskDateError'))).toHaveText( |
||||
'Кінцева дата не може бути меншою, ніж початкова', |
||||
) |
||||
}) |
||||
}) |
Loading…
Reference in new issue