Skip to content

Commit

Permalink
Revert "refactor(templates): Remove legacy templates (#19300)"
Browse files Browse the repository at this point in the history
This reverts commit 543bbd1.
  • Loading branch information
hoorayimhelping committed Aug 26, 2020
1 parent a8fe07b commit c49817e
Show file tree
Hide file tree
Showing 70 changed files with 5,497 additions and 128 deletions.
76 changes: 66 additions & 10 deletions ui/cypress/e2e/dashboardsIndex.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('Dashboards', () => {
"Looks like you don't have any Dashboards, why not create one?"
)
})
cy.getByTestID('add-resource-button').should($b => {
cy.getByTestID('add-resource-dropdown--button').should($b => {
expect($b).to.have.length(1)
expect($b).to.contain('Create Dashboard')
})
Expand All @@ -39,16 +39,18 @@ describe('Dashboards', () => {
it('can CRUD dashboards from empty state, header, and a Template', () => {
// Create from empty state
cy.getByTestID('empty-dashboards-list').within(() => {
cy.getByTestID('add-resource-button')
.click()
.then(() => {
cy.fixture('routes').then(({orgs}) => {
cy.get('@org').then(({id}: Organization) => {
cy.visit(`${orgs}/${id}/dashboards-list`)
})
cy.getByTestID('add-resource-dropdown--button').click()
})

cy.getByTestID('add-resource-dropdown--new')
.click()
.then(() => {
cy.fixture('routes').then(({orgs}) => {
cy.get('@org').then(({id}: Organization) => {
cy.visit(`${orgs}/${id}/dashboards-list`)
})
})
})
})

const newName = 'new 🅱️ashboard'

Expand All @@ -68,15 +70,36 @@ describe('Dashboards', () => {

cy.getByTestID('dashboard-card').should('contain', newName)

// Open Export overlay
cy.getByTestID('context-menu-item-export').click({force: true})
cy.getByTestID('export-overlay--text-area').should('exist')
cy.get('.cf-overlay--dismiss').click()

// Create from header
cy.getByTestID('add-resource-button').click()
cy.getByTestID('add-resource-dropdown--button').click()
cy.getByTestID('add-resource-dropdown--new').click()

cy.fixture('routes').then(({orgs}) => {
cy.get('@org').then(({id}: Organization) => {
cy.visit(`${orgs}/${id}/dashboards-list`)
})
})

// Create from Template
cy.get('@org').then(({id}: Organization) => {
cy.createDashboardTemplate(id)
})

cy.getByTestID('empty-dashboards-list').within(() => {
cy.getByTestID('add-resource-dropdown--button').click()
cy.getByTestID('add-resource-dropdown--template').click()
})
cy.getByTestID('template--Bashboard-Template').click()
cy.getByTestID('template-panel').should('exist')
cy.getByTestID('create-dashboard-button').click()

cy.getByTestID('dashboard-card').should('have.length', 3)

// Delete dashboards
cy.getByTestID('dashboard-card')
.first()
Expand All @@ -94,9 +117,42 @@ describe('Dashboards', () => {
cy.getByTestID('context-delete-dashboard').click()
})

cy.getByTestID('dashboard-card')
.first()
.trigger('mouseover')
.within(() => {
cy.getByTestID('context-delete-menu').click()
cy.getByTestID('context-delete-dashboard').click()
})

cy.getByTestID('empty-dashboards-list').should('exist')
})

it('keeps user input in text area when attempting to import invalid JSON', () => {
cy.getByTestID('page-control-bar').within(() => {
cy.getByTestID('add-resource-dropdown--button').click()
})

cy.getByTestID('add-resource-dropdown--import').click()
cy.contains('Paste').click()
cy.getByTestID('import-overlay--textarea')
.click()
.type('this is invalid JSON')
cy.get('button[title*="Import JSON"]').click()
cy.getByTestID('import-overlay--textarea--error').should('have.length', 1)
cy.getByTestID('import-overlay--textarea').should($s =>
expect($s).to.contain('this is invalid JSON')
)
cy.getByTestID('import-overlay--textarea').type(
'{backspace}{backspace}{backspace}{backspace}{backspace}'
)
cy.get('button[title*="Import JSON"]').click()
cy.getByTestID('import-overlay--textarea--error').should('have.length', 1)
cy.getByTestID('import-overlay--textarea').should($s =>
expect($s).to.contain('this is invalid')
)
})

describe('Dashboard List', () => {
beforeEach(() => {
cy.get('@org').then(({id}: Organization) => {
Expand Down
43 changes: 41 additions & 2 deletions ui/cypress/e2e/tasks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,19 @@ from(bucket: "${name}"{rightarrow}
.should('have.length', 1)
.and('contain', taskName)

cy.getByTestID('add-resource-button').click()
// TODO: extend to create from template overlay
cy.getByTestID('add-resource-dropdown--button').click()
cy.getByTestID('add-resource-dropdown--template').click()
cy.getByTestID('task-import-template--overlay').within(() => {
cy.get('.cf-overlay--dismiss').click()
})

// TODO: extend to create a template from JSON
cy.getByTestID('add-resource-dropdown--button').click()
cy.getByTestID('add-resource-dropdown--import').click()
cy.getByTestID('task-import--overlay').within(() => {
cy.get('.cf-overlay--dismiss').click()
})
})
// this test is broken due to a failure on the post route
it.skip('can create a task using http.post', () => {
Expand All @@ -80,6 +92,31 @@ http.post(
.and('contain', taskName)
})

it('keeps user input in text area when attempting to import invalid JSON', () => {
cy.getByTestID('page-control-bar').within(() => {
cy.getByTestID('add-resource-dropdown--button').click()
})

cy.getByTestID('add-resource-dropdown--import').click()
cy.contains('Paste').click()
cy.getByTestID('import-overlay--textarea')
.click()
.type('this is invalid JSON')
cy.get('button[title*="Import JSON"]').click()
cy.getByTestID('import-overlay--textarea--error').should('have.length', 1)
cy.getByTestID('import-overlay--textarea').should($s =>
expect($s).to.contain('this is invalid JSON')
)
cy.getByTestID('import-overlay--textarea').type(
'{backspace}{backspace}{backspace}{backspace}{backspace}'
)
cy.get('button[title*="Import JSON"]').click()
cy.getByTestID('import-overlay--textarea--error').should('have.length', 1)
cy.getByTestID('import-overlay--textarea').should($s =>
expect($s).to.contain('this is invalid')
)
})

describe('When tasks already exist', () => {
beforeEach(() => {
cy.get('@org').then(({id}: Organization) => {
Expand Down Expand Up @@ -358,9 +395,11 @@ function createFirstTask(
offset: string = '20m'
) {
cy.getByTestID('empty-tasks-list').within(() => {
cy.getByTestID('add-resource-button').click()
cy.getByTestID('add-resource-dropdown--button').click()
})

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

cy.get<Bucket>('@bucket').then(bucket => {
cy.getByTestID('flux-editor').within(() => {
cy.get('textarea.inputarea')
Expand Down
57 changes: 53 additions & 4 deletions ui/cypress/e2e/variables.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ describe('Variables', () => {
'windowPeriod'
)

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

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

cy.getByTestID('variable-type-dropdown--button').click()
cy.getByTestID('variable-type-dropdown-constant').click()
Expand Down Expand Up @@ -143,7 +145,9 @@ describe('Variables', () => {
)

// Create a Map variable from scratch
cy.getByTestID('add-resource-button').click()
cy.getByTestID('add-resource-dropdown--button').click()

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

cy.getByTestID('variable-type-dropdown--button').click()
cy.getByTestID('variable-type-dropdown-map').click()
Expand All @@ -167,7 +171,9 @@ describe('Variables', () => {
cy.getByTestID(`variable-card--name ${mapVariableName}`).should('exist')

// Create a Query variable from scratch
cy.getByTestID('add-resource-button').click()
cy.getByTestID('add-resource-dropdown--button').click()

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

cy.getByTestID('variable-type-dropdown--button').click()
cy.getByTestID('variable-type-dropdown-map').click()
Expand Down Expand Up @@ -195,6 +201,45 @@ describe('Variables', () => {
cy.getByTestID(`variable-card--name ${queryVariableName}`).contains(
queryVariableName
)

//create variable by uploader
cy.getByTestID('add-resource-dropdown--button').click()

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

const yourFixturePath = 'data-for-variable.json'
cy.get('.drag-and-drop').attachFile(yourFixturePath, {
subjectType: 'drag-n-drop',
})

cy.getByTestID('submit-button Variable').click()

cy.getByTestID('resource-card variable')
.should('have.length', 4)
.contains('agent_host')
})

it('keeps user input in text area when attempting to import invalid JSON', () => {
cy.getByTestID('tabbed-page--header').within(() => {
cy.contains('Create').click()
})

cy.getByTestID('add-resource-dropdown--import').click()
cy.contains('Paste').click()
cy.getByTestID('import-overlay--textarea')
.click()
.type('this is invalid JSON')
cy.get('button[title*="Import JSON"]').click()
cy.getByTestID('import-overlay--textarea--error').should('have.length', 1)
cy.getByTestID('import-overlay--textarea').should($s =>
expect($s).to.contain('this is invalid JSON')
)
cy.getByTestID('import-overlay--textarea').type(
'{backspace}{backspace}{backspace}{backspace}{backspace}'
)
cy.get('button[title*="Import JSON"]').click()
cy.getByTestID('import-overlay--textarea--error').should('have.length', 1)
cy.getByTestID('import-overlay--textarea').contains('this is invalid')
})

it('can create and delete a label and filter a variable by label name & sort by variable name', () => {
Expand All @@ -209,7 +254,11 @@ describe('Variables', () => {

cy.getByTestID('overlay--children').should('not.exist')

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

cy.getByTestID('add-resource-dropdown--new').should('have.length', 1)

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

cy.getByTestID('variable-type-dropdown--button').click()
cy.getByTestID('variable-type-dropdown-constant').click()
Expand Down
Loading

0 comments on commit c49817e

Please sign in to comment.