|
| 1 | +import { Attribute, AttributeValue, Keys } from '../../common/consts'; |
| 2 | +import FocusZonePageObject from '../pages/FocusZonePageObject'; |
| 3 | + |
| 4 | +// Before testing begins, allow up to 60 seconds for app to open |
| 5 | +describe('FocusZone Testing Initialization', () => { |
| 6 | + it('Wait for app load', async () => { |
| 7 | + expect(await FocusZonePageObject.waitForInitialPageToDisplay()).toBeTrue(); |
| 8 | + }); |
| 9 | + |
| 10 | + it('Click and navigate to FocusZone test page', async () => { |
| 11 | + /* Click on component button to navigate to test page */ |
| 12 | + expect(await FocusZonePageObject.navigateToPageAndLoadTests()).toBeTrue(); |
| 13 | + |
| 14 | + /* Expand E2E section */ |
| 15 | + expect(await FocusZonePageObject.enableE2ETesterMode()).toBeTrue(); |
| 16 | + |
| 17 | + await expect(await FocusZonePageObject.didAssertPopup()) |
| 18 | + .withContext(FocusZonePageObject.ERRORMESSAGE_ASSERT) |
| 19 | + .toBeFalsy(); // Ensure no asserts popped up |
| 20 | + }); |
| 21 | +}); |
| 22 | + |
| 23 | +/* FocusZone Functional Testing |
| 24 | + * |
| 25 | + * Focuses on the directional aspect of FocusZone with arrow keys. |
| 26 | + * |
| 27 | + * */ |
| 28 | +describe('FocusZone Functional Testing', () => { |
| 29 | + beforeEach(async () => { |
| 30 | + await FocusZonePageObject.scrollToTestElement(); |
| 31 | + |
| 32 | + await FocusZonePageObject.resetTest(); |
| 33 | + }); |
| 34 | + |
| 35 | + it('Navigate bidirectional focuszone using arrow keys. Validate focus switches correctly.', async () => { |
| 36 | + // move to 2 with right arrow |
| 37 | + await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(1), [Keys.ARROW_RIGHT]); |
| 38 | + expect( |
| 39 | + await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(2), Attribute.IsFocused, AttributeValue.true), |
| 40 | + ).toBeTruthy(); |
| 41 | + |
| 42 | + // move to 3 with down arrow |
| 43 | + await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(2), [Keys.ARROW_DOWN]); |
| 44 | + expect( |
| 45 | + await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(3), Attribute.IsFocused, AttributeValue.true), |
| 46 | + ).toBeTruthy(); |
| 47 | + |
| 48 | + expect(await FocusZonePageObject.didAssertPopup()) |
| 49 | + .withContext(FocusZonePageObject.ERRORMESSAGE_ASSERT) |
| 50 | + .toBeFalsy(); |
| 51 | + }); |
| 52 | + |
| 53 | + it('Navigate horizontal focuszone using arrow keys. Validate focus switches correctly.', async () => { |
| 54 | + await FocusZonePageObject.configureGridFocusZone('SetDirection', 'horizontal'); |
| 55 | + // move to 2 with right arrow |
| 56 | + await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(1), [Keys.ARROW_RIGHT]); |
| 57 | + expect( |
| 58 | + await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(2), Attribute.IsFocused, AttributeValue.true), |
| 59 | + ).toBeTruthy(); |
| 60 | + |
| 61 | + // down arrow shouldn't move focus |
| 62 | + await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(2), [Keys.ARROW_DOWN]); |
| 63 | + expect( |
| 64 | + await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(2), Attribute.IsFocused, AttributeValue.true), |
| 65 | + ).toBeTruthy(); |
| 66 | + |
| 67 | + // left arrow goes back |
| 68 | + await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(4), [Keys.ARROW_LEFT]); |
| 69 | + expect( |
| 70 | + await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(3), Attribute.IsFocused, AttributeValue.true), |
| 71 | + ).toBeTruthy(); |
| 72 | + |
| 73 | + expect(await FocusZonePageObject.didAssertPopup()) |
| 74 | + .withContext(FocusZonePageObject.ERRORMESSAGE_ASSERT) |
| 75 | + .toBeFalsy(); |
| 76 | + }); |
| 77 | + |
| 78 | + it('Navigates vertical focuszone using arrow keys. Validate focus switches correctly.', async () => { |
| 79 | + await FocusZonePageObject.configureGridFocusZone('SetDirection', 'vertical'); |
| 80 | + |
| 81 | + // move to 2 with down arrow |
| 82 | + await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(1), [Keys.ARROW_DOWN]); |
| 83 | + expect( |
| 84 | + await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(2), Attribute.IsFocused, AttributeValue.true), |
| 85 | + ).toBeTruthy(); |
| 86 | + |
| 87 | + // right arrow shouldn't move focus |
| 88 | + await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(2), [Keys.ARROW_RIGHT]); |
| 89 | + expect( |
| 90 | + await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(2), Attribute.IsFocused, AttributeValue.true), |
| 91 | + ).toBeTruthy(); |
| 92 | + |
| 93 | + // up arrow goes back |
| 94 | + await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(4), [Keys.ARROW_UP]); |
| 95 | + expect( |
| 96 | + await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(3), Attribute.IsFocused, AttributeValue.true), |
| 97 | + ).toBeTruthy(); |
| 98 | + |
| 99 | + expect(await FocusZonePageObject.didAssertPopup()) |
| 100 | + .withContext(FocusZonePageObject.ERRORMESSAGE_ASSERT) |
| 101 | + .toBeFalsy(); |
| 102 | + }); |
| 103 | + |
| 104 | + it('Navigates none-direction focuszone using arrow keys. Validate focus does not switch.', async () => { |
| 105 | + await FocusZonePageObject.configureGridFocusZone('SetDirection', 'none'); |
| 106 | + |
| 107 | + // none of these key commands should move |
| 108 | + await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(2), [Keys.ARROW_DOWN]); |
| 109 | + expect( |
| 110 | + await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(2), Attribute.IsFocused, AttributeValue.true), |
| 111 | + ).toBeTruthy(); |
| 112 | + |
| 113 | + await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(2), [Keys.ARROW_UP]); |
| 114 | + expect( |
| 115 | + await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(2), Attribute.IsFocused, AttributeValue.true), |
| 116 | + ).toBeTruthy(); |
| 117 | + |
| 118 | + await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(2), [Keys.ARROW_LEFT]); |
| 119 | + expect( |
| 120 | + await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(2), Attribute.IsFocused, AttributeValue.true), |
| 121 | + ).toBeTruthy(); |
| 122 | + |
| 123 | + await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(2), [Keys.ARROW_RIGHT]); |
| 124 | + expect( |
| 125 | + await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(2), Attribute.IsFocused, AttributeValue.true), |
| 126 | + ).toBeTruthy(); |
| 127 | + |
| 128 | + expect(await FocusZonePageObject.didAssertPopup()) |
| 129 | + .withContext(FocusZonePageObject.ERRORMESSAGE_ASSERT) |
| 130 | + .toBeFalsy(); |
| 131 | + }); |
| 132 | + |
| 133 | + it('Navigates bi-directional focuszone with 2d navigation. Validate focus switches correctly.', async () => { |
| 134 | + await FocusZonePageObject.configureGridFocusZone('Set2DNavigation', true); |
| 135 | + |
| 136 | + await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(1), [Keys.ARROW_DOWN]); |
| 137 | + expect( |
| 138 | + await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(4), Attribute.IsFocused, AttributeValue.true), |
| 139 | + ).toBeTruthy(); |
| 140 | + |
| 141 | + await FocusZonePageObject.sendKeys(FocusZonePageObject.gridButton(4), [Keys.ARROW_RIGHT]); |
| 142 | + expect( |
| 143 | + await FocusZonePageObject.compareAttribute(FocusZonePageObject.gridButton(5), Attribute.IsFocused, AttributeValue.true), |
| 144 | + ).toBeTruthy(); |
| 145 | + |
| 146 | + expect(await FocusZonePageObject.didAssertPopup()) |
| 147 | + .withContext(FocusZonePageObject.ERRORMESSAGE_ASSERT) |
| 148 | + .toBeFalsy(); |
| 149 | + }); |
| 150 | +}); |
0 commit comments