forked from patternfly/patternfly-react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
searchinput.spec.ts
75 lines (61 loc) · 4.13 KB
/
searchinput.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
describe('Search Input Demo Test', () => {
it('Navigate to demo section', () => {
cy.visit('http://localhost:3000/search-input-demo-nav-link');
});
it('Verify search input ref by clicking focus button', () => {
cy.get('#focus_button').first().click();
cy.focused().should('have.attr', 'placeholder', 'Find by name');
cy.focused().blur();
});
it('Disabled search input is disabled', () => {
cy.get('#disabled-search .pf-v5-c-text-input-group__text-input').should('be.disabled');
cy.get('#disabled-search .pf-v5-c-input-group button').eq(0).should('be.disabled');
cy.get('#disabled-search .pf-v5-c-input-group button').eq(1).should('be.disabled');
});
it('Verify search input with hint', () => {
cy.get('#hinted-search .pf-v5-c-text-input-group__text-input').should('have.length', 2);
const hint = cy.get('#hinted-search .pf-v5-c-text-input-group__text-input').eq(0);
hint.should('be.disabled');
hint.should('have.class', 'pf-m-hint');
hint.should('have.value', 'hint');
cy.get('#hinted-search .pf-v5-c-text-input-group__text-input').eq(1).should('not.be.disabled');
});
it('Verify search input and its handlers work', () => {
cy.get('#enabled-search .pf-v5-c-badge').should('not.exist');
cy.get('#enabled-search .pf-v5-c-text-input-group__utilities > button').should('not.exist');
cy.get('#enabled-search .pf-v5-c-text-input-group__group').should('not.exist');
cy.get('#enabled-search .pf-v5-c-text-input-group__text-input').type('Hello world');
cy.get('#enabled-search .pf-v5-c-text-input-group__text-input').should('have.value', 'Hello world');
cy.get('#enabled-search .pf-v5-c-badge').should('be.visible');
cy.get('#enabled-search .pf-v5-c-text-input-group__utilities > button').should('be.visible');
cy.get('#enabled-search .pf-v5-c-text-input-group__group').should('be.visible');
cy.get('#enabled-search .pf-v5-c-badge').should('have.text', '1 / 3');
cy.get('#enabled-search .pf-v5-c-text-input-group__group button').last().click();
cy.get('#enabled-search .pf-v5-c-badge').should('have.text', '2 / 3');
cy.get('#enabled-search .pf-v5-c-text-input-group__group button').first().click();
cy.get('#enabled-search .pf-v5-c-badge').should('have.text', '1 / 3');
cy.get('#enabled-search .pf-v5-c-text-input-group__utilities > button').click();
cy.get('#enabled-search .pf-v5-c-text-input-group__text-input').should('not.have.value', 'Hello world');
cy.get('#enabled-search .pf-v5-c-badge').should('not.exist');
cy.get('#enabled-search .pf-v5-c-text-input-group__utilities > button').should('not.exist');
cy.get('#enabled-search .pf-v5-c-text-input-group__group').should('not.exist');
});
it('Verify advanced search and its handlers work', () => {
cy.get('#enabled-search .pf-v5-c-panel').should('not.exist');
cy.get('#enabled-search .pf-v5-c-input-group .pf-v5-c-input-group__item > button').eq(0).click();
cy.get('#enabled-search .pf-v5-c-panel').should('be.visible');
cy.get('#enabled-search .pf-v5-c-form-control > input').eq(0).type('test');
cy.get('#enabled-search .pf-v5-c-text-input-group__text-input').should('have.value', 'username:test');
cy.get('#enabled-search .pf-v5-c-text-input-group__text-input').type(' firstname:hi another test');
cy.get('#enabled-search .pf-v5-c-form-control > input').eq(1).should('have.value', 'hi');
cy.get('#enabled-search .pf-v5-c-form-control > input').eq(2).should('have.value', 'another test');
cy.get('#enabled-search .pf-v5-c-form__actions button').eq(1).click();
cy.get('#enabled-search .pf-v5-c-text-input-group__text-input').should('have.value', '');
cy.get('#enabled-search .pf-v5-c-form-control > input').eq(1).should('have.value', '');
cy.get('#enabled-search .pf-v5-c-form-control > input').eq(2).should('have.value', '');
cy.get('#enabled-search .pf-v5-c-form-control > input').eq(0).type('test');
cy.get('#enabled-search .pf-v5-c-form__actions button').eq(0).click();
cy.get('#enabled-search .pf-v5-c-form input').should('not.exist');
cy.get('#enabled-search .pf-v5-c-text-input-group__text-input').should('have.value', 'username:test');
});
});