Skip to content

Commit

Permalink
Merge branch 'nahid' of github.com:nahidthenh/embedpress-playwright-a…
Browse files Browse the repository at this point in the history
…utomation
  • Loading branch information
nahidthenh committed Jan 9, 2025
2 parents 7db0ff0 + 8240915 commit fe4b26b
Show file tree
Hide file tree
Showing 18 changed files with 215 additions and 57 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: Playwright Tests
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
# pull_request:
# branches: [main, master]
schedule:
- cron: '0 0 * * *' # 6 AM GMT+6 (0 0 in UTC)
- cron: '0 2 * * *' # 8 AM GMT+6

permissions:
contents: write # Grants write access to the repository
Expand Down
41 changes: 24 additions & 17 deletions playwright.config.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
const { defineConfig, devices } = require('@playwright/test');
require('dotenv').config();

const isCI = !!process.env.CI; // Check if the CI environment variable is set

module.exports = defineConfig({
testDir: './tests',
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
forbidOnly: isCI,
retries: isCI ? 3 : 1,
workers: isCI ? 4 : 4,
reporter: [
[
'./node_modules/playwright-slack-report/dist/src/SlackReporter.js',
{
slackWebHookUrl: process.env.SLACK_WEBHOOK_URL,
sendResults: 'always',
maxNumberOfFailuresToShow: 0,
meta: [
...(isCI
? [
[
'./node_modules/playwright-slack-report/dist/src/SlackReporter.js',
{
key: ":embedpress: EmbedPress Automation - Test Results",
value: "<https://nahidthenh.github.io/embedpress-playwright-automation/ | 📂 Click Here!>",
}
]
},
],
slackWebHookUrl: process.env.SLACK_WEBHOOK_URL,
sendResults: 'always',
maxNumberOfFailuresToShow: 0,
meta: [
{
key: ":embedpress: EmbedPress Automation - Test Results",
value:
"<https://nahidthenh.github.io/embedpress-playwright-automation/ | :desktop_computer: Final Report!>",
},
],
},
],
]
: []),
['html', { outputFolder: 'playwright-report', open: 'never' }], // Ensure you have the HTML reporter as well
['dot'], // Console output reporter
],
Expand All @@ -35,6 +42,6 @@ module.exports = defineConfig({
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
}
},
],
});
1 change: 1 addition & 0 deletions tests/classic/youtube.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ let slug = 'playwright-classic-editor/classic-youtube/';
test.describe("Elementor YouTube", () => {
test.beforeEach(async ({ page }) => {
await page.goto(slug);
await page.waitForLoadState('networkidle');
});

test('Default YouTube', async ({ page }) => {
Expand Down
Empty file.
28 changes: 28 additions & 0 deletions tests/elementor/calendly.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const { test, expect } = require('@playwright/test');

let slug = 'playwright-gutenberg/elementor-calendly';


test.describe("Gutenberg Calendly", () => {
test.beforeEach(async ({ page }) => {
await page.goto(slug);
});

test('Default Gutenberg Calendly', async ({ page }) => {

let defaultLocator = page.locator('iframe[title="Select a Date \\& Time - Calendly"]')

await expect(page.locator('h2')).toBeVisible();

await expect(defaultLocator.contentFrame().getByLabel('Cookie banner')).toBeVisible();
await expect(defaultLocator.contentFrame().getByText('Md. Nahid Hasan')).toBeVisible();
await expect(defaultLocator.contentFrame().getByRole('heading', { name: 'Custom Event' })).toBeVisible();
await expect(defaultLocator.contentFrame().getByText('Web conferencing details')).toBeVisible();
await expect(defaultLocator.contentFrame().getByText('Md. Nahid HasanCustom Event1')).toBeVisible();
await expect(defaultLocator.contentFrame().getByRole('link', { name: 'powered by Calendly' })).toBeVisible();
await expect(defaultLocator.contentFrame().locator('div').filter({ hasText: /^Cookie settings$/ }).nth(1)).toBeVisible();
});

// More TestCases will added later as found error on this feature card link - https://projects.startise.com/fbs-73072

});
1 change: 1 addition & 0 deletions tests/elementor/flip_book_pdf.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ let slug = 'flip-book-pdf-elementor';
test.describe("Elementor Flip Book PDF", () => {
test.beforeEach(async ({ page }) => {
await page.goto(slug);
await page.waitForLoadState('networkidle');
});

test('To Enable All Controls', async ({ page }) => {
Expand Down
45 changes: 45 additions & 0 deletions tests/elementor/google-photos.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const { test, expect } = require('@playwright/test');

let slug = 'playwright-elementor/elementor-google-photos';


test.describe("Google Photos", () => {
test.beforeEach(async ({ page }) => {
await page.goto(slug);
await page.waitForLoadState('networkidle');
});

test('Google Photos Carousel', async ({ page }) => {
await expect(page.getByRole('heading', { name: 'Google Photos Carousel' })).toBeVisible();
await expect(page.locator('#ep-elements-id-f3716c7 iframe').contentFrame().getByTitle('Open in new window.').getByRole('img')).toBeVisible();
});

test('Pro - Google Photos Gallery Player', async ({ page }) => {
await page.getByRole('heading', { name: 'Pro - Google Photos Gallery Player', exact: true }).click();
await expect(page.locator('#ep-elements-id-dba371e iframe').contentFrame().locator('.jx-imageset').first()).toBeVisible();
await expect(page.locator('#ep-elements-id-dba371e iframe').contentFrame().locator('div:nth-child(3) > div > div:nth-child(2) > svg')).toBeVisible();
await expect(page.locator('#ep-elements-id-dba371e iframe').contentFrame().locator('div:nth-child(5) > div:nth-child(2) > div > div:nth-child(2) > svg')).toBeVisible();
await page.locator('#ep-elements-id-dba371e iframe').contentFrame().locator('div:nth-child(7) > .jx-svg-image > svg').click();
await page.locator('#ep-elements-id-dba371e iframe').contentFrame().locator('.jx-carousel-arrow > .jx-svg-image > svg').first().click();
await page.locator('#ep-elements-id-dba371e iframe').contentFrame().locator('div:nth-child(2) > svg').first().click();
});

test('Pro - Google Photos Gallery Player - Auto Play & Repeat On', async ({ page }) => {
await expect(page.getByRole('heading', { name: 'Pro - Google Photos Gallery Player - Auto Play & Repeat On' })).toBeVisible();
await expect(page.locator('#ep-elements-id-117fe6c iframe').contentFrame().locator('.jx-imageset').first()).toBeVisible();
await expect(page.locator('#ep-elements-id-117fe6c iframe').contentFrame().locator('div:nth-child(8) > .jx-svg-image > svg')).toBeVisible();
await expect(page.locator('#ep-elements-id-117fe6c iframe').contentFrame().locator('img:nth-child(2)').first()).toBeVisible();
await expect(page.locator('#ep-elements-id-117fe6c iframe').contentFrame().locator('div:nth-child(2) > .jx-imageset > div > img:nth-child(2)')).toBeVisible();
await expect(page.locator('#ep-elements-id-117fe6c iframe').contentFrame().locator('div:nth-child(3) > .jx-imageset > div > img:nth-child(2)')).toBeVisible();
await expect(page.locator('#ep-elements-id-117fe6c iframe').contentFrame().locator('div:nth-child(4) > .jx-imageset > div > img:nth-child(2)')).toBeVisible();
await expect(page.locator('#ep-elements-id-117fe6c iframe').contentFrame().locator('img:nth-child(2)').first()).toBeVisible();
});

test('Single Photo - With Color', async ({ page }) => {
await expect(page.getByRole('heading', {
name: 'Single Photo - With Color'
})).toBeVisible();
await expect(page.locator('#ep-elements-id-f0593d4 iframe').contentFrame().locator('.jx-imageset')).toBeVisible();
await expect(page.locator('#ep-elements-id-f0593d4 iframe').contentFrame().getByRole('link', { name: 'New item by Md. Nahid Hasan' })).toBeVisible();
});
});
1 change: 1 addition & 0 deletions tests/elementor/modern_pdf.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ let slug = 'modern-pdf-elementor';
test.describe("Elementor Modern PDF", () => {
test.beforeEach(async ({ page }) => {
await page.goto(slug);
await page.waitForLoadState('networkidle');
});

test('To Enable All Controls', async ({ page }) => {
Expand Down
3 changes: 1 addition & 2 deletions tests/elementor/spotify.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ let slug = 'playwright-elementor/elementor-spotify';
test.describe('Elementor Spotify', () => {
test.beforeEach(async ({ page }) => {
await page.goto(slug);
await page.waitForLoadState('networkidle');
});

test('Spotify Single', async ({ page }) => {
Expand Down Expand Up @@ -72,7 +73,5 @@ test.describe('Elementor Spotify', () => {
await expect(iframe.getByTestId('tracklist-row-0')).toBeVisible();
await expect(iframe.getByTestId('tracklist-row-1')).toBeVisible();
await iframe.getByTestId('play-pause-button').click();
await page.waitForTimeout(3000);
await iframe.getByTestId('play-pause-button').click();
});
});
30 changes: 17 additions & 13 deletions tests/elementor/spreaker.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ let slug = 'elementor-spreaker';
test.describe("Elementor Spreaker", () => {
test.beforeEach(async ({ page }) => {
await page.goto(slug);
await page.waitForLoadState('networkidle');
await expect(page.getByRole('heading', { name: 'Elementor Spreaker' })).toBeVisible();
});

// Spreaker Playlist
test('Spreaker Playlist', async ({ page }) => {
test('Spreaker Playlist - Elementor', async ({ page }) => {
// Assert the main heading is visible
const heading = page.getByRole('heading', { name: 'Spreaker Playlist' });
await expect(heading).toBeVisible();
Expand All @@ -23,11 +25,10 @@ test.describe("Elementor Spreaker", () => {

// Define locators for elements within the iframe
const elementsToCheck = [
// { locator: frame.getByRole('link', { name: 'The Deadliest Mountain on' }), description: 'Episode link' },
{ locator: frame.getByLabel('Listen on Spreaker'), description: 'Listen on Spreaker button' },
{ locator: frame.getByRole('link', { name: 'Privacy Policy' }), description: 'Privacy Policy link' },
{ locator: frame.getByRole('img', { name: 'The Deadliest Mountain on' }).first(), description: 'Episode image' },
{ locator: frame.getByLabel('Play episode The Deadliest').first(), description: 'Play button' },
{ locator: frame.locator('li').filter({ hasText: 'The Deadliest Mountain on' }).getByLabel('Play episode The Deadliest Mountain on Earth'), description: 'Specific Play button' },
{ locator: frame.getByLabel('Skip back 10 seconds'), description: 'Skip back button' },
{ locator: frame.getByLabel('Skip forward 30 seconds'), description: 'Skip forward button' },
{ locator: frame.getByLabel('Like episode'), description: 'Like button' },
Expand All @@ -36,33 +37,36 @@ test.describe("Elementor Spreaker", () => {
{ locator: frame.getByLabel('player.download_episode'), description: 'Download button' },
{ locator: frame.locator('.button_info').first(), description: 'Info button' },
{ locator: frame.getByText('The Deadliest Mountain on Earthepisode_explicit16:'), description: 'Episode text' },
{ locator: frame.getByRole('list').getByLabel('Play episode The Deadliest'), description: 'Play episode list item' },
{ locator: frame.getByRole('list').getByRole('img', { name: 'The Deadliest Mountain on' }), description: 'Episode list image' },
{ locator: frame.locator('li').filter({ hasText: 'The Deadliest Mountain on' }).locator('span'), description: 'Episode span' },
{ locator: frame.locator('li').filter({ hasText: 'The Deadliest Mountain on' }).getByLabel('Read description'), description: 'Read description button' },
];

// Check visibility of all elements in the iframe
for (const { locator, description } of elementsToCheck) {
await expect(locator).toBeVisible({ message: `${description} should be visible` });
}

// Interact with play and pause buttons
const playButton = frame.getByLabel('Play episode The Deadliest').first();
const pauseButton = frame.getByLabel('Pause episode The Deadliest').first();
// Interact with specific play and pause buttons
const specificPlayButton = frame
.locator('li')
.filter({ hasText: 'The Deadliest Mountain on Earth' })
.getByLabel('Play episode The Deadliest Mountain on Earth');

const specificPauseButton = frame
.locator('li')
.filter({ hasText: 'The Deadliest Mountain on Earth' })
.getByLabel('Pause episode The Deadliest Mountain on Earth');

await playButton.click();
await specificPlayButton.click();
await page.waitForTimeout(500); // Small delay to simulate playback
await pauseButton.click();
await specificPauseButton.click();

// Assert CSS property of an element within the frame
const cssElement = frame.locator('.widget.theme_light.theme_with_playlist');

// Assert that the element has the expected class
await expect(cssElement).toHaveClass(/widget theme_light theme_with_playlist/);

});


// Enable Pro Features
test('Enable Pro Features', async ({ page }) => {
// Check the main heading visibility
Expand Down
1 change: 1 addition & 0 deletions tests/elementor/youtube.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ let slug = 'elementor-youtube-2';
test.describe("Elementor YouTube", () => {
test.beforeEach(async ({ page }) => {
await page.goto(slug);
await page.waitForLoadState('networkidle');
});

test('YouTube Chanel Gallery', async ({ page }) => {
Expand Down
28 changes: 28 additions & 0 deletions tests/gutenberg/calendly.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const { test, expect } = require('@playwright/test');

let slug = 'playwright-gutenberg/gutenberg-calendly';


test.describe("Gutenberg Calendly", () => {
test.beforeEach(async ({ page }) => {
await page.goto(slug);
});

test('Default Gutenberg Calendly', async ({ page }) => {

let defaultLocator = page.locator('iframe[title="Select a Date \\& Time - Calendly"]')

await expect(page.locator('h2')).toBeVisible();

await expect(defaultLocator.contentFrame().getByLabel('Cookie banner')).toBeVisible();
await expect(defaultLocator.contentFrame().getByText('Md. Nahid Hasan')).toBeVisible();
await expect(defaultLocator.contentFrame().getByRole('heading', { name: 'Custom Event' })).toBeVisible();
await expect(defaultLocator.contentFrame().getByText('Web conferencing details')).toBeVisible();
await expect(defaultLocator.contentFrame().getByText('Md. Nahid HasanCustom Event1')).toBeVisible();
await expect(defaultLocator.contentFrame().getByRole('link', { name: 'powered by Calendly' })).toBeVisible();
await expect(defaultLocator.contentFrame().locator('div').filter({ hasText: /^Cookie settings$/ }).nth(1)).toBeVisible();
});

// More TestCases will added later as found error on this feature card link - https://projects.startise.com/fbs-73072

});
1 change: 1 addition & 0 deletions tests/gutenberg/flip_book_pdf.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ let slug = 'flip-book-pdf';
test.describe("Gutenberg Flip Book PDF", () => {
test.beforeEach(async ({ page }) => {
await page.goto(slug);
await page.waitForLoadState('networkidle');
await expect(page.getByRole('heading', { name: 'Flip Book Pdf' })).toBeVisible();
});

Expand Down
49 changes: 49 additions & 0 deletions tests/gutenberg/google-photos.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const { test, expect } = require('@playwright/test');

let slug = 'playwright-elementor/gutenberg-google-photos';


test.describe("Google Photos", () => {
test.beforeEach(async ({ page }) => {
await page.goto(slug);
await page.waitForLoadState('networkidle');
});

test('Google Photos Carousel', async ({ page }) => {
await expect(page.getByText('Google Photos Carousel')).toBeVisible();
await expect(page.locator('iframe').first().contentFrame().locator('.jx-imageset').first()).toBeVisible();
});

test('Pro - Google Photos Gallery Player', async ({ page }) => {
await expect(page.getByRole('heading', { name: 'Pro – Google Photos Gallery Player', exact: true })).toBeVisible();
await expect(page.locator('iframe').nth(1).contentFrame().locator('.jx-imageset').first()).toBeVisible();
await expect(page.locator('iframe').nth(1).contentFrame().locator('div:nth-child(8) > .jx-svg-image > svg')).toBeVisible();
await page.locator('iframe').nth(1).contentFrame().locator('div:nth-child(7) > .jx-svg-image > svg').click();
await expect(page.locator('iframe').nth(1).contentFrame().locator('div:nth-child(2) > .jx-imageset > div > img:nth-child(2)')).toBeVisible();
await expect(page.locator('iframe').nth(1).contentFrame().locator('div:nth-child(7)')).toBeVisible();
await expect(page.locator('iframe').nth(1).contentFrame().locator('.jx-carousel-arrow > .jx-svg-image > svg').first()).toBeVisible();
await page.locator('iframe').nth(1).contentFrame().locator('.jx-carousel-arrow > .jx-svg-image > svg').first().click();
await expect(page.locator('iframe').nth(1).contentFrame().locator('.jx-imageset').first()).toBeVisible();
});

test('Pro - Google Photos Gallery Player - Auto Play & Repeat On', async ({ page }) => {
await expect(page.getByRole('heading', { name: 'Pro – Google Photos Gallery Player – Auto Play & Repeat On' })).toBeVisible();
await expect(page.locator('iframe').nth(2).contentFrame().locator('div:nth-child(4) > .jx-imageset')).toBeVisible();
await expect(page.locator('iframe').nth(2).contentFrame().locator('div:nth-child(2) > .jx-imageset > div > img:nth-child(2)')).toBeVisible();
await expect(page.locator('iframe').nth(2).contentFrame().locator('div:nth-child(3) > .jx-imageset > div > img:nth-child(2)')).toBeVisible();
await expect(page.locator('iframe').nth(2).contentFrame().locator('div:nth-child(4) > .jx-imageset > div > img:nth-child(2)')).toBeVisible();
await expect(page.locator('iframe').nth(2).contentFrame().locator('img:nth-child(2)').first()).toBeVisible();
await expect(page.locator('iframe').nth(2).contentFrame().locator('div:nth-child(8) > .jx-svg-image > svg')).toBeVisible();
});

test('Single Photo - With Color', async ({ page }) => {
await expect(page.getByRole('heading', { name: 'Single Photo – With Color' })).toBeVisible();
await page.locator('iframe').nth(3).contentFrame().getByRole('img').nth(1).click();
await expect(page.locator('iframe').nth(3).contentFrame().getByRole('link', { name: 'New item by Md. Nahid Hasan' })).toBeVisible();
await page.locator('iframe').nth(3).contentFrame().locator('div:nth-child(7)').click();
});



});

1 change: 1 addition & 0 deletions tests/gutenberg/modern_pdf.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ let heading = 'Gutenberg Modern pdf';
test.describe("Gutenberg Modern PDF", () => {
test.beforeEach(async ({ page }) => {
await page.goto(slug);
await page.waitForLoadState('networkidle');
await expect.soft(page.getByRole('heading', { name: heading, exact: true })).toBeVisible();
});

Expand Down
5 changes: 3 additions & 2 deletions tests/gutenberg/spotify.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ let slug = 'playwright-gutenberg/gutenberg-spotify';
test.describe("Gutenberg Spotify", () => {
test.beforeEach(async ({ page }) => {
await page.goto(slug);
await page.waitForLoadState('networkidle');
});

test('Spotify Single', async ({ page }) => {
Expand Down Expand Up @@ -77,9 +78,9 @@ test.describe("Gutenberg Spotify", () => {
await expect(framelocator.getByTestId('play-pause-button')).toBeVisible();
await framelocator.getByTestId('play-pause-button').click();

await page.waitForTimeout(500);
// await page.waitForTimeout(500);

await framelocator.getByTestId('play-pause-button').click();
// await framelocator.getByTestId('play-pause-button').click();
});

});
Loading

0 comments on commit fe4b26b

Please sign in to comment.