Skip to content

Commit

Permalink
test(tasks): fix cypress tests for task creation with token
Browse files Browse the repository at this point in the history
  • Loading branch information
AlirieGray committed Jul 26, 2019
1 parent c04f3a2 commit 7b96bd9
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 13 deletions.
1 change: 0 additions & 1 deletion http/task_service.go
Expand Up @@ -15,7 +15,6 @@ import (

influxdb "github.com/influxdata/influxdb"
platform "github.com/influxdata/influxdb"
"github.com/influxdata/influxdb/authorizer"
pcontext "github.com/influxdata/influxdb/context"
"github.com/influxdata/influxdb/kit/tracing"
"github.com/influxdata/influxdb/kv"
Expand Down
43 changes: 31 additions & 12 deletions ui/cypress/e2e/tasks.test.ts
@@ -1,4 +1,5 @@
import {Organization, Bucket} from '@influxdata/influx'
import _ from 'lodash'

describe('Tasks', () => {
beforeEach(() => {
Expand All @@ -7,6 +8,14 @@ describe('Tasks', () => {
cy.signin().then(({body}) => {
cy.wrap(body.org).as('org')
cy.wrap(body.bucket).as('bucket')

cy.createToken(body.org.id, 'test token', 'active', [
{action: 'write', resource: {type: 'views'}},
{action: 'write', resource: {type: 'documents'}},
{action: 'write', resource: {type: 'tasks'}},
]).then(({body}) => {
cy.wrap(body.token).as('token')
})
})

cy.fixture('routes').then(({orgs}) => {
Expand Down Expand Up @@ -46,8 +55,10 @@ describe('Tasks', () => {

it('can delete a task', () => {
cy.get<Organization>('@org').then(({id}) => {
cy.createTask(id)
cy.createTask(id)
cy.get<string>('@token').then(token => {
cy.createTask(token, id)
cy.createTask(token, id)
})

cy.fixture('routes').then(({orgs}) => {
cy.visit(`${orgs}/${id}/tasks`)
Expand All @@ -69,7 +80,9 @@ describe('Tasks', () => {

it('can disable a task', () => {
cy.get<Organization>('@org').then(({id}) => {
cy.createTask(id)
cy.get<string>('@token').then(token => {
cy.createTask(token, id)
})
})

cy.getByTestID('task-card--slide-toggle').should('have.class', 'active')
Expand All @@ -81,7 +94,9 @@ describe('Tasks', () => {

it('can edit a tasks name', () => {
cy.get<Organization>('@org').then(({id}) => {
cy.createTask(id)
cy.get<string>('@token').then(token => {
cy.createTask(token, id)
})
})

const newName = 'Task'
Expand Down Expand Up @@ -130,12 +145,14 @@ describe('Tasks', () => {
const newLabelName = 'click-me'

cy.get<Organization>('@org').then(({id}) => {
cy.createTask(id).then(({body}) => {
cy.createAndAddLabel('tasks', id, body.id, newLabelName)
})

cy.createTask(id).then(({body}) => {
cy.createAndAddLabel('tasks', id, body.id, 'bar')
cy.get<string>('@token').then(token => {
cy.createTask(token, id).then(({body}) => {
cy.createAndAddLabel('tasks', id, body.id, newLabelName)
})

cy.createTask(token, id).then(({body}) => {
cy.createAndAddLabel('tasks', id, body.id, 'bar')
})
})
})

Expand All @@ -157,8 +174,10 @@ describe('Tasks', () => {
it('can search by task name', () => {
const searchName = 'beepBoop'
cy.get<Organization>('@org').then(({id}) => {
cy.createTask(id, searchName)
cy.createTask(id)
cy.get<string>('@token').then(token => {
cy.createTask(token, id, searchName)
cy.createTask(token, id)
})
})

cy.fixture('routes').then(({orgs}) => {
Expand Down
2 changes: 2 additions & 0 deletions ui/cypress/support/commands.ts
Expand Up @@ -110,6 +110,7 @@ export const createBucket = (
}

export const createTask = (
token: string,
orgID?: string,
name: string = '🦄ask'
): Cypress.Chainable<Cypress.Response> => {
Expand All @@ -127,6 +128,7 @@ export const createTask = (
body: {
flux,
orgID,
token,
},
})
}
Expand Down

0 comments on commit 7b96bd9

Please sign in to comment.