Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
fabienSvstr committed Feb 11, 2025
1 parent 6fb3311 commit 5e4bd4b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 41 deletions.
6 changes: 1 addition & 5 deletions client/tests/e2e/specs/file_viewers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ msTest('File viewer page details', async ({ documents }) => {
await expect(documents).toHavePageTitle('File viewer');
await expect(documents.locator('.file-viewer').locator('.file-viewer-topbar').locator('ion-text')).toHaveText(/^File_[a-z0-9_.]+$/);
const buttons = documents.locator('.file-viewer').locator('.file-viewer-topbar').locator('ion-button');
await expect(buttons.nth(1)).toHaveText('Details');
const detailsModal = documents.locator('.file-details-modal');
await expect(detailsModal).toBeHidden();
await buttons.nth(1).click();
await expect(detailsModal).toBeVisible();
await expect(buttons).toHaveCount(4);
});

msTest('Quick access loads correct document', async ({ documents }) => {
Expand Down
34 changes: 17 additions & 17 deletions client/tests/e2e/specs/file_viewers_image.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ msTest('Image viewer', async ({ documents }) => {
const wrapper = documents.locator('.file-viewer-wrapper');
await expect(wrapper.locator('img')).toBeVisible();
const bottomBar = documents.locator('.file-viewer-bottombar');
const zoom = bottomBar.locator('.file-controls-zoom');
const zoom = bottomBar.locator('.zoom-controls');
await expect(zoom).toHaveCount(1);
});

Expand All @@ -22,48 +22,48 @@ msTest('Image viewer zoom', async ({ documents }) => {
await expect(documents.locator('.file-viewer').locator('.file-viewer-topbar').locator('ion-text')).toHaveText(/^File_[a-z0-9_]+\.png$/);
const bottomBar = documents.locator('.file-viewer-bottombar');
const wrapper = documents.locator('.file-viewer-wrapper');
const zoomControls = bottomBar.locator('.file-controls-zoom').locator('ion-button');
const zoomReset = zoomControls.nth(0);
const zoomMinus = zoomControls.nth(1);
const zoomPlus = zoomControls.nth(2);
const zoomLevel = bottomBar.locator('.file-controls-zoom').locator('span.zoom-level-input');
const zoomLevelInput = bottomBar.locator('.file-controls-zoom').locator('ion-input.zoom-level-input');
const zoom = bottomBar.locator('.zoom-controls');
const zoomReset = bottomBar.locator('#reset-zoom');
const zoomOut = zoom.locator('.file-controls-button-container').nth(0);
const zoomIn = zoom.locator('.file-controls-button-container').nth(1);
const zoomLevel = zoom.locator('ion-text.zoom-level-input');
const zoomLevelInput = zoom.locator('ion-input.zoom-level-input');

await expect(zoomLevelInput).toBeHidden();

await expect(zoomLevel).toHaveText('100 %');
await testFileViewerZoomLevel(wrapper, '1');

await zoomMinus.click();
await zoomMinus.click();
await zoomOut.click();
await zoomOut.click();
await expect(zoomLevel).toHaveText('80 %');
await testFileViewerZoomLevel(wrapper, '0.8');
for (let i = 0; i < 8; i++) {
await zoomMinus.click();
await zoomOut.click();
}
await expect(zoomMinus).toBeTrulyDisabled();
await expect(zoomLevel).toHaveText('5 %');
await expect(zoomOut).toBeTrulyDisabled();
await testFileViewerZoomLevel(wrapper, '0.05');
await zoomReset.click();
await expect(zoomLevel).toHaveText('100 %');
await testFileViewerZoomLevel(wrapper, '1');
await expect(zoomMinus).toBeTrulyEnabled();
await expect(zoomOut).toBeTrulyEnabled();

await zoomPlus.click();
await zoomPlus.click();
await zoomIn.click();
await zoomIn.click();
await expect(zoomLevel).toHaveText('150 %');
await testFileViewerZoomLevel(wrapper, '1.5');
for (let i = 0; i < 6; i++) {
await zoomPlus.click();
await zoomIn.click();
}
await expect(zoomPlus).toBeTrulyDisabled();
await expect(zoomIn).toBeTrulyDisabled();
await expect(zoomLevel).toHaveText('500 %');
await testFileViewerZoomLevel(wrapper, '5');
await zoomReset.click();

await expect(zoomLevel).toHaveText('100 %');
await testFileViewerZoomLevel(wrapper, '1');
await expect(zoomPlus).toBeTrulyEnabled();
await expect(zoomIn).toBeTrulyEnabled();

await zoomLevel.click();
await expect(zoomLevel).toBeHidden();
Expand Down
38 changes: 19 additions & 19 deletions client/tests/e2e/specs/file_viewers_spreadsheet.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ msTest('Spreadsheet viewer', async ({ documents }) => {
await expect(dropdownPopover).toBeHidden();
await dropdownButton.click();
await expect(dropdownPopover).toBeVisible();
const dropdownItems = dropdownPopover.locator('.dropdown-item');
const dropdownItems = dropdownPopover.locator('.file-controls-dropdown-item');
await expect(dropdownItems).toHaveText(['Sheet1', 'Sheet2']);
await expect(dropdownItems.nth(0)).toHaveTheClass('dropdown-item-active');
await expect(dropdownItems.nth(1)).not.toHaveTheClass('dropdown-item-active');
await expect(dropdownItems.nth(0)).toHaveTheClass('file-controls-dropdown-item-active');
await expect(dropdownItems.nth(1)).not.toHaveTheClass('file-controls-dropdown-item-active');

// Trying to switch to Sheet1, nothing should happen
await dropdownItems.nth(0).click();
Expand All @@ -52,48 +52,48 @@ msTest('Spreadsheet viewer zoom', async ({ documents }) => {
const wrapper = documents.locator('.file-viewer-wrapper');
const spreadsheet = wrapper.locator('.inner-content-table').nth(1).locator('.content-wrapper');
await expect(spreadsheet.locator('.rgCell')).toHaveText(['A', '1', 'B', '2', 'C', '3', 'D', '4']);
const zoomControls = bottomBar.locator('.file-controls-zoom').locator('ion-button');
const zoomReset = zoomControls.nth(0);
const zoomMinus = zoomControls.nth(1);
const zoomPlus = zoomControls.nth(2);
const zoomLevel = bottomBar.locator('.file-controls-zoom').locator('span.zoom-level-input');
const zoomLevelInput = bottomBar.locator('.file-controls-zoom').locator('ion-input.zoom-level-input');
const zoom = bottomBar.locator('.zoom-controls');
const zoomReset = bottomBar.locator('#reset-zoom');
const zoomOut = zoom.locator('.file-controls-button-container').nth(0);
const zoomIn = zoom.locator('.file-controls-button-container').nth(1);
const zoomLevel = zoom.locator('ion-text.zoom-level-input');
const zoomLevelInput = zoom.locator('ion-input.zoom-level-input');

await expect(zoomLevelInput).toBeHidden();

await expect(zoomLevel).toHaveText('100 %');
await testFileViewerZoomLevel(wrapper, '1');

await zoomMinus.click();
await zoomMinus.click();
await zoomOut.click();
await zoomOut.click();
await expect(zoomLevel).toHaveText('80 %');
await testFileViewerZoomLevel(wrapper, '0.8');
for (let i = 0; i < 8; i++) {
await zoomMinus.click();
await zoomOut.click();
}
await expect(zoomMinus).toBeTrulyDisabled();
await expect(zoomOut).toBeTrulyDisabled();
await expect(zoomLevel).toHaveText('5 %');
await testFileViewerZoomLevel(wrapper, '0.05');
await zoomReset.click();
await expect(zoomLevel).toHaveText('100 %');
await testFileViewerZoomLevel(wrapper, '1');
await expect(zoomMinus).toBeTrulyEnabled();
await expect(zoomOut).toBeTrulyEnabled();

await zoomPlus.click();
await zoomPlus.click();
await zoomIn.click();
await zoomIn.click();
await expect(zoomLevel).toHaveText('150 %');
await testFileViewerZoomLevel(wrapper, '1.5');
for (let i = 0; i < 6; i++) {
await zoomPlus.click();
await zoomIn.click();
}
await expect(zoomPlus).toBeTrulyDisabled();
await expect(zoomIn).toBeTrulyDisabled();
await expect(zoomLevel).toHaveText('500 %');
await testFileViewerZoomLevel(wrapper, '5');
await zoomReset.click();

await expect(zoomLevel).toHaveText('100 %');
await testFileViewerZoomLevel(wrapper, '1');
await expect(zoomPlus).toBeTrulyEnabled();
await expect(zoomIn).toBeTrulyEnabled();

await zoomLevel.click();
await expect(zoomLevel).toBeHidden();
Expand Down

0 comments on commit 5e4bd4b

Please sign in to comment.