Skip to content

Commit

Permalink
CONSOLE-2530: Migrate labels tests
Browse files Browse the repository at this point in the history
Migrated labels CRUD tests from Protractor to Cypress.

Fixes https://issues.redhat.com/projects/CONSOLE/issues/CONSOLE-2530
  • Loading branch information
rebeccaalpert committed Jan 14, 2021
1 parent 86a3173 commit 27cd93a
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 100 deletions.
5 changes: 0 additions & 5 deletions frontend/integration-tests/protractor.conf.ts
Expand Up @@ -55,13 +55,11 @@ const testSuites = {
secrets: suite(['tests/secrets.scenario.ts']),
storage: suite(['tests/storage.scenario.ts']),
crud: suite([
'tests/crud.scenario.ts',
'tests/secrets.scenario.ts',
'tests/filter.scenario.ts',
'tests/environment.scenario.ts',
]),
event: suite(['tests/event.scenario.ts']),
crudBasic: suite(['tests/crud.scenario.ts']),
monitoring: suite(['tests/monitoring.scenario.ts']),
newApp: suite(['tests/overview/overview.scenario.ts', 'tests/deploy-image.scenario.ts']),
performance: suite(['tests/performance.scenario.ts']),
Expand All @@ -76,7 +74,6 @@ const testSuites = {
crdExtensions: suite(['tests/crd-extensions.scenario.ts']),
oauth: suite(['tests/oauth.scenario.ts']),
e2e: suite([
'tests/crud.scenario.ts',
'tests/filter.scenario.ts',
'tests/secrets.scenario.ts',
'tests/storage.scenario.ts',
Expand All @@ -95,7 +92,6 @@ const testSuites = {
'tests/cluster-settings.scenario.ts',
]),
release: suite([
'tests/crud.scenario.ts',
'tests/secrets.scenario.ts',
'tests/filter.scenario.ts',
'tests/environment.scenario.ts',
Expand All @@ -109,7 +105,6 @@ const testSuites = {
'tests/event.scenario.ts',
]),
all: suite([
'tests/crud.scenario.ts',
'tests/overview/overview.scenario.ts',
'tests/secrets.scenario.ts',
'tests/storage.scenario.ts',
Expand Down
94 changes: 0 additions & 94 deletions frontend/integration-tests/tests/crud.scenario.ts

This file was deleted.

@@ -0,0 +1,65 @@
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';

describe('Editing labels', () => {
const name = `${testName}-editlabels`;
const plural = 'configmaps';
const kind = 'ConfigMap';
const labelValue = 'appblah';
const yaml = {
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();
});
});
6 changes: 6 additions & 0 deletions frontend/packages/integration-tests-cypress/views/labels.ts
@@ -0,0 +1,6 @@
export const labels = {
inputLabel: (label: string) => cy.byTestID('tags-input').type(label),
confirmDetailsPageLabelExists: (label: string) => cy.get('.co-m-label__key').contains(label),
clickDetailsPageLabel: () => cy.byTestID('label-key').click(),
chipExists: () => cy.get('.pf-c-chip-group__label').should('exist'),
};
4 changes: 3 additions & 1 deletion frontend/public/components/utils/label-list.tsx
Expand Up @@ -14,7 +14,9 @@ export const Label: React.SFC<LabelProps> = ({ kind, name, value, expand }) => {
return (
<Link className={`co-text-${kindForReference(kind.toLowerCase())}`} to={href}>
<div className={klass}>
<span className="co-m-label__key">{name}</span>
<span className="co-m-label__key" data-test="label-key">
{name}
</span>
{value && <span className="co-m-label__eq">=</span>}
{value && <span className="co-m-label__value">{value}</span>}
</div>
Expand Down

0 comments on commit 27cd93a

Please sign in to comment.