Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: new tasks tests #4

Merged
merged 1 commit into from
Sep 29, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
238 changes: 238 additions & 0 deletions cypress/e2e/tasks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,95 @@ http.post(
)
})

it('can create a cron task', () => {
cy.getByTestID('empty-tasks-list').within(() => {
cy.getByTestID('add-resource-dropdown--button').click()
})

cy.getByTestID('add-resource-dropdown--new').click()

cy.getByTestID('flux-editor').within(() => {
cy.get('textarea.inputarea')
.click()
.type('from(bucket: "defbuck")\n' + '\t|> range(start: -2m)', {
force: true,
delay: 2,
})
})

cy.getByTestID('task-form-name')
.click()
.type('Cron task test')
.then(() => {
cy.getByTestID('task-card-cron-btn').click()
cy.getByTestID('task-form-schedule-input')
.click()
.type('0 4 8-14 * *')
cy.getByTestID('task-form-offset-input')
.click()
.type('10m')
})

cy.getByTestID('task-save-btn').click()

cy.getByTestID('task-card')
.contains('Cron task test')
.get('.cf-resource-meta--item')
.contains('Scheduled to run 0 4 8-14 * *')

cy.getByTestID('task-card')
.contains('Cron task test')
.click()
.then(() => {
cy.getByTestID('task-form-schedule-input').should(
'have.value',
'0 4 8-14 * *'
)
})
})

//skip until this issue is resolved
//https://github.com/influxdata/ui/issues/96
it.skip('can create a task with an option parameter', () => {
cy.getByTestID('empty-tasks-list').within(() => {
cy.getByTestID('add-resource-dropdown--button')
.click()
.then(() => {
cy.getByTestID('add-resource-dropdown--new').click()
})
})

cy.getByTestID('flux-editor').within(() => {
cy.get('textarea.inputarea')
.click()
.type(
'option task = \n' +
'{\n' +
'name: "Option Test", \n' +
'every: 24h, \n' +
'offset: 20m\n' +
'}\n' +
'from(bucket: "defbuck")\n' +
'\t|> range(start: -2m)'
)
})

cy.getByTestID('task-form-name')
.click()
.type('Option Test')
.then(() => {
cy.getByTestID('task-form-schedule-input')
.click()
.type('24h')
cy.getByTestID('task-form-offset-input')
.click()
.type('20m')
})

cy.getByTestID('task-save-btn').click()
cy.getByTestID('notification-success').should('exist')
})

describe('When tasks already exist', () => {
beforeEach(() => {
cy.get('@org').then(({id}: Organization) => {
Expand Down Expand Up @@ -186,6 +275,155 @@ http.post(
})
})
})

//skipping until this issue is resolved
//https://github.com/influxdata/influxdb/issues/18478
it.skip('can clone a task and activate just the cloned one', () => {
cy.getByTestID('task-card').then(() => {
cy.get('.context-menu--container')
.eq(1)
.click()
.then(() => {
cy.getByTestID('context-menu-item')
.contains('Clone')
.click()
})
})

cy.getByTestID('task-card--slide-toggle')
.eq(0)
.should('have.class', 'active')
.then(() => {
cy.getByTestID('task-card--slide-toggle')
.eq(0)
.click()
.then(() => {
cy.getByTestID('task-card--slide-toggle')
.eq(0)
.should('not.have.class', 'active')
cy.getByTestID('task-card--slide-toggle')
.eq(1)
.should('have.class', 'active')
})
})
})

it('can clone a task and edit it', () => {
//clone a task
cy.getByTestID('task-card')
.first()
.trigger('mouseover')
.then(() => {
cy.get('.context-menu--container')
.eq(1)
.within(() => {
cy.getByTestID('context-menu')
.click()
.then(() => {
cy.getByTestID('context-menu-item')
.contains('Clone')
.click()
})
})
})

cy.getByTestID('task-card').should('have.length', 2)

//assert the values of the task and change them
cy.getByTestID('task-card--name')
.eq(1)
.click()
.then(() => {
cy.getByTestID('task-form-name')
.should('have.value', '🦄ask')
.then(() => {
cy.getByTestID('task-form-name')
.click()
.clear()
.type('Copy task test')
.then(() => {
cy.getByTestID('task-form-schedule-input')
.should('have.value', '24h')
.clear()
.type('12h')
.should('have.value', '12h')
cy.getByTestID('task-form-offset-input')
.should('have.value', '20m')
.clear()
.type('10m')
.should('have.value', '10m')
cy.getByTestID('task-save-btn').click()
})
})
})

//assert changed task name
cy.getByTestID('task-card--name').contains('Copy task test')
})

//skip until this issue is resolved
//https://github.com/influxdata/ui/issues/97
it.skip('can add a comment into a task', () => {
cy.getByTestID('task-card--name')
.first()
.click()

//assert textarea and write a comment
cy.getByTestID('flux-editor').within(() => {
cy.get('textarea.inputarea')
.should(
'have.value',
'option task = {\n' +
' name: "🦄ask",\n' +
' every: 24h,\n' +
' offset: 20m\n' +
' }\n' +
' from(bucket: "defbuck")\n' +
' |> range(start: -2m)'
)
.click()
.focused()
.type('{end} {enter} //this is a test comment')
.then(() => {
cy.get('textarea.inputarea').should(
'have.value',
'option task = {\n' +
' name: "🦄ask",\n' +
' every: 24h,\n' +
' offset: 20m\n' +
' }\n' +
' from(bucket: "defbuck")\n' +
' |> range(start: -2m) \n' +
' //this is a test comment'
)
})
})

//save and assert notification
cy.getByTestID('task-save-btn')
.click()
.then(() => {
cy.getByTestID('notification-success').contains(
'Task was updated successfully'
)
})

cy.getByTestID('task-card--name')
.first()
.click()

//assert the comment
cy.getByTestID('flux-editor').within(() => {
cy.get('textarea.inputarea').should(
'have.value',
'option task = {name: "🦄ask", every: 24h, offset: 20m}\n' +
'\n' +
'from(bucket: "defbuck")\n' +
'\t|> range(start: -2m)\n' +
' //this is a test comment'
)
})
})
})

describe('Searching and filtering', () => {
Expand Down