Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E2E: update tests #1217

Closed
16 of 76 tasks
alexkuc opened this issue Jul 5, 2023 · 34 comments
Closed
16 of 76 tasks

E2E: update tests #1217

alexkuc opened this issue Jul 5, 2023 · 34 comments
Assignees
Labels
C: tests 🧪 category D: Packages 📦 domain: Barista Packages P3: med priority 😐 priority: medium S1: new 👶🏻 status T: chore 🧹 type: REPO - maintenance

Comments

@alexkuc
Copy link
Contributor

alexkuc commented Jul 5, 2023

Need to update E2E tests to make them compatible with Playwright runner

Primary TODOs

Events Page - events-page.spec.ts

Categories - #1229

  • admin/event/categories/editCategory.test.ts
  • admin/event/categories/categoryShortcode.test.ts
  • admin/event/categories/createCategory.test.ts

Default Settings - #1230

  • admin/event/default/settings/defaultMaximumTickets.test.ts
  • admin/event/default/settings/defaultRegistrationStatus.test.ts

Links - #1236

  • admin/event/events-list/linkForDraft.test.ts
  • admin/event/events-list/linkForToday.test.ts
  • admin/event/events-list/linkForViewAllEvents.test.ts
  • admin/event/events-list/linkForThisMonth.test.ts
  • admin/event/events-list/linkForTrash.test.ts

Single Event - single-event.spec.ts - #1238

  • shared/pagination.test.ts
  • shared/search.test.ts
  • shared/date-capacity-vs-ticket-qty.test.ts
  • shared/views/switch-view.test.ts
  • shared/views/card-view-date-range.test.ts
  • shared/copy-entity.test.ts

Registration - registration.spec.ts

  • shared/two-dates-two-tickets.test.ts
  • public/single-page-checkout/registration-scenarios/sold-out.test.ts
  • public/single-page-checkout/registration-scenarios/index.test.ts

Add-ons - rem.spec.ts, wpUser.spec.ts

  • add-ons/rem/index.test.ts
  • add-ons/wpUser/index.test.ts

To Be Sorted ⚠️

  • admin/event/events-list/bulkActions.test.ts
  • admin/event/events-list/pagination.test.ts
  • admin/event/events-list/search.test.ts
  • admin/event/events-list/filters.test.ts
  • admin/events/templates/archives/displayStatusBanner.test.ts
  • admin/events/templates/archives/displayTicketSelector.test.ts
  • admin/events/templates/archives/displayDescription.test.ts
  • admin/events/templates/archives/resetEventListSettings.test.ts
  • admin/events/templates/archives/displayVenueDetails.test.ts
  • admin/events/templates/archives/displayDatetimes.test.ts
  • admin/events/templates/archives/eventListingUrl.test.ts
  • admin/events/templates/archives/useCustomDisplayOrder.test.ts
  • admin/events/templates/archives/eventSlug.test.ts
  • admin/events/templates/archives/displayExpiredEvents.test.ts
  • admin/events/templates/ticket-selector/showTicketDetails.test.ts
  • admin/events/templates/ticket-selector/dateAndTimeFilterMaxChecked.test.ts
  • admin/events/templates/ticket-selector/showExpiredTickets.test.ts
  • admin/events/templates/ticket-selector/moreTicketSelectorOneMaxAttendees.test.ts
  • admin/events/templates/ticket-selector/showTicketSaleInfo.test.ts
  • admin/events/templates/ticket-selector/showDateAndTimeFilter.test.ts
  • admin/events/templates/ticket-selector/moreTicketSelectorTenMaxAttendees.test.ts
  • admin/events/templates/ticket-selector/freeTicketSelectorOneMaxAttendees.test.ts
  • admin/events/templates/ticket-selector/dateAndTimeFilterThreshold.test.ts
  • admin/events/templates/single/displayStatusBanner.test.ts
  • admin/events/templates/single/displayVenueDetails.test.ts
  • admin/events/templates/single/useCustomDisplayOrder.test.ts
  • admin/events/dates-list/filters/sortby.test.ts
  • admin/events/dates-list/filters/status.test.ts
  • admin/events/dates-list/filters/sales.test.ts
  • admin/events/dates-list/card.test.ts
  • admin/events/dates-list/index.test.ts
  • admin/events/dates-list/edit.test.ts
  • admin/events/dates-list/delete.test.ts
  • admin/events/editor/tickets-list/price-precision.test.ts
  • admin/events/editor/tickets-list/filters/sortby.test.ts
  • admin/events/editor/tickets-list/filters/status.test.ts
  • admin/events/editor/tickets-list/filters/sales.test.ts
  • admin/events/editor/tickets-list/card.test.ts
  • admin/events/editor/tickets-list/price-inline-vs-tpc.test.ts
  • admin/events/editor/tickets-list/index.test.ts
  • admin/events/editor/tickets-list/edit.test.ts
  • admin/events/editor/tickets-list/delete.test.ts
  • admin/events/editor/tickets-list/price.test.ts
  • admin/events/editor/ticket/price-calculator/index.test.ts
  • admin/events/editor/ticket/assignments-manager/toggle-assignments.test.ts
  • admin/events/editor/ticket/assignments-manager/index.test.ts
  • admin/events/editor/ticket/assignments-manager/filters.test.ts
  • admin/events/editor/ticket/assignments-manager/related-count-vs-assignments.test.ts
  • admin/events/editor/ticket/assignments-manager/single-vs-global-tam.test.ts

