|
1 | 1 | const AppPage = require('../pageobjects/app.page') |
2 | 2 |
|
3 | | -describe('My application', () => { |
| 3 | +describe('Example App for "pdf-viewer-reactjs"', () => { |
4 | 4 | before(() => { |
5 | 5 | AppPage.open() |
6 | 6 | }) |
7 | 7 |
|
8 | | - it('Should display the viewer', () => { |
9 | | - expect(AppPage.loadFromURL).toBeExisting() |
| 8 | + describe('"Custom loader element" section', () => { |
| 9 | + before(() => { |
| 10 | + AppPage.section = 'cl' |
| 11 | + }) |
| 12 | + |
| 13 | + it('Should be displayed', () => { |
| 14 | + expect(AppPage.section).toBeExisting() |
| 15 | + }) |
| 16 | + |
| 17 | + it('Should display the custom loader message', () => { |
| 18 | + expect(AppPage.loader).toHaveText('Custom loader element') |
| 19 | + }) |
| 20 | + }) |
| 21 | + |
| 22 | + describe('"Fetch PDF by URL" section', () => { |
| 23 | + before(() => { |
| 24 | + AppPage.section = 'url' |
| 25 | + }) |
| 26 | + |
| 27 | + it('Should be displayed', () => { |
| 28 | + expect(AppPage.section).toBeExisting() |
| 29 | + }) |
| 30 | + |
| 31 | + it('Should display the loader', () => { |
| 32 | + expect(AppPage.loader).toBeExisting() |
| 33 | + }) |
| 34 | + |
| 35 | + it('Loader should become hidden', () => { |
| 36 | + expect( |
| 37 | + AppPage.loader.waitForDisplayed({ |
| 38 | + timeout: 60000, |
| 39 | + reverse: true, |
| 40 | + interval: 5000, |
| 41 | + }) |
| 42 | + ).toBe(true) |
| 43 | + }) |
| 44 | + |
| 45 | + it('PDF Viewer should become visible', () => { |
| 46 | + expect( |
| 47 | + AppPage.pdfViewer.waitForDisplayed({ |
| 48 | + timeout: 60000, |
| 49 | + reverse: true, |
| 50 | + interval: 5000, |
| 51 | + }) |
| 52 | + ).toBe(true) |
| 53 | + }) |
| 54 | + |
| 55 | + it('Should display thumbnails of all the pages', () => { |
| 56 | + expect(AppPage.thumbnails).toBeElementsArrayOfSize(65) |
| 57 | + }) |
| 58 | + }) |
| 59 | + |
| 60 | + describe('"Load PDF from base 64 string" section', () => { |
| 61 | + before(() => { |
| 62 | + AppPage.section = 'base64' |
| 63 | + }) |
| 64 | + |
| 65 | + it('Should be displayed', () => { |
| 66 | + expect(AppPage.section).toBeExisting() |
| 67 | + }) |
| 68 | + |
| 69 | + it('Should display first page initially', () => { |
| 70 | + expect(AppPage.pageIndicator).toHaveText('Page 1 / 1') |
| 71 | + }) |
| 72 | + |
| 73 | + it('Zoom Out & Zoom Reset button should be disabled', () => { |
| 74 | + expect(AppPage.zoomOutButton.isEnabled()).toBe(false) |
| 75 | + expect(AppPage.zoomResetButton.isEnabled()).toBe(false) |
| 76 | + }) |
| 77 | + |
| 78 | + it('Previous & Next page button should be disabled', () => { |
| 79 | + expect(AppPage.nextPageButton.isEnabled()).toBe(false) |
| 80 | + expect(AppPage.prevPageButton.isEnabled()).toBe(false) |
| 81 | + }) |
| 82 | + |
| 83 | + it('Rotation Reset button should be disabled', () => { |
| 84 | + expect(AppPage.rotateResetButton.isEnabled()).toBe(false) |
| 85 | + }) |
| 86 | + }) |
| 87 | + |
| 88 | + describe('"Error message for failures" section', () => { |
| 89 | + before(() => { |
| 90 | + AppPage.section = 'eh' |
| 91 | + }) |
| 92 | + |
| 93 | + it('Should be displayed', () => { |
| 94 | + expect(AppPage.section).toBeExisting() |
| 95 | + }) |
| 96 | + |
| 97 | + it('Should display the error message', () => { |
| 98 | + expect(AppPage.alert).toHaveText( |
| 99 | + 'error_outline\nError while opening the document !' |
| 100 | + ) |
| 101 | + }) |
10 | 102 | }) |
11 | 103 |
|
12 | | - it.skip('Should have page at 1', () => { |
13 | | - expect(AppPage.getPageIndicator).toHaveText('Page 1 / 43') |
| 104 | + describe('"Custom Error component for failures" section', () => { |
| 105 | + before(() => { |
| 106 | + AppPage.section = 'ceh' |
| 107 | + }) |
| 108 | + |
| 109 | + it('Should be displayed', () => { |
| 110 | + expect(AppPage.section).toBeExisting() |
| 111 | + }) |
| 112 | + |
| 113 | + it('Should display the custom error message', () => { |
| 114 | + expect(AppPage.alert).toHaveText( |
| 115 | + 'Failed To load !!!\nError while opening the document !' |
| 116 | + ) |
| 117 | + }) |
| 118 | + }) |
| 119 | + |
| 120 | + describe('"Custom starting page" section', () => { |
| 121 | + before(() => { |
| 122 | + AppPage.section = 'csp' |
| 123 | + }) |
| 124 | + |
| 125 | + it('Should be displayed', () => { |
| 126 | + expect(AppPage.section).toBeExisting() |
| 127 | + }) |
| 128 | + |
| 129 | + it('Should display Fifth page initially', () => { |
| 130 | + expect(AppPage.pageIndicator).toHaveText('Page 5 / 65') |
| 131 | + }) |
| 132 | + |
| 133 | + it('Should change the page on next & previous button click', () => { |
| 134 | + AppPage.nextPageButton.click() |
| 135 | + expect(AppPage.pageIndicator).toHaveText('Page 6 / 65') |
| 136 | + AppPage.prevPageButton.click() |
| 137 | + expect(AppPage.pageIndicator).toHaveText('Page 5 / 65') |
| 138 | + }) |
| 139 | + |
| 140 | + it('Should change the rotation on left & right rotation button click', () => { |
| 141 | + const H = AppPage.canvas.getSize('height') |
| 142 | + const W = AppPage.canvas.getSize('width') |
| 143 | + AppPage.rotateRightButton.click() |
| 144 | + expect(AppPage.canvas.getSize('height')).toBe(W) |
| 145 | + expect(AppPage.canvas.getSize('width')).toBe(H) |
| 146 | + AppPage.rotateResetButton.click() |
| 147 | + expect(AppPage.canvas.getSize('height')).toBe(H) |
| 148 | + expect(AppPage.canvas.getSize('width')).toBe(W) |
| 149 | + AppPage.rotateLeftButton.click() |
| 150 | + expect(AppPage.canvas.getSize('height')).toBe(W) |
| 151 | + expect(AppPage.canvas.getSize('width')).toBe(H) |
| 152 | + }) |
| 153 | + |
| 154 | + it('Should change the scale on Zoom Out & Zoom In button click', () => { |
| 155 | + const H = AppPage.canvas.getSize('height') |
| 156 | + const W = AppPage.canvas.getSize('width') |
| 157 | + AppPage.zoomInButton.click() |
| 158 | + expect(AppPage.canvas.getSize('height')).toBe(H * 2) |
| 159 | + expect(AppPage.canvas.getSize('width')).toBe(W * 2) |
| 160 | + AppPage.zoomResetButton.click() |
| 161 | + expect(AppPage.canvas.getSize('height')).toBe(H) |
| 162 | + expect(AppPage.canvas.getSize('width')).toBe(W) |
| 163 | + AppPage.zoomInButton.click() |
| 164 | + expect(AppPage.canvas.getSize('height')).toBe(H * 2) |
| 165 | + expect(AppPage.canvas.getSize('width')).toBe(W * 2) |
| 166 | + AppPage.zoomOutButton.click() |
| 167 | + expect(AppPage.canvas.getSize('height')).toBe(H) |
| 168 | + expect(AppPage.canvas.getSize('width')).toBe(W) |
| 169 | + }) |
| 170 | + }) |
| 171 | + |
| 172 | + describe('"Without Navigation" section', () => { |
| 173 | + before(() => { |
| 174 | + AppPage.section = 'wn' |
| 175 | + }) |
| 176 | + |
| 177 | + it('Should be displayed', () => { |
| 178 | + expect(AppPage.section).toBeExisting() |
| 179 | + }) |
| 180 | + |
| 181 | + it('Should not display the navigation', () => { |
| 182 | + expect(AppPage.prevPageButton.isExisting()).toBe(false) |
| 183 | + expect(AppPage.pageIndicator.isExisting()).toBe(false) |
| 184 | + expect(AppPage.nextPageButton.isExisting()).toBe(false) |
| 185 | + }) |
| 186 | + }) |
| 187 | + |
| 188 | + describe('"Without Zoom and Rotation" section', () => { |
| 189 | + before(() => { |
| 190 | + AppPage.section = 'wzr' |
| 191 | + }) |
| 192 | + |
| 193 | + it('Should be displayed', () => { |
| 194 | + expect(AppPage.section).toBeExisting() |
| 195 | + }) |
| 196 | + |
| 197 | + it('Should not display the zoom controls', () => { |
| 198 | + expect(AppPage.zoomOutButton.isExisting()).toBe(false) |
| 199 | + expect(AppPage.zoomInButton.isExisting()).toBe(false) |
| 200 | + }) |
| 201 | + |
| 202 | + it('Should not display the rotation controls', () => { |
| 203 | + expect(AppPage.rotateLeftButton.isExisting()).toBe(false) |
| 204 | + expect(AppPage.rotateRightButton.isExisting()).toBe(false) |
| 205 | + }) |
14 | 206 | }) |
15 | 207 |
|
16 | | - it.skip('Should display the second page on next click', () => { |
17 | | - AppPage.getButtons.click() |
18 | | - expect(AppPage.getPageIndicator).toHaveText('Page 2 / 43') |
| 208 | + describe('"External Controls" section', () => { |
| 209 | + before(() => { |
| 210 | + AppPage.section = 'ec' |
| 211 | + }) |
| 212 | + |
| 213 | + it('Should be displayed', () => { |
| 214 | + expect(AppPage.section).toBeExisting() |
| 215 | + }) |
| 216 | + |
| 217 | + it('External Controls should work', () => { |
| 218 | + const H = AppPage.canvas.getSize('height') |
| 219 | + const W = AppPage.canvas.getSize('width') |
| 220 | + AppPage.extZoomInButton.click() |
| 221 | + expect(AppPage.canvas.getSize('height')).toBe(H * 2) |
| 222 | + expect(AppPage.canvas.getSize('width')).toBe(W * 2) |
| 223 | + AppPage.extZoomOutButton.click() |
| 224 | + expect(AppPage.canvas.getSize('height')).toBe(H) |
| 225 | + expect(AppPage.canvas.getSize('width')).toBe(W) |
| 226 | + }) |
19 | 227 | }) |
20 | 228 | }) |
0 commit comments