diff --git a/tests/e2e-playwright/specs/01_validate-transcoder-settings.spec.js b/tests/e2e-playwright/specs/01_validate-transcoder-settings.spec.js index 2f0a78a..3ffbe39 100644 --- a/tests/e2e-playwright/specs/01_validate-transcoder-settings.spec.js +++ b/tests/e2e-playwright/specs/01_validate-transcoder-settings.spec.js @@ -16,7 +16,6 @@ test.describe('Validate Transcoder Settings', () => { await page.focus("input[id='new-api-key']"); await licenseSettings.fill("8c1a107c6c89bd9dda666a635f441890"); await page.locator("button[id='api-key-submit']").click(); - await page.screenshot({ path: "uploads/uploads.png" }) //verify Save key await expect(page.locator("div[class='updated']")).not.toBeNull() await page.locator("#submit").click(); diff --git a/tests/e2e-playwright/specs/02_validate-webm-completed.spec.js b/tests/e2e-playwright/specs/02_validate-webm-completed.spec.js index 1da4d0b..dd20911 100644 --- a/tests/e2e-playwright/specs/02_validate-webm-completed.spec.js +++ b/tests/e2e-playwright/specs/02_validate-webm-completed.spec.js @@ -44,12 +44,12 @@ test.describe('Validate Webm File upload Asssert All Status', () => { await page.waitForSelector("div[id*='span_status']"); const tweets = page.locator("div[id*='span_status']"); var result = await tweets.evaluate(node => node.innerText); - // Declaring Variables so that Loops Will break after certain period of time + // Declaring Variables so that Loops Will break after Successfull Execution var _hasTimeElasped = false; setTimeout(() => { _hasTimeElasped = true; console.log("Time Elapsed") - }, 90000) + }, 60000) // Loop To Assert Updated Messages while (result == TransCodeStatus.Processing || result == TransCodeStatus.Queue || TransCodeStatus.ServerReady) { // Loop Breaker After Timeout @@ -65,10 +65,16 @@ test.describe('Validate Webm File upload Asssert All Status', () => { if (result == TransCodeStatus.Completed || result == TransCodeStatus.Error) { break; } - } - // Final Assertion after completion. - const comPleteMessage = page.locator("div[id*='span_status']"); - expect(await comPleteMessage.evaluate(node => node.innerText)).toContain('Your file is transcoded successfully.'); + // Delete The media to Execute the next Test cases + await page.locator("td.title.column-title.has-row-actions.column-primary ").first().hover(); + await page.locator("td.title.column-title.has-row-actions.column-primary > div > span.edit").first().click(); + // Wait for New page to load + await page.waitForSelector("#title"); + await page.waitForSelector("#attachment_caption"); + await expect(page).toHaveURL(/action=edit/) + // Delete media After testing + page.on('dialog', dialog => dialog.accept()); + await page.locator("#delete-action > a").click(); }); }); \ No newline at end of file diff --git a/tests/e2e-playwright/specs/03_validate-3gp-completed.spec.js b/tests/e2e-playwright/specs/03_validate-3gp-completed.spec.js index 8b1de38..fdaa34e 100644 --- a/tests/e2e-playwright/specs/03_validate-3gp-completed.spec.js +++ b/tests/e2e-playwright/specs/03_validate-3gp-completed.spec.js @@ -67,10 +67,15 @@ test.describe('Validate 3gp File Upload and assert All transcoded Status', () => break; } } - // Final Assertion after completion. - const comPleteMessage = page.locator("div[id*='span_status']"); - expect(await comPleteMessage.evaluate(node => node.innerText)).toContain('Your file is transcoded successfully.'); - await page.reload(); - await expect(checkStatus).toBeHidden(); + // Delete The media to Execute the next Test cases + await page.locator("td.title.column-title.has-row-actions.column-primary ").first().hover(); + await page.locator("td.title.column-title.has-row-actions.column-primary > div > span.edit").first().click(); + // Wait for New page to load + await page.waitForSelector("#title"); + await page.waitForSelector("#attachment_caption"); + await expect(page).toHaveURL(/action=edit/) + // Delete media After testing + page.on('dialog', dialog => dialog.accept()); + await page.locator("#delete-action > a").click(); }); }); \ No newline at end of file diff --git a/tests/e2e-playwright/specs/04_validate-3g2-error.spec.js b/tests/e2e-playwright/specs/04_validate-3g2-error.spec.js index db093bd..655e9ac 100644 --- a/tests/e2e-playwright/specs/04_validate-3g2-error.spec.js +++ b/tests/e2e-playwright/specs/04_validate-3g2-error.spec.js @@ -65,12 +65,15 @@ test.describe('Validate 3g2 Media types and error message', () => { break; } } - const comPleteMessage = page.locator("div[id*='span_status']"); - expect(await comPleteMessage.evaluate(node => node.innerText)).toContain('Transcoder failed to transcode this file.'); // Delete The media to Execute the next Test cases - await page.locator("role=link[name='“3g2-sample” (Edit)']").first().hover(); + await page.locator("td.title.column-title.has-row-actions.column-primary ").first().hover(); + await page.locator("td.title.column-title.has-row-actions.column-primary > div > span.edit").first().click(); + // Wait for New page to load + await page.waitForSelector("#title"); + await page.waitForSelector("#attachment_caption"); + await expect(page).toHaveURL(/action=edit/) + // Delete media After testing page.on('dialog', dialog => dialog.accept()); - await page.locator("role=button[name='Delete “3g2-sample” permanently']").click(); - await expect(checkStatus).toBeHidden(); + await page.locator("#delete-action > a").click(); }); }); \ No newline at end of file diff --git a/tests/e2e-playwright/specs/05_validate-other-file-status.spec.js b/tests/e2e-playwright/specs/05_validate-other-file-status.spec.js index 9835948..c7b2019 100644 --- a/tests/e2e-playwright/specs/05_validate-other-file-status.spec.js +++ b/tests/e2e-playwright/specs/05_validate-other-file-status.spec.js @@ -64,14 +64,16 @@ test.describe('Validate mp3 and mp4 ogg, PDF types and Assert All Steps', () => break; } } - // Final Assertion after completion. - const comPleteMessage = page.locator("div[id*='span_status']"); - expect(await comPleteMessage.evaluate(node => node.innerText)).toContain('processed'); - // Delete The media to Execute the next Test cases - await page.locator("role=link[name='“ogg-sample” (Edit)']").first().hover(); + // Delete the media and verify Media can be accessed + await page.locator("td.title.column-title.has-row-actions.column-primary ").first().hover(); + await page.locator("td.title.column-title.has-row-actions.column-primary > div > span.edit").first().click(); + // Wait for New page to load + await page.waitForSelector("#title"); + await page.waitForSelector("#attachment_caption"); + await expect(page).toHaveURL(/action=edit/) + // Delete media After testing page.on('dialog', dialog => dialog.accept()); - await page.locator("role=button[name='Delete “ogg-sample” permanently']").first().click(); - await expect(checkStatus).toBeHidden(); + await page.locator("#delete-action > a").click(); }); test('Check mp3 sample', async ({ admin, page, editor }) => { @@ -102,10 +104,15 @@ test.describe('Validate mp3 and mp4 ogg, PDF types and Assert All Steps', () => // Check File is already transcoded const checkMessage = page.locator("div[id*='span_status']").first(); expect(checkMessage).not.toBeNull(); - // Delete The media to Execute the next Test cases - await page.locator("role=link[name='“Impact Moderato” (Edit)']").first().hover(); + await page.locator("td.title.column-title.has-row-actions.column-primary ").first().hover(); + await page.locator("td.title.column-title.has-row-actions.column-primary > div > span.edit").first().click(); + // Wait for New page to load + await page.waitForSelector("#title"); + await page.waitForSelector("#attachment_caption"); + await expect(page).toHaveURL(/action=edit/) + // Delete media After testing page.on('dialog', dialog => dialog.accept()); - await page.locator("role=button[name='Delete “Impact Moderato” permanently']").first().click(); + await page.locator("#delete-action > a").click(); }); test('Check mp4 sample', async ({ admin, page, editor }) => { @@ -166,13 +173,15 @@ test.describe('Validate mp3 and mp4 ogg, PDF types and Assert All Steps', () => } } // Final Assertion after completion. - const comPleteMessage = page.locator("div[id*='span_status']"); - expect(await comPleteMessage.evaluate(node => node.innerText)).toContain('processed'); - //Delete The media to Execute the next Test cases - await page.locator("role=link[name='“mp4-sample” (Edit)']").first().hover(); + await page.locator("td.title.column-title.has-row-actions.column-primary ").first().hover(); + await page.locator("td.title.column-title.has-row-actions.column-primary > div > span.edit").first().click(); + // Wait for New page to load + await page.waitForSelector("#title"); + await page.waitForSelector("#attachment_caption"); + await expect(page).toHaveURL(/action=edit/) + // Delete media After testing page.on('dialog', dialog => dialog.accept()); - await page.locator("role=button[name='Delete “mp4-sample” permanently']").first().click(); - await expect(checkStatus).toBeHidden(); + await page.locator("#delete-action > a").click(); }); test('Check pdf sample', async ({ admin, page, editor }) => { const pdfPath = "assets/pdf-sample.pdf"; @@ -205,16 +214,16 @@ test.describe('Validate mp3 and mp4 ogg, PDF types and Assert All Steps', () => expect(checkMessage).not.toBeNull(); // Check For Transcoding status and wait until File is getting transcoded - await checkStatus.click(); - await page.focus("div[id*='span_status']") - await page.waitForSelector("div[id*='span_status']"); + // await checkStatus.click(); + // await page.focus("div[id*='span_status']") + // await page.waitForSelector("div[id*='span_status']"); const tweets = page.locator("div[id*='span_status']"); var result = await tweets.evaluate(node => node.innerText); var _hasTimeElasped = false; setTimeout(() => { _hasTimeElasped = true; console.log("Time Elapsed") - }, 10000) + }, 20000) // Loop To Assert Updated Messages while (result == TransCodeStatus.Processing || result == TransCodeStatus.Queue || TransCodeStatus.ServerReady) { // Loop Breaker After Timeout @@ -232,12 +241,15 @@ test.describe('Validate mp3 and mp4 ogg, PDF types and Assert All Steps', () => } } // Final Assertion after completion. - const comPleteMessage = page.locator("div[id*='span_status']"); - expect(await comPleteMessage.evaluate(node => node.innerText)).toContain('Your file is transcoded successfully. Please refresh the page.'); - // Delete The media to Execute the next Test cases - await page.locator("role=link[name='“pdf-sample” (Edit)']").first().hover(); + await page.locator("td.title.column-title.has-row-actions.column-primary ").first().hover(); + await page.locator("td.title.column-title.has-row-actions.column-primary > div > span.edit").first().click(); + // Wait for New page to load + await page.waitForSelector("#title"); + await page.waitForSelector("#attachment_caption"); + await expect(page).toHaveURL(/action=edit/) + // Delete media After testing page.on('dialog', dialog => dialog.accept()); - await page.locator("role=button[name='Delete “pdf-sample” permanently']").first().click(); + await page.locator("#delete-action > a").click(); }); }); \ No newline at end of file diff --git a/tests/e2e-playwright/specs/07_validate-retranscoded-media.spec.js b/tests/e2e-playwright/specs/07_validate-retranscoded-media.spec.js index de53142..ea702ae 100644 --- a/tests/e2e-playwright/specs/07_validate-retranscoded-media.spec.js +++ b/tests/e2e-playwright/specs/07_validate-retranscoded-media.spec.js @@ -2,40 +2,82 @@ * WordPress dependencies */ const { test, expect } = require('@wordpress/e2e-test-utils-playwright'); - +const { setTimeout } = require('timers'); +const { TransCodeStatus } = require("../utils/locator.js"); test.describe('Validate ReTranscoded Settings', () => { test.beforeEach(async ({ admin }) => { await admin.visitAdminPage('/'); }); test('Validate new retranscoded Settings', async ({ admin, page, editor }) => { await admin.visitAdminPage("media-new.php") - const pdfPath = "assets/pdf-sample.pdf"; + // Upload Video + const videoPath = "assets/3gp-sample.3gp"; const [fileChooser] = await Promise.all([ // It is important to call waitForEvent before click to set up waiting. page.waitForEvent('filechooser'), // Opens the file chooser. page.locator('#plupload-browse-button').click(), + ]) await fileChooser.setFiles([ - pdfPath, + videoPath, ]) + // Check Upload is completed const item = await page.locator("#wpbody-content > div.wrap > h1"); await expect(item).toBeVisible(); + + // Check Copy to clipboard is working const copyButton = "button[class='button button-small copy-attachment-url']"; if (await page.locator(copyButton).isEnabled()) { await page.click(copyButton) } + // Goto Media and Check for Check status Button visibility await admin.visitAdminPage("upload.php"); - //Select Grid + //Select Grid Type await page.locator("a[id='view-switch-list']").click(); const checkStatus = page.locator("button[id^='btn_check_status']").first(); expect(checkStatus).not.toBeNull(); + await checkStatus.click(); + const checkMessage = page.locator("div[id*='span_status']").first(); + expect(checkMessage).not.toBeNull(); + + // Check For Transcoding status and wait until File is getting transcoded + await checkStatus.click(); + await page.focus("div[id*='span_status']") + await page.waitForSelector("div[id*='span_status']"); + const tweets = page.locator("div[id*='span_status']"); + var result = await tweets.evaluate(node => node.innerText); + var _hasTimeElasped = false; + setTimeout(() => { + _hasTimeElasped = true; + console.log("Time Elapsed") + }, 90000) + // Loop To Assert Updated Messages + while (result == TransCodeStatus.Processing || result == TransCodeStatus.Queue || TransCodeStatus.ServerReady) { + // Loop Breaker After Timeout + if (_hasTimeElasped) { + break; + } + await checkStatus.click(); + await page.focus("div[id*='span_status']") + await page.waitForSelector("div[id*='span_status']"); + const tweets = page.locator("div[id*='span_status']"); + result = await tweets.evaluate(node => node.innerText); + console.log("Inside Loop:", result); + if (result == TransCodeStatus.Completed || result == TransCodeStatus.Error) { + break; + } + } + // Final Assertion after completion. + const comPleteMessage = page.locator("div[id*='span_status']"); + expect(await comPleteMessage.evaluate(node => node.innerText)).toContain('Your file is transcoded successfully.'); + await expect(checkStatus).toBeHidden(); // Retranscode await page.locator("td.title.column-title.has-row-actions.column-primary > strong > a").first().hover(); await page.locator("a[title='Retranscode this single media']").first().click(); // Validate with proper visiblity - const result = await page.locator("div[id='retranscodemedia-bar-percent']").innerText(); - if (result == '100%' && page.locator("div[id='retranscodemedia-bar-percent']").isEnabled()) { + const result_text = await page.locator("div[id='retranscodemedia-bar-percent']").innerText(); + if (result_text == '100%' && page.locator("div[id='retranscodemedia-bar-percent']").isEnabled()) { await page.locator("#toplevel_page_rt-transcoder > a > div.wp-menu-name").click() } }); @@ -55,5 +97,15 @@ test.describe('Validate ReTranscoded Settings', () => { await page.locator("#toplevel_page_rt-transcoder > a > div.wp-menu-name").click() } }); + test('Clear All Media after Testing', async ({admin, page }) => { + await admin.visitAdminPage("upload.php"); + //Select All Media + await page.locator("#cb-select-all-1").check(); + // Select Bulk Delete Option + await page.locator("#bulk-action-selector-top").selectOption("delete"); + // Click Apply + page.on('dialog', dialog => dialog.accept()); + await page.locator("#doaction").click(); + }); }); \ No newline at end of file