-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add browser E2E tests for TaskRun YAML editor
- Loading branch information
1 parent
494a4db
commit 3bd4c8b
Showing
5 changed files
with
275 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
/* | ||
Copyright 2023 The Tekton Authors | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
const namespace = 'tekton-dashboard-e2e-taskrun-create'; | ||
describe('Create TaskRun', () => { | ||
before(() => { | ||
cy.exec('kubectl version --client'); | ||
cy.exec(`kubectl create namespace ${namespace} || true`); | ||
}); | ||
|
||
after(() => { | ||
cy.exec(`kubectl delete namespace ${namespace} || true`); | ||
}); | ||
|
||
it('should create TaskRun', function () { | ||
const uniqueNumber = Date.now(); | ||
|
||
const taskName = `simple-task-${uniqueNumber}`; | ||
const task = `apiVersion: tekton.dev/v1beta1 | ||
kind: Task | ||
metadata: | ||
name: ${taskName} | ||
namespace: ${namespace} | ||
spec: | ||
steps: | ||
- name: echo | ||
image: busybox | ||
script: | | ||
#!/bin/ash | ||
echo "Hello World!" | ||
`; | ||
cy.exec(`echo "${task}" | kubectl apply -f -`); | ||
cy.visit(`/#/taskruns/create?namespace=${namespace}&taskName=${taskName}`); | ||
cy.get('[id=create-taskrun--namespaces-dropdown]').should( | ||
'have.value', | ||
namespace | ||
); | ||
cy.get('[id=create-taskrun--tasks-dropdown]').should( | ||
'have.value', | ||
taskName | ||
); | ||
|
||
cy.contains('button', 'Create').click(); | ||
|
||
cy.contains('h1', 'TaskRuns'); | ||
cy.contains('a', `${taskName}-run`).click(); | ||
|
||
cy.get('header[class="tkn--pipeline-run-header"]') | ||
.find('span[class="tkn--status-label"]', { timeout: 15000 }) | ||
.should('have.text', 'Succeeded'); | ||
}); | ||
|
||
it('should populate YAML editor based on form inputs', function () { | ||
const uniqueNumber = Date.now(); | ||
|
||
const taskName = `simple-task-${uniqueNumber}`; | ||
const taskRunName = `run-${uniqueNumber}`; | ||
const task = `apiVersion: tekton.dev/v1beta1 | ||
kind: Task | ||
metadata: | ||
name: ${taskName} | ||
namespace: ${namespace} | ||
spec: | ||
steps: | ||
- name: echo | ||
image: busybox | ||
script: | | ||
#!/bin/ash | ||
echo "Hello World!" | ||
`; | ||
cy.exec(`echo "${task}" | kubectl apply -f -`); | ||
cy.visit(`/#/taskruns/create?namespace=${namespace}&taskName=${taskName}`); | ||
cy.get('[id=create-taskrun--namespaces-dropdown]').should( | ||
'have.value', | ||
namespace | ||
); | ||
cy.get('[id=create-taskrun--tasks-dropdown]').should( | ||
'have.value', | ||
taskName | ||
); | ||
|
||
cy.get('#create-taskrun--taskrunname').type(taskRunName); | ||
|
||
cy.get('#create-taskrun--timeout').type('10m'); | ||
|
||
cy.contains('button', 'YAML Mode').click(); | ||
cy.url().should('include', 'mode=yaml'); | ||
|
||
cy.contains('.cm-content', `name: ${taskRunName}`); | ||
cy.contains('.cm-content', `name: ${taskName}`); | ||
cy.contains('.cm-content', 'timeout: 10m'); | ||
|
||
cy.contains('button', 'Create').click(); | ||
|
||
cy.contains('h1', 'TaskRuns'); | ||
cy.contains('a', taskRunName).click(); | ||
|
||
cy.get('header[class="tkn--pipeline-run-header"]') | ||
.find('span[class="tkn--status-label"]', { timeout: 15000 }) | ||
.should('have.text', 'Succeeded'); | ||
}); | ||
|
||
it('should create TaskRun in YAML mode', function () { | ||
const uniqueNumber = Date.now(); | ||
|
||
const taskRunName = `yaml-mode-${uniqueNumber}`; | ||
const taskRun = `apiVersion: tekton.dev/v1beta1 | ||
kind: TaskRun | ||
metadata: | ||
name: ${taskRunName} | ||
namespace: ${namespace} | ||
spec: | ||
taskSpec: | ||
steps: | ||
- name: echo | ||
image: busybox | ||
script: | | ||
#!/bin/ash | ||
echo "Hello World!" | ||
`; | ||
cy.visit(`/#/taskruns/create`); | ||
|
||
cy.contains('button', 'YAML Mode').click(); | ||
cy.url().should('include', 'mode=yaml'); | ||
|
||
cy.get('.cm-content').clear(); | ||
cy.get('.cm-content').type(taskRun, { preserveIndentation: true }); | ||
|
||
cy.contains('button', 'Create').click(); | ||
|
||
cy.contains('h1', 'TaskRuns'); | ||
cy.get(`[title=${taskRunName}]`).click(); | ||
|
||
cy.get('header[class="tkn--pipeline-run-header"]') | ||
.find('span[class="tkn--status-label"]', { timeout: 15000 }) | ||
.should('have.text', 'Succeeded'); | ||
}); | ||
|
||
it('should create TaskRun when open YAML mode directly', function () { | ||
const uniqueNumber = Date.now(); | ||
|
||
const taskRunName = `yaml-mode-${uniqueNumber}`; | ||
const taskRun = `apiVersion: tekton.dev/v1beta1 | ||
kind: TaskRun | ||
metadata: | ||
name: ${taskRunName} | ||
namespace: ${namespace} | ||
spec: | ||
taskSpec: | ||
steps: | ||
- name: echo | ||
image: busybox | ||
script: | | ||
#!/bin/ash | ||
echo "Hello World!" | ||
`; | ||
cy.visit(`/#/taskruns/create?mode=yaml`); | ||
|
||
cy.get('.cm-content').clear(); | ||
cy.get('.cm-content').type(taskRun, { preserveIndentation: true }); | ||
|
||
cy.contains('button', 'Create').click(); | ||
|
||
cy.contains('h1', 'TaskRuns'); | ||
cy.get(`[title=${taskRunName}]`).click(); | ||
|
||
cy.get('header[class="tkn--pipeline-run-header"]') | ||
.find('span[class="tkn--status-label"]', { timeout: 15000 }) | ||
.should('have.text', 'Succeeded'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
Copyright 2023 The Tekton Authors | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
const namespace = 'tkn-dashboard-e2e-taskrun-edit'; | ||
describe('Edit and run TaskRun', () => { | ||
before(() => { | ||
cy.exec('kubectl version --client'); | ||
cy.exec(`kubectl create namespace ${namespace} || true`); | ||
}); | ||
|
||
after(() => { | ||
cy.exec(`kubectl delete namespace ${namespace} || true`); | ||
}); | ||
|
||
it('should create TaskRun on edit and run', function () { | ||
const uniqueNumber = Date.now(); | ||
const taskName = `sp-${uniqueNumber}`; | ||
const task = `apiVersion: tekton.dev/v1beta1 | ||
kind: Task | ||
metadata: | ||
name: ${taskName} | ||
namespace: ${namespace} | ||
spec: | ||
steps: | ||
- name: echo | ||
image: busybox | ||
script: | | ||
#!/bin/ash | ||
echo "Hello World!" | ||
`; | ||
cy.exec(`echo "${task}" | kubectl apply -f -`); | ||
cy.visit(`/#/taskruns/create?namespace=${namespace}&taskName=${taskName}`); | ||
cy.get('[id=create-taskrun--namespaces-dropdown]').should( | ||
'have.value', | ||
namespace | ||
); | ||
cy.get('[id=create-taskrun--tasks-dropdown]').should( | ||
'have.value', | ||
taskName | ||
); | ||
cy.contains('button', 'Create').click(); | ||
|
||
cy.contains('h1', 'TaskRuns'); | ||
|
||
cy.get( | ||
`td:has(.bx--link[title*=${taskName}-run]) + td:has(.tkn--status[data-reason=Succeeded])`, | ||
{ timeout: 15000 } | ||
).should('have.length', 1); | ||
|
||
cy.contains('a', `${taskName}-run`).click(); | ||
cy.contains('button', 'Actions').click(); | ||
cy.contains('button', 'Edit and run').click(); | ||
cy.get('.cm-content').contains(`name: ${taskName}`); | ||
cy.contains('button', 'Create').click(); | ||
cy.contains('h1', 'TaskRuns'); | ||
|
||
cy.get( | ||
`td:has(.bx--link[title*=${taskName}-run]) + td:has(.tkn--status[data-reason=Succeeded])`, | ||
{ timeout: 15000 } | ||
).should('have.length', 2); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters