-
Notifications
You must be signed in to change notification settings - Fork 355
/
popover.spec.ts
66 lines (61 loc) · 2.45 KB
/
popover.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
describe('Popover Demo Test', () => {
it('Navigate to popover section', () => {
cy.visit('http://localhost:3000/popover-demo-nav-link');
});
it('Launch, test, and close Popover', () => {
['popoverTarget', 'popover-selector', 'popover-ref'].forEach(id => {
cy.get(`[id="${id}"]`).then((popoverLink: JQuery<HTMLDivElement>) => {
cy.get('.pf-c-popover').should('not.exist');
cy.wrap(popoverLink).click();
cy.get('.pf-c-popover').should('exist');
cy.get('h6').contains('Popover Header');
cy.get('.pf-c-popover__body').contains('Popover Body');
cy.get('footer').contains('Popover Footer');
cy.get('button[aria-label="Close"]').then(closeBtn => {
cy.wrap(closeBtn).click();
cy.get('.pf-c-popover').should('not.exist');
});
});
});
});
it('Popover header has correct default size', () => {
cy.get('div[id="popoverTarget"]').then((popoverLink: JQuery<HTMLDivElement>) => {
cy.wrap(popoverLink).click();
cy.get('.pf-c-popover').should('exist');
cy.get('h6').should('have.class', 'pf-m-md');
cy.get('button[aria-label="Close"]').then(closeBtn => {
cy.wrap(closeBtn).click();
cy.get('.pf-c-popover').should('not.exist');
});
});
});
it('Popover header custom heading level', () => {
cy.get('[id="popover-heading-level-toggle"]').then((popoverLink: JQuery<HTMLDivElement>) => {
cy.wrap(popoverLink).click();
cy.get('.pf-c-popover').should('exist');
cy.get('h1').should('exist');
cy.get('button[aria-label="Close"]').then(closeBtn => {
cy.wrap(closeBtn).click();
cy.get('.pf-c-popover').should('not.exist');
});
});
});
it('Close popover from content', () => {
cy.get(`[id="popover-content-close-toggle"]`).then((popoverLink: JQuery<HTMLDivElement>) => {
cy.get('.pf-c-popover').should('not.exist');
cy.wrap(popoverLink).click();
cy.get('.pf-c-popover').should('exist');
cy.get('.pf-c-popover__body').should('exist');
cy.get('[id="popover-content-close-btn"]').then(btn => {
cy.wrap(btn).click();
cy.get('.pf-c-popover').should('not.exist');
});
});
});
it('Applies diagonal modifiers', () => {
cy.get('#popover-right-top-toggle').click();
cy.get('.pf-c-popover').should('have.class', 'pf-m-right-top');
cy.get('#popover-right-top-toggle').click();
cy.get('.pf-c-popover').should('not.exist');
});
});