Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7834 from rebeccaalpert/cypress
CONSOLE-2530: Migrate labels CRUD tests
- Loading branch information
Showing
5 changed files
with
75 additions
and
100 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 was deleted.
Oops, something went wrong.
66 changes: 66 additions & 0 deletions
66
frontend/packages/integration-tests-cypress/tests/crud/labels.spec.ts
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,66 @@ | ||
import { safeLoad, safeDump } from 'js-yaml'; | ||
import * as _ from 'lodash'; | ||
|
||
import { checkErrors, testName } from '../../support'; | ||
import { nav } from '../../views/nav'; | ||
import { detailsPage } from '../../views/details-page'; | ||
import * as yamlEditor from '../../views/yaml-editor'; | ||
import { errorMessage } from '../../views/form'; | ||
import { modal } from '../../views/modal'; | ||
import { labels } from '../../views/labels'; | ||
import { ConfigMapKind } from '@console/internal/module/k8s'; | ||
|
||
describe('Editing labels', () => { | ||
const name = `${testName}-editlabels`; | ||
const plural = 'configmaps'; | ||
const kind = 'ConfigMap'; | ||
const labelValue = 'appblah'; | ||
const yaml: ConfigMapKind = { | ||
apiVersion: 'v1', | ||
kind, | ||
metadata: { | ||
name, | ||
namespace: testName, | ||
}, | ||
}; | ||
|
||
before(() => { | ||
cy.login(); | ||
cy.visit('/'); | ||
nav.sidenav.switcher.changePerspectiveTo('Administrator'); | ||
nav.sidenav.switcher.shouldHaveText('Administrator'); | ||
cy.createProject(testName); | ||
cy.visit(`k8s/ns/${testName}/${plural}/~new`); | ||
yamlEditor.isLoaded(); | ||
yamlEditor.getEditorContent().then((content) => { | ||
const newContent = _.defaultsDeep({}, yaml, safeLoad(content)); | ||
yamlEditor.setEditorContent(safeDump(newContent, { sortKeys: true })).then(() => { | ||
yamlEditor.clickSaveCreateButton(); | ||
cy.get(errorMessage).should('not.exist'); | ||
}); | ||
}); | ||
}); | ||
|
||
afterEach(() => { | ||
checkErrors(); | ||
}); | ||
|
||
after(() => { | ||
cy.deleteProject(testName); | ||
cy.logout(); | ||
}); | ||
|
||
it(`Adds a resource instance label, updates the resource instance label, and makes sure the link works`, () => { | ||
detailsPage.isLoaded(); | ||
detailsPage.clickPageActionFromDropdown('Edit labels'); | ||
modal.shouldBeOpened(); | ||
labels.inputLabel(labelValue); | ||
modal.submit(); | ||
detailsPage.isLoaded(); | ||
labels.confirmDetailsPageLabelExists(labelValue); | ||
labels.clickDetailsPageLabel(); | ||
detailsPage.isLoaded(); | ||
cy.url().should('include', `/search/ns/${testName}?kind=core~v1~ConfigMap&q=${labelValue}`); | ||
labels.chipExists(); | ||
}); | ||
}); |
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,6 @@ | ||
export const labels = { | ||
inputLabel: (label: string) => cy.byTestID('tags-input').type(label), | ||
confirmDetailsPageLabelExists: (label: string) => cy.byTestID('label-key').contains(label), | ||
clickDetailsPageLabel: () => cy.byTestID('label-key').click(), | ||
chipExists: () => cy.get('.pf-c-chip-group__label').should('exist'), | ||
}; |
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