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

Add/edit posts tests #1089

Closed

Conversation

tellthemachines
Copy link
Contributor

Sequel to #200, fixes element targeting issues in some of the tests.

Trac ticket: https://core.trac.wordpress.org/ticket/49507


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@tellthemachines tellthemachines marked this pull request as ready for review March 22, 2021 23:26
Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work here. Love seeing e2e test added to Core. It's important though to not add Gutenberg e2e tests to Core because we already have a way to run Gutenberg tests in Core.

I think this one is ready for commit

@JustinyAhin
Copy link
Member

I've run the tests, and they work as expected.

@tellthemachines I was wondering, does it make sense to add a README to the e2e folder with information about how to run the test, how to enable headless mode for the tests for instance?

Also, what does this needs to get merged?

@talldan
Copy link

talldan commented Jul 15, 2021

There's a README over here @JustinyAhin - #1451.

@hellofromtonya
Copy link
Contributor

@tellthemachines @talldan Is this PR ready for commit? Does it overlap any of the work that @JustinyAhin is doing?

@tellthemachines
Copy link
Contributor Author

@hellofromtonya yup, this one's ready to go. It doesn't overlap with Justin's PRs as this is specific to the posts screen and Justin has been focusing on other screens so far.

@hellofromtonya
Copy link
Contributor

When running this test locally (via npm run test:e2e), I get the following error:

 FAIL  tests/e2e/specs/edit-posts.test.js (76.359 s)
  ● Edit Posts › allows an existing post to be edited using the Edit button

    TimeoutError: waiting for selector `.components-snackbar` failed: timeout 30000ms exceeded

      44 | 		const title = 'Test Title';
      45 | 		await createNewPost( { title } );
    > 46 | 		await publishPost();
         | 		^
      47 | 		await visitAdminPage( '/edit.php' );
      48 |
      49 | 		await page.waitForSelector( '#the-list .type-post' );

      at new WaitTask (../../node_modules/puppeteer-core/src/common/DOMWorld.ts:780:28)
      at DOMWorld.waitForSelectorInPage (../../node_modules/puppeteer-core/src/common/DOMWorld.ts:632:22)
      at Object.internalHandler.waitFor (../../node_modules/puppeteer-core/src/common/QueryHandler.ts:78:19)
      at DOMWorld.waitForSelector (../../node_modules/puppeteer-core/src/common/DOMWorld.ts:490:25)
      at Frame.waitForSelector (../../node_modules/puppeteer-core/src/common/FrameManager.ts:1163:47)
      at Page.waitForSelector (../../node_modules/puppeteer-core/src/common/Page.ts:2100:29)
      at publishPost (../../node_modules/@wordpress/e2e-test-utils/build/@wordpress/e2e-test-utils/src/publish-post.js:19:14)
          at runMicrotasks (<anonymous>)
      at Object.<anonymous> (specs/edit-posts.test.js:46:3)

  ● Edit Posts › allows an existing post to be deleted using the Trash button

    TimeoutError: waiting for selector `.components-snackbar` failed: timeout 30000ms exceeded

      110 | 		const title = 'Test Title';
      111 | 		await createNewPost( { title } );
    > 112 | 		await publishPost();
          | 		^
      113 | 		await visitAdminPage( '/edit.php' );
      114 |
      115 | 		await page.waitForSelector( '#the-list .type-post' );

      at new WaitTask (../../node_modules/puppeteer-core/src/common/DOMWorld.ts:780:28)
      at DOMWorld.waitForSelectorInPage (../../node_modules/puppeteer-core/src/common/DOMWorld.ts:632:22)
      at Object.internalHandler.waitFor (../../node_modules/puppeteer-core/src/common/QueryHandler.ts:78:19)
      at DOMWorld.waitForSelector (../../node_modules/puppeteer-core/src/common/DOMWorld.ts:490:25)
      at Frame.waitForSelector (../../node_modules/puppeteer-core/src/common/FrameManager.ts:1163:47)
      at Page.waitForSelector (../../node_modules/puppeteer-core/src/common/Page.ts:2100:29)
      at publishPost (../../node_modules/@wordpress/e2e-test-utils/build/@wordpress/e2e-test-utils/src/publish-post.js:19:14)
          at runMicrotasks (<anonymous>)
      at Object.<anonymous> (specs/edit-posts.test.js:112:3)

 PASS  tests/e2e/specs/dashboard.test.js
 PASS  tests/e2e/specs/hello.test.js

Test Suites: 1 failed, 2 passed, 3 total
Tests:       2 failed, 6 passed, 8 total
Snapshots:   0 total
Time:        79.215 s

@tellthemachines Does it pass locally for you?

@tellthemachines
Copy link
Contributor Author

@hellofromtonya it passes for me! I rebased the branch in case it helps at all.

@hellofromtonya
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants