Skip to content

Commit

Permalink
[MS] Updated e2e tests to better handle loadings
Browse files Browse the repository at this point in the history
  • Loading branch information
Max-7 committed Dec 20, 2024
1 parent c9fe967 commit a59e028
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion client/src/views/layouts/LoadingLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { onMounted } from 'vue';
onMounted(async () => {
// When trying to switch from one connected org to another,
// we have trouble remounting the components because the
// url doesn't change enough according to vue-router (/1 to /2 for exemple),
// url doesn't change enough according to vue-router (/1 to /2 for example),
// which means it doesn't remount a new component and instead insists on re-using
// an existing one. This is a pain for us as we don't want to add a watch
// in every component.
Expand Down
2 changes: 2 additions & 0 deletions client/tests/e2e/helpers/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ export const msTest = base.extend<{
await home.locator('#password-input').locator('input').fill('P@ssw0rd.');
await expect(home.locator('.login-button')).toBeEnabled();
await home.locator('.login-button').click();
await expect(home.locator('.loading-container')).toBeVisible();
await expect(home).toHaveURL(/\/loading\??.*$/);
await expect(home.locator('#connected-header')).toContainText('My workspaces');
await expect(home).toBeWorkspacePage();

Expand Down
13 changes: 5 additions & 8 deletions client/tests/e2e/specs/file_viewers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ async function openFileType(documentsPage: Page, type: 'xlsx' | 'docx' | 'png' |
const entryName = (await entry.locator('.file-name').locator('.file-name__label').textContent()) ?? '';
if (entryName.endsWith(`.${type}`)) {
await entry.dblclick();
await expect(documentsPage.locator('.ms-spinner-modal')).toBeVisible();
await expect(documentsPage.locator('.ms-spinner-modal').locator('.spinner-label__text')).toHaveText('Opening file...');
await expect(documentsPage.locator('.ms-spinner-modal')).toBeHidden();
await expect(documentsPage).toBeViewerPage();
return;
}
}
Expand All @@ -20,7 +24,7 @@ msTest('Documents page default state', async ({ documents }) => {

await entries.nth(2).dblclick();
await expect(documents.locator('.ms-spinner-modal')).toBeVisible();
await documents.waitForTimeout(500);
await expect(documents.locator('.ms-spinner-modal').locator('.spinner-label__text')).toHaveText('Opening file...');
await expect(documents.locator('.ms-spinner-modal')).toBeHidden();
await expect(documents).toBeViewerPage();
await expect(documents).toHavePageTitle('File viewer');
Expand All @@ -29,7 +33,6 @@ msTest('Documents page default state', async ({ documents }) => {

msTest('Spreadsheet viewer', async ({ documents }) => {
await openFileType(documents, 'xlsx');
await documents.waitForTimeout(500);
await expect(documents).toBeViewerPage();
await expect(documents).toHavePageTitle('File viewer');
await expect(documents.locator('.file-viewer').locator('.file-viewer-topbar').locator('ion-text')).toHaveText(/^File_[a-z0-9_]+\.xlsx$/);
Expand All @@ -44,7 +47,6 @@ msTest('Spreadsheet viewer', async ({ documents }) => {

msTest('Document viewer', async ({ documents }) => {
await openFileType(documents, 'docx');
await documents.waitForTimeout(500);
await expect(documents).toBeViewerPage();
await expect(documents).toHavePageTitle('File viewer');
await expect(documents.locator('.file-viewer').locator('.file-viewer-topbar').locator('ion-text')).toHaveText(/^File_[a-z0-9_]+\.docx$/);
Expand All @@ -65,7 +67,6 @@ msTest('Document viewer', async ({ documents }) => {

msTest('PDF viewer', async ({ documents }) => {
await openFileType(documents, 'pdf');
await documents.waitForTimeout(500);
await expect(documents).toBeViewerPage();
await expect(documents).toHavePageTitle('File viewer');
await expect(documents.locator('.file-viewer').locator('.file-viewer-topbar').locator('ion-text')).toHaveText(/^File_[a-z0-9_]+\.pdf$/);
Expand Down Expand Up @@ -104,7 +105,6 @@ msTest('PDF viewer', async ({ documents }) => {

msTest('Image viewer', async ({ documents }) => {
await openFileType(documents, 'png');
await documents.waitForTimeout(500);
await expect(documents).toBeViewerPage();
await expect(documents).toHavePageTitle('File viewer');
await expect(documents.locator('.file-viewer').locator('.file-viewer-topbar').locator('ion-text')).toHaveText(/^File_[a-z0-9_]+\.png$/);
Expand All @@ -118,7 +118,6 @@ msTest('Image viewer', async ({ documents }) => {

msTest('Audio viewer', async ({ documents }) => {
await openFileType(documents, 'mp3');
await documents.waitForTimeout(500);
await expect(documents).toBeViewerPage();
await expect(documents).toHavePageTitle('File viewer');
await expect(documents.locator('.file-viewer').locator('.file-viewer-topbar').locator('ion-text')).toHaveText(/^File_[a-z0-9_]+\.mp3$/);
Expand All @@ -135,7 +134,6 @@ msTest('Audio viewer', async ({ documents }) => {

msTest('Video viewer', async ({ documents }) => {
await openFileType(documents, 'mp4');
await documents.waitForTimeout(500);
await expect(documents).toBeViewerPage();
await expect(documents).toHavePageTitle('File viewer');
await expect(documents.locator('.file-viewer').locator('.file-viewer-topbar').locator('ion-text')).toHaveText(/^File_[a-z0-9_]+\.mp4$/);
Expand Down Expand Up @@ -176,7 +174,6 @@ msTest('Video viewer', async ({ documents }) => {

msTest('Text viewer', async ({ documents }) => {
await openFileType(documents, 'py');
await documents.waitForTimeout(500);
await expect(documents).toBeViewerPage();
await expect(documents).toHavePageTitle('File viewer');
await expect(documents.locator('.file-viewer').locator('.file-viewer-topbar').locator('ion-text')).toHaveText(/^File_[a-z0-9_]+\.py$/);
Expand Down

0 comments on commit a59e028

Please sign in to comment.