Skip to content

Commit

Permalink
Add Store appreance tests (#2478)
Browse files Browse the repository at this point in the history
* Add appearance settings tests

* Update create store payloads

* Add new store appearance tests

* Add new store appearance tests

* Add condition on vendor add

* Fix pr reviews

* Update selectors

* Update db reset methods

* Update payloads

* Update vendor create methods

* Fix flaky tests

* Fix widget issue

* Fix lint issues

* Fix failed tests

* Skipped couple tests
  • Loading branch information
shashwatahalder01 authored Dec 12, 2024
1 parent a0d9e64 commit 98d3958
Show file tree
Hide file tree
Showing 25 changed files with 830 additions and 477 deletions.
1 change: 1 addition & 0 deletions .github/workflows/e2e_api_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ env:
CUSTOMER2: customer2
USER_PASSWORD: 01dokan01
GMAP: ${{secrets.GMAP}}
MAPBOX: ${{secrets.MAPBOX}}
BASE_URL: http://localhost:9999
CI: true
FORCE_COLOR: 1
Expand Down
39 changes: 21 additions & 18 deletions tests/pw/.env.example
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
# Plugin Configuration
ADMIN=John_Doe [Admin username]
ADMIN_PASSWORD=AdminPass123 [Password for the admin account]
VENDOR=David_Johnson [Vendor username]
VENDOR2=jhonathon_Smith [Vendor username]
CUSTOMER=Michael_Williams [Customer username]
USER_PASSWORD=Passw0rd123 [Password for all other users]
DOKAN_PRO=true [Dokan pro active status]
LICENSE_KEY=licence_key [Dokan License key]
GMAP=map_key [Google Maps API key]
TALKJS_APP_ID=talkjs_app_id [TalkJS App ID]
TALKJS_APP_SECRET=talkjs_app_secret [TalkJS App Secret]
VONAGE_API_KEY=vonage_key [Vonage SMS API key]
VONAGE_API_SECRET=vonage_secret [Vonage SMS API secret]
FB_APP_ID=facebook_app_id [Facebook App ID]
FB_APP_SECRET=facebook_app_secret [Facebook App secret]
PRINTFUL_APP_ID=printful_app_id [Printful App ID]
PRINTFUL_APP_SECRET=printful_app_secret [Printful App secret]
# Plugin Configuration
ADMIN=John_Doe [Admin username]
ADMIN_PASSWORD=AdminPass123 [Password for the admin account]
VENDOR=David_Johnson [Vendor username]
VENDOR2=jhonathon_Smith [Vendor username]
CUSTOMER=Michael_Williams [Customer username]
USER_PASSWORD=Passw0rd123 [Password for all other users]
DOKAN_PRO=true [Dokan pro active status]
LICENSE_KEY=license_key [Dokan License key]
GMAP=map_key [Google Maps API key]
MAPBOX=mapbox_key [Mapbox Maps API key]
TALKJS_APP_ID=talkjs_app_id [TalkJS App ID]
TALKJS_APP_SECRET=talkjs_app_secret [TalkJS App Secret]
VONAGE_API_KEY=vonage_key [Vonage SMS API key]
VONAGE_API_SECRET=vonage_secret [Vonage SMS API secret]
FB_APP_ID=facebook_app_id [Facebook App ID]
FB_APP_SECRET=facebook_app_secret [Facebook App secret]
PRINTFUL_APP_ID=printful_app_id [Printful App ID]
PRINTFUL_APP_SECRET=printful_app_secret [Printful App secret]
RECAPTCHA_SITE_KEY=recaptcha_site_key [reCAPTCHA site key]
RECAPTCHA_SECRET_KEY=recaptcha_secret_key [reCAPTCHA secret key]

# Playwright Configuration
BASE_URL=https://example.com [Base URL of the test site]
Expand Down
71 changes: 37 additions & 34 deletions tests/pw/README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,32 @@

## :bookmark: Table of contents

- [Pre-requisites :pushpin:](#pre-requisites)
- [Install Node](#install-node)
- [Install NVM](#install-nvm)
- [Install Docker](#install-docker)
- [Pre-requisites :pushpin:](#pre-requisites)
- [Install Node](#install-node)
- [Install NVM](#install-nvm)
- [Install Docker](#install-docker)

<br/>

- [Prep for tests :construction:](#prep-for-tests)
- [Build Dokan plugin](#build-dokan-plugin)
- [Install Dependencies](#install-dependencies)
- [Start Wordpress Environment](#start-wordpress-environment)
- [Create Env file](#create-env-file)
- [Prep for tests :construction:](#prep-for-tests)
- [Build Dokan plugin](#build-dokan-plugin)
- [Install Dependencies](#install-dependencies)
- [Start Wordpress Environment](#start-wordpress-environment)
- [Create Env file](#create-env-file)

<br/>

- [Running tests :test_tube: ](#running-tests)
- [How to run test projects](#how-to-run-test-projects)
- [How to run tests](#how-to-run-tests)
- [How to skip tests](#how-to-skip-tests)
- [How to debug tests](#how-to-debug-tests)
- [How to serve reports](#how-to-serve-reports)
- [Running tests :test_tube: ](#running-tests)
- [How to run test projects](#how-to-run-test-projects)
- [How to run tests](#how-to-run-tests)
- [How to skip tests](#how-to-skip-tests)
- [How to debug tests](#how-to-debug-tests)
- [How to serve reports](#how-to-serve-reports)

<br/>

- [Contributing to Dokan-e2e-api-test](#Contributing-to-dokan-e2e-api-test)
- [How to wright tests](#how-to-run-tests)
- [Contributing to Dokan-e2e-api-test](#Contributing-to-dokan-e2e-api-test)
- [How to wright tests](#how-to-run-tests)

<br/>

Expand Down Expand Up @@ -121,23 +121,26 @@ Create .env file according to .env.example file

```
# Plugin Configuration
ADMIN=John_Doe [Admin username]
ADMIN_PASSWORD=AdminPass123 [Password for the admin account]
VENDOR=David_Johnson [Vendor username]
VENDOR2=Johnathon_Smith [Vendor username]
CUSTOMER=Michael_Williams [Customer username]
USER_PASSWORD=Passw0rd123 [Password for all other users]
DOKAN_PRO=true [Dokan pro active status]
LICENSE_KEY=licence_key [Dokan License key]
GMAP=map_key [Google Maps API key]
TALKJS_APP_ID=talkjs_app_id [TalkJS App ID]
TALKJS_APP_SECRET=talkjs_app_secret [TalkJS App Secret]
VONAGE_API_KEY=vonage_key [Vonage SMS API key]
VONAGE_API_SECRET=vonage_secret [Vonage SMS API secret]
FB_APP_ID=facebook_app_id [Facebook App ID]
FB_APP_SECRET=facebook_app_secret [Facebook App secret]
PRINTFUL_APP_ID=printful_app_id [Printful App ID]
PRINTFUL_APP_SECRET=printful_app_secret [Printful App secret]
ADMIN=John_Doe [Admin username]
ADMIN_PASSWORD=AdminPass123 [Password for the admin account]
VENDOR=David_Johnson [Vendor username]
VENDOR2=Johnathon_Smith [Vendor username]
CUSTOMER=Michael_Williams [Customer username]
USER_PASSWORD=Passw0rd123 [Password for all other users]
DOKAN_PRO=true [Dokan pro active status]
LICENSE_KEY=license_key [Dokan License key]
GMAP=map_key [Google Maps API key]
MAPBOX=mapbox_key [Mapbox Maps API key]
TALKJS_APP_ID=talkjs_app_id [TalkJS App ID]
TALKJS_APP_SECRET=talkjs_app_secret [TalkJS App Secret]
VONAGE_API_KEY=vonage_key [Vonage SMS API key]
VONAGE_API_SECRET=vonage_secret [Vonage SMS API secret]
FB_APP_ID=facebook_app_id [Facebook App ID]
FB_APP_SECRET=facebook_app_secret [Facebook App secret]
PRINTFUL_APP_ID=printful_app_id [Printful App ID]
PRINTFUL_APP_SECRET=printful_app_secret [Printful App secret]
RECAPTCHA_SITE_KEY=recaptcha_site_key [reCAPTCHA site key]
RECAPTCHA_SECRET_KEY=recaptcha_secret_key [reCAPTCHA secret key]
# Playwright Configuration
BASE_URL=https://example.com [Base URL of the test site]
Expand Down
4 changes: 2 additions & 2 deletions tests/pw/e2e.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ export default defineConfig({
/* The maximum number of test failures for the whole test suite run. After reaching this number, testing will stop and exit with an error. */
maxFailures: CI ? 50 : 50,
/* Maximum time one test can run for. */
timeout: CI ? 35 * 1000 : 40 * 1000,
timeout: CI ? 35 * 1000 : 45 * 1000,
/* Configuration for the expect assertion library */
expect: {
/* Maximum time expect() should wait for the condition to be met. For example in `await expect(locator).toHaveText();`*/
timeout: 10 * 1000,
timeout: 15 * 1000,
toHaveScreenshot: {
maxDiffPixelRatio: 0.2,
maxDiffPixels: 500,
Expand Down
27 changes: 22 additions & 5 deletions tests/pw/feature-map/feature-map.yml
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,27 @@

- page: 'Store Appearance'
features:
customer:
store map is disabled on store sidebar [lite]: true
store open-close time is disabled store sidebar [lite]: true
vendor info is disabled on single store page [lite]: false
admin:
admin can enable store map on store sidebar [lite]: true
admin can disable store map on store sidebar [lite]: true
admin can set map api source (Google Maps) [lite]: true
admin can set map api source (Mapbox) [lite]: true
admin can enable Google reCAPTCHA validation [lite]: true
admin can disable Google reCAPTCHA validation [lite]: true
admin can enable store contact form on store sidebar [lite]: true
admin can disable store contact form on store sidebar [lite]: true
admin can set store header template (default) [lite]: true
admin can set store header template (layout1) [lite]: true
admin can set store header template (layout2) [lite]: true
admin can set store header template (layout3) [lite]: true
admin can enable store open-close time on store sidebar [lite]: true
admin can disable store open-close time on store sidebar [lite]: true
admin can enable store sidebar from theme [lite]: true
admin can disable store sidebar from theme [lite]: true
admin can enable vendor info on single store page [lite]: true
admin can disable vendor info on single store page [lite]: true
admin can enable Dokan FontAwesome library [lite]: true
admin can disable Dokan FontAwesome library [lite]: true

- page: 'Store List'
features:
Expand Down Expand Up @@ -660,7 +677,7 @@
admin can refresh license: true
admin can deactivate license: true

- page: 'Feature lock'
- page: 'Feature Lock'
features:
admin:
admin can view license expiration notice: false
Expand Down
6 changes: 3 additions & 3 deletions tests/pw/fixtures/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import { ShortcodePage } from '@pages/shortcodePage';
import { SingleProductPage } from '@pages/singleProductPage';
import { SingleStorePage } from '@pages/singleStorePage';
import { SpmvPage } from '@pages/spmvPage';
import { StoreAppearance } from '@pages/storeAppearance';
import { StoreAppearancePage } from '@pages/storeAppearancePage';
import { StoreCategoriesPage } from '@pages/storeCategoriesPage';
import { StoreListingPage } from '@pages/storeListingPage';
import { StoreReviewsPage } from '@pages/storeReviewsPage';
Expand Down Expand Up @@ -111,7 +111,7 @@ type pages = {
singleProductPage: SingleProductPage;
singleStorePage: SingleStorePage;
spmvPage: SpmvPage;
storeAppearance: StoreAppearance;
storeAppearance: StoreAppearancePage;
storeCategoriesPage: StoreCategoriesPage;
storeListingPage: StoreListingPage;
storeReviewsPage: StoreReviewsPage;
Expand Down Expand Up @@ -308,7 +308,7 @@ export const test = base.extend<pages>({
},

storeAppearance: async ({ page }, use) => {
await use(new StoreAppearance(page));
await use(new StoreAppearancePage(page));
},

storeCategoriesPage: async ({ page }, use) => {
Expand Down
12 changes: 12 additions & 0 deletions tests/pw/pages/basePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1487,6 +1487,12 @@ export class BasePage {
return visibleSelectors;
}

// assert element to exists
async toExists(selector: string) {
const exists = await this.isLocatorExists(selector);
expect(exists).toBe(true);
}

// assert value to be equal
toBeEqual(received: any, expected: any) {
expect(received).toEqual(expected);
Expand Down Expand Up @@ -1604,6 +1610,12 @@ export class BasePage {
.toBe(200);
}

// assert element not to exists
async notToExists(selector: string) {
const exists = await this.isLocatorExists(selector);
expect(exists).toBe(false);
}

// assert two element to have same count
async toHaveEqualCount(selector1: string, selector2: string, options?: { timeout?: number; intervals?: number[] }) {
await this.toPass(async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/pw/pages/privacyPolicyPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class PrivacyPolicyPage extends CustomerPage {
// contact vendor
async contactVendor(storeName: string, storeContactData: storeContactData) {
await this.toPass(async () => {
await this.gotoUntilNetworkidle(data.subUrls.frontend.vendorDetails(helpers.slugify(storeName)));
await this.gotoUntilNetworkidle(data.subUrls.frontend.vendorDetails(helpers.slugify(storeName)), { waitUntil: 'networkidle' }, true);
await this.toBeVisible(singleStoreCustomer.storeContactForm.storeContactForm);
});
await this.clearAndType(singleStoreCustomer.storeContactForm.name, storeContactData.name);
Expand Down
50 changes: 32 additions & 18 deletions tests/pw/pages/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1447,10 +1447,10 @@ export const selector = {
popup: {
dokanUpgradePopup: '#dokan-upgrade-popup',
closeDokanUpgradePopup: '#dokan-upgrade-popup .close',
upgradeToProText: '.upgrade-text',
upgradeToPro: '.upgrade-button',
proCard: '.promo-card',
alreadyUpdated: '.already-updated',
upgradeToProText: 'div.modal-content p.upgrade-text',
upgradeToPro: 'div.modal-content a.upgrade-button',
proCard: 'div.modal-content div.promo-card',
alreadyUpdated: 'div.modal-content a.already-updated',
},

// modules
Expand Down Expand Up @@ -6087,6 +6087,7 @@ export const selector = {

// banner and profile picture
banner: '.dokan-banner .dokan-banner-drag',
bannerHelpText: 'div.dokan-banner p.help-block',
bannerImage: '//div[@class="image-wrap"]//img[@class="dokan-banner-img"]',
uploadedBanner: 'div#dokan-profile-picture-wrapper div.gravatar-wrap',
removeBannerImage: '.close.dokan-remove-banner-image',
Expand Down Expand Up @@ -7440,32 +7441,33 @@ export const selector = {

// Store Profile Summary
storeProfile: {
storeProfileInfoBox: 'div.profile-info-box',
storeProfileSummary: '.dokan-single-store .profile-info-summery',

storeBanner: '.profile-info-img',
storeBanner: 'div.profile-info-img',

profileInfoHead: '.profile-info-head',
profileImage: '.profile-img.profile-img-circle',
storeName: '.profile-info-head .store-name',
profileInfoHead: 'div.profile-info-head',
profileImage: 'div.profile-img.profile-img-circle',
storeName: 'div.profile-info-head h1.store-name',
verifiedIcon: '//div[@data-original-title="Verified"]',
verifiedIconByIcon: (icon: string) => `//div[@data-original-title="Verified"]//i[@class="${icon}"]`,

profileInfo: '.profile-info',
storeInfo: '.dokan-store-info',
storeAddress: '.dokan-store-address',
storePhone: '.dokan-store-phone',
storeEmail: '.dokan-store-email',
// storeRating: '.dokan-store-rating',
// storeOpenClose: '.dokan-store-open-close',
storeSocial: '.store-social',

profileInfo: 'div.profile-info',
storeInfo: 'ul.dokan-store-info',
storeAddress: 'li.dokan-store-address',
storePhone: 'li.dokan-store-phone',
storeEmail: 'li.dokan-store-email',
// storeRating: 'li.dokan-store-rating',
// storeOpenClose: 'li.dokan-store-open-close',
euComplianceData: {
companyName: 'li.dokan-company-name',
companyId: 'li.dokan-company-id-number',
vatNumber: 'li.dokan-vat-number',
bankName: 'li.dokan-bank-name',
bankIban: 'li.dokan-bank-iban',
},

storeSocial: 'ul.store-social',
},

// Store open close time
Expand Down Expand Up @@ -7588,6 +7590,8 @@ export const selector = {
coupon: (code: string) => `//span[@class="coupon-code"]//strong[normalize-space()="${code}"]`,
},

dokanStoreSideBar: 'div.dokan-store-sidebar div.dokan-widget-area',

storeContactForm: {
storeContactForm: 'form#dokan-form-contact-seller',
name: 'form#dokan-form-contact-seller input[placeholder="Your Name"]',
Expand All @@ -7598,8 +7602,18 @@ export const selector = {
privacyPolicy: 'div.dokan-privacy-policy-text p',
privacyPolicyLink: 'a.dokan-privacy-policy-link',
},
storeMap: 'div#dokan-store-location',

storeMap: {
storeMap: 'div#dokan-store-location',
googleMap: '//div[@id="dokan-store-location"]//a[contains(@href,"https://maps.google.com/")]',
mapbox: '//div[@id="dokan-store-location"]//a[@href="https://www.mapbox.com/"]',
},

storeOpenCloseTime: 'div.dokan-store-open-close',

googleRecaptcha: '//iframe[@title="reCAPTCHA"]',

dokanFontAwesomeLibrary: 'link#dokan-fontawesome-css',
},

cMyOrders: {
Expand Down
29 changes: 0 additions & 29 deletions tests/pw/pages/storeAppearance.ts

This file was deleted.

Loading

0 comments on commit 98d3958

Please sign in to comment.