Configuration

show only PHP errors but suppress warnings (moved to #1234)

Secondary TODOs (optional)

@alexkuc alexkuc added D: Packages 📦 domain: Barista Packages P3: med priority 😐 priority: medium C: tests 🧪 category S1: new 👶🏻 status labels Jul 5, 2023
@alexkuc alexkuc self-assigned this Jul 5, 2023
@alexkuc
Copy link
Contributor Author

alexkuc commented Jul 5, 2023

Consider removal of packages mentioned in #1213

This was referenced Jul 6, 2023
@alexkuc
Copy link
Contributor Author

alexkuc commented Jul 7, 2023

Consider moving dependencies from root workspace to @eventespress/e2e

@alexkuc
Copy link
Contributor Author

alexkuc commented Jul 7, 2023

Until #1223 is merged, created this branch from commit 2069bb624412823030bac3a691cc181dec61b2a0

Edit: no need for rebase, PR #1223 was merged and didn't commit anything yet

@alexkuc
Copy link
Contributor Author

alexkuc commented Jul 7, 2023

To implement flexible support for values like HOST or PORT, consider use of ts-node to use TypeScript for make-config (instead of plain JS to leverage intellisense) and this issue on how to get it working

@alexkuc
Copy link
Contributor Author

alexkuc commented Jul 7, 2023

Once tests are converted, remove deprecated scripts from package.json

@alexkuc
Copy link
Contributor Author

alexkuc commented Jul 7, 2023

Bootstrap code from legacy E2E tests that runs before every suite from setup-playwright.ts

// Before every test suite run, delete all content created by the test. This ensures
// other posts/comments/etc. aren't dirtying tests and tests don't depend on
// each other's side-effects.
beforeAll(async () => {
	await loginUser(); // log in into /wp-admin/wp-login.php to obtain auth cookies

        // IS_WP_MULTISITE_NETWORK === true => run E2E against http://e2etests.makeeventsnotwar.com
        // IS_WP_MULTISITE_NETWORK === false => run E2E against docker (@wordpress/env)
	if(!IS_WP_MULTISITE_NETWORK){
		await activatePlugin('event-espresso-core/espresso.php'); // go to /wp-admin/plugins.php and activate plugin
		await activatePlugin('barista/ee-barista.php');  // go to /wp-admin/plugins.php and activate plugin	
	}
	
	await Goto.eventsListPage(); // go to /wp-admin/admin.php?page=espresso_events
	await defaultSettingsManager.gotoDefaultSettings(); // go to tab "Default Settings" in EE's admin page
        // choose setting for "Activate Advanced Editor"
        // 1 => Advanced Editor
        // 0 => Legacy Editor
	await defaultSettingsManager.selectDefaultEditor('1');
});

afterAll(async () => {
        // IS_WP_MULTISITE_NETWORK === true => run E2E against http://e2etests.makeeventsnotwar.com
        // IS_WP_MULTISITE_NETWORK === false => run E2E against docker (@wordpress/env)
	if(!IS_WP_MULTISITE_NETWORK){
		await deactivatePlugin('barista/ee-barista.php');  // go to /wp-admin/plugins.php and deactivate plugin
	}
});

@alexkuc
Copy link
Contributor Author

alexkuc commented Jul 7, 2023

💡 Create a E2E to confirm it is configured and functional?

@alexkuc
Copy link
Contributor Author

alexkuc commented Jul 11, 2023

Fixture for activating/deactivating plugin has proven to be flaky i.e. intermittent failures when running repeat tests. Will proceed with the following solution

  • use global setup for plugin activation/deactivation
  • implement provisioning of unique WordPress credentials per worker

@alexkuc
Copy link
Contributor Author

alexkuc commented Jul 12, 2023

Investigate why opening Categories fails:

image

@alexkuc
Copy link
Contributor Author

alexkuc commented Jul 12, 2023

Something overwrites WP_DEBUG to false

Edit: overwrite comes from @wordpress/env, see default wp-config.php values

@alexkuc
Copy link
Contributor Author

alexkuc commented Jul 12, 2023

Looks like the issue was solved after running yarn docker:stop && yarn docker:start --update i.e. looks like it was broken/dirty state of the environment. Fyi, running just yarn docker:start --update is sufficient as @wordpress/env is smart enough to stop docker container(s) first.

@alexkuc
Copy link
Contributor Author

alexkuc commented Jul 12, 2023

Base for actual E2E branches - 78b59fbd9688938dae34a44156e1f0b058d6c9a7 - until PR #1228 is merged into master

@alexkuc
Copy link
Contributor Author

alexkuc commented Jul 12, 2023

@tn3rb Just FYI, I know this issue seemed like it was in limbo but actually lots of work was being done, I just didn't update TODOs on time

@alexkuc
Copy link
Contributor Author

alexkuc commented Jul 12, 2023

@tn3rb Just FYI, when converting tests, I am following the testing scope of whatever was in the original E2E tests. This is to avoid scope creep. My vision is to convert existing E2E tests and hook them up as a part of our pipeline asap. Then we can open subsequent GH issues and/or PRs to improve those tests. I see that there is a lot of great value for the company by automating E2E so I'd rather follow incremental Agile approach instead of trying to get "picture perfect" E2E tests (waterfall). However… if you prefer to follow a different approach, please let me know and I'll adapt accordingly.

@alexkuc
Copy link
Contributor Author

alexkuc commented Jul 13, 2023

Since #1228 is merged, all E2E branches are to be based off master branch

@alexkuc
Copy link
Contributor Author

alexkuc commented Jul 13, 2023

Experiencing intermittent failures again…

Error: page.reload: Navigation failed because page was closed!
=========================== logs ===========================
waiting for navigation until "load"
  navigated to "http://<host>:<port>/wp-admin/admin.php?page=espresso_events&action=create_new"
============================================================

  118 |
  119 | 			// reload page to check if default settings have applied
> 120 | 			await eventPage.reload();
      | 			                ^
  121 |
  122 | 			await expect(eventDropdown).toHaveValue(value);
  123 |

    at /<path>/events-page.spec.ts:120:20

@alexkuc
Copy link
Contributor Author

alexkuc commented Jul 13, 2023

During investigation I have noticed that auth cookies are missing

@alexkuc
Copy link
Contributor Author

alexkuc commented Jul 13, 2023

Looks like increasing timeout per test to 60 seconds resolved the issue

@alexkuc
Copy link
Contributor Author

alexkuc commented Jul 13, 2023

I need to consider that not all E2E tests will support concurrency, such as testing global settings

@alexkuc
Copy link
Contributor Author

alexkuc commented Jul 13, 2023

The alternative to run tests in series is to actually support multiple databases. Consider official WordPress docker image.

@alexkuc
Copy link
Contributor Author

alexkuc commented Jul 13, 2023

Before proceeding anyway, let's do a quick investigation to confirm this theory that running tests sequentially will resolve issue of having unexpected values in assert conditions

@alexkuc
Copy link
Contributor Author

alexkuc commented Jul 13, 2023

Thinking more about… having a separate database instance per work might be way too hard to implement since that would require some kind of broker mechanism to spin up new WordPress instance and provision new database.

@alexkuc
Copy link
Contributor Author

alexkuc commented Jul 13, 2023

By the way, running tests sequentially leads to no errors but timeframe is increased by x5-10

@alexkuc
Copy link
Contributor Author

alexkuc commented Jul 14, 2023

Investigating flakiness


Runs

Command Outcome
yarn e2e:run --repeat-each 3 --project chromium
yarn e2e:run --repeat-each 3 --project chromium --workers 1
yarn e2e:run --repeat-each 3 --project chromium --workers 1 --trace on
yarn e2e:run --repeat-each 4 --project chromium --workers 1
yarn e2e:run --repeat-each 4 --project chromium --workers 1 --trace on
yarn e2e:run --repeat-each 5 --project chromium

Note: test case is marked as test.only

@alexkuc
Copy link
Contributor Author

alexkuc commented Jul 17, 2023

When running tests in series, it appears that fixture Auth fails as the test times out on the login page when attempting to navigate to admin page for EE events

Edit: Strangely enough, it is the initial/admin tab that fails to re-use auth cookie cookie. We actually expect to re-use same admin auth session. Similar, to how it is possible to open several WP admin pages under the same account.

@alexkuc
Copy link
Contributor Author

alexkuc commented Jul 17, 2023

When the Auth fixture fails, it looks like auth cookie is wrong as it has value of

Cookie: wordpress_test_cookie=WP%20Cookie%20check

@alexkuc
Copy link
Contributor Author

alexkuc commented Jul 17, 2023

It appears that even when auth cookie is present, test is getting timeout at the login page. What I have noticed is that redirect is indeed happening due to WordPress. Curiously enough, there is search param reauth=1 present for some reason.

@alexkuc
Copy link
Contributor Author

alexkuc commented Jul 17, 2023

Once I have enabled screenshots and trace on Auth fixture, the error seems gone?

await page.context().tracing.start({
	screenshots: true,
	snapshots: true,
	sources: true,
});
await page.screenshot({
  fullPage: true,
  path: `<repo>/debug-ss/ss-${this.workerInfo.workerIndex}-${this.workerInfo.parallelIndex}.png`,
});

await page.context().tracing.stop({
  path: `<repo>/debug-trace/trace-${this.workerInfo.workerIndex}-${this.workerInfo.parallelIndex}.zip`,
});

@alexkuc
Copy link
Contributor Author

alexkuc commented Jul 18, 2023

To avoid issues with "floating" time, I need to set it to something fixed and used static timestamps to avoid unexpected surprises. Consider this solution.

@alexkuc
Copy link
Contributor Author

alexkuc commented Jul 20, 2023

As per my conversation with @tn3rb instead of doing implicit checks, e.g. count how many datetimes an event has, I should explicitly checks parameter, e.g. does a specific datetime exist for a given event?

@alexkuc
Copy link
Contributor Author

alexkuc commented Jul 21, 2023

Scaffolding data via UI fixtures proved unreliable. I will investigate REST API route for scaffolding data.

@alexkuc
Copy link
Contributor Author

alexkuc commented Jul 27, 2023

Error reporting constants

  • E_ERROR
  • E_PARSE
  • E_CORE_ERROR
  • E_COMPILE_ERROR
  • E_USER_ERROR
  • E_RECOVERABLE_ERROR

from https://www.php.net/manual/en/errorfunc.constants.php

Bitmask value for error_reporting() is 4437 thanks to this calculator

@alexkuc
Copy link
Contributor Author

alexkuc commented Feb 18, 2024

@alexkuc alexkuc closed this as completed Feb 18, 2024
@alexkuc
Copy link
Contributor Author

alexkuc commented Mar 10, 2024

Files references in this issue can be found in this PR or via file browser here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: tests 🧪 category D: Packages 📦 domain: Barista Packages P3: med priority 😐 priority: medium S1: new 👶🏻 status T: chore 🧹 type: REPO - maintenance
Projects
None yet
Development

No branches or pull requests

1 participant