Skip to content

Commit

Permalink
Fix Playwright tests
Browse files Browse the repository at this point in the history
  • Loading branch information
R0Wi committed Feb 2, 2025
1 parent 5ba0453 commit 6bc860f
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 28 deletions.
32 changes: 16 additions & 16 deletions tests/E2E/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions tests/E2E/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"author": "",
"license": "ISC",
"devDependencies": {
"playwright": "^1.40.1",
"@playwright/test": "^1.40.1"
"playwright": "^1.50.1",
"@playwright/test": "^1.50.1"
}
}
2 changes: 1 addition & 1 deletion tests/E2E/tests/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export async function loginAndSwitchToPPVTestFiles(page) {
await page.locator('#password').fill(process.env.E2E_PASSWORD ?? 'admin');
await page.locator('#password').press('Enter');
await page.getByLabel('Files', { exact: true }).click();
await page.getByRole('button', { name: 'ppv-testfiles' }).click();
await page.getByRole('button', { name: /.*\sppv-testfiles.*/ }).click();
};

export const frameId = '#photo-sphere-viewer-frame';
Expand Down
8 changes: 6 additions & 2 deletions tests/E2E/tests/directory-share.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ async function shareDirectory(page) {

test('PPV should show on click on directory shared pano.jpg', async ({ page }) => {
// Open pano
await page.getByRole('link', { name: 'pano .jpg Actions', exact: true }).click();
await page.getByRole('row', { name: /.*"pano.jpg".*/ }).click();

await page.locator(frameId).waitFor({ state: 'visible', timeout: 5000 });
const ppvLocator = page.frameLocator(frameId);

Expand All @@ -55,7 +56,7 @@ test('PPV should show on click on directory shared pano.jpg', async ({ page }) =

test('PPV should not show on click on directory shared non-pano.jpg', async ({ page }) => {
// Open image
await page.getByRole('link', { name: 'non-pano .jpg Actions', exact: true }).click();
await page.getByRole('row', { name: /.*"non-pano.jpg".*/ }).click();

// Assert PPV did not open
let visible = true;
Expand All @@ -68,4 +69,7 @@ test('PPV should not show on click on directory shared non-pano.jpg', async ({ p
}

expect(visible).toBe(false);

// Assert regular viewer opened
await page.getByRole('img', { name: 'non-pano.jpg' }).waitFor({ state: 'visible', timeout: 1000 });
});
16 changes: 9 additions & 7 deletions tests/E2E/tests/regular-fileview.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ test.beforeEach(async ({ page }) => {

test('PPV should show', async ({ page }) => {
const ppvTestDirUrl = page.url();
const panoLink = page.getByRole('link', { name: 'pano .jpg', exact: true });
const panoRow = page.locator('tr', { has: panoLink });
const panoRow = await page.getByRole('row', { name: /.*"pano.jpg".*/ });
const panoFileId = await panoRow.getAttribute('data-cy-files-list-row-fileid');

expect(ppvTestDirUrl).not.toContain('/' + panoFileId + '?');

// Open 1st time
await panoLink.click();
await panoRow.click();
await page.locator(frameId).waitFor({ state: 'visible' });

expect(page.url()).toContain('/' + panoFileId + '?');
Expand All @@ -30,7 +29,7 @@ test('PPV should show', async ({ page }) => {
expect(page.url()).toBe(ppvTestDirUrl);

// Open 2nd time
await panoLink.click();
await panoRow.click();
await page.locator(frameId).waitFor({ state: 'visible' });

// Move the image
Expand All @@ -51,8 +50,8 @@ test('PPV should show', async ({ page }) => {
});

test('PPV should not show', async ({ page }) => {
await page.getByRole('link', { name: 'non-pano .jpg', exact: true }).click();
await page.getByRole('row', { name: /.*"non-pano.jpg".*/ }).click();

// Assert PPV did not open
let visible = true;
try {
Expand All @@ -64,11 +63,14 @@ test('PPV should not show', async ({ page }) => {
}

expect(visible).toBe(false);

// Assert regular viewer opened
await page.getByRole('img', { name: 'non-pano.jpg' }).waitFor({ state: 'visible', timeout: 1000 });
});

test('360 video should show on context menu click', async ({ page }) => {
// Note :: this test needs to run on Chrome because Chromium lacks support for 360 video codecs
await page.getByRole('row', { name: 'Toggle selection for file "360-video.mp4" 360-video .mp4 Show sharing options' }).getByLabel('Actions').click();
await page.getByRole('row', { name: /.*"360-video.mp4".*/ }).getByLabel('Actions').click();
await page.getByRole('menuitem', { name: 'View in 360° viewer' }).click();

await expect(page.frameLocator('#photo-sphere-viewer-frame').locator('#pano div').nth(1)).toBeVisible({ timeout: 1000 });
Expand Down

0 comments on commit 6bc860f

Please sign in to comment.