-
Notifications
You must be signed in to change notification settings - Fork 593
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Radim Hrazdil
committed
Jun 16, 2020
1 parent
b0f60e4
commit b5e9cf7
Showing
4 changed files
with
82 additions
and
20 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
frontend/packages/kubevirt-plugin/integration-tests/tests/dialogs/nodeSelectorDialog.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,39 @@ | ||
/* eslint-disable no-await-in-loop */ | ||
import * as view from '../../views/dialogs/editNodeSelectorView'; | ||
import { fillInput } from '@console/shared/src/test-utils/utils'; | ||
import { click } from '@console/dev-console/integration-tests/utilities/elementInteractions'; | ||
import { MatchLabels } from '@console/internal/module/k8s'; | ||
|
||
export class NodeSelectorDialog { | ||
private extractID(id: string) { | ||
return id.split('-')[1]; | ||
} | ||
|
||
/** | ||
* Adds new row if needed. | ||
* Returns string with index of next empty row. | ||
*/ | ||
async addRow(): Promise<string> { | ||
if ((await view.emptyKeyInputs.count()) === 0) { | ||
await click(view.addLabelBtn); | ||
} | ||
return this.extractID(await view.emptyKeyInputs.first().getAttribute('id')); | ||
} | ||
|
||
async addLabel(key: string, value: string) { | ||
const id = await this.addRow(); | ||
await fillInput(view.labelKeyInputByID(id), key); | ||
await fillInput(view.labelValueInputByID(id), value); | ||
} | ||
|
||
async addLabels(labels: MatchLabels) { | ||
for (const [key, value] of Object.entries(labels)) { | ||
await this.addLabel(key, value); | ||
} | ||
} | ||
|
||
async deleteLabel(key: string) { | ||
const id = this.extractID(await view.keyInputByKey(key).getAttribute('id')); | ||
await click(view.deleteBtnByID(id)); | ||
} | ||
} |
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
4 changes: 3 additions & 1 deletion
4
frontend/packages/kubevirt-plugin/integration-tests/views/dialogs/editNodeSelectorView.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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import { $ } from 'protractor'; | ||
import { $, $$ } from 'protractor'; | ||
|
||
export const addLabelBtn = $('#vm-labels-list-add-btn'); | ||
export const emptyKeyInputs = $$("input[placeholder='key'][value='']"); | ||
export const keyInputByKey = (key) => $(`input[placeholder='key'][value='${key}']`); | ||
export const labelKeyInputByID = (id) => $(`#label-${id}-key-input`); | ||
export const labelValueInputByID = (id) => $(`#label-${id}-value-input`); | ||
export const deleteBtnByID = (id) => $(`#label-${id}-delete-btn`); |