10up / distributor

Share content between your websites.
https://distributorplugin.com
GNU General Public License v2.0
618 stars 156 forks source link

Add categories to pull screen - 1 #1237

Open kirtangajjar opened 1 month ago

kirtangajjar commented 1 month ago

Description of the Change

Add categories to the pull screen. This is a part 1 of 2 of this issue. This PR only lists categories from posts.

Closes #428

How to test the Change

  1. Open a pull screen and select any site
  2. Ensure that you see "Categories" column on it.
  3. Ensure that the categories link to their original site.
  4. Ensure step 1-3 for both internal and external connections.

Changelog Entry

Added - categories to pull screen

Credits

Props @kirtangajjar

Checklist:

kirtangajjar commented 2 weeks ago

While testing I noticed the category link is broken because a '/' is missing

This should be fixed now.

It seems like it says a user should be able to select categories but this PR only displays them. I'm not sure how do we achieve pulling posts via selected categories in the same UI

That will happen in another PR. I'll ping that PR here when it's ready.

kirtangajjar commented 2 weeks ago

Can you please check and fix the E2E failures? Try upgrading the wp-env version.

Which version of wp-env works fine?

kirtangajjar commented 2 weeks ago

@faisal-alvi I worked fixing tests for a while and I was able to fix many things, but it looks like it'll require more work.

Work done so far:

https://github.com/10up/distributor/pull/1237/files#diff-4c9c322e893113577fd895f8ac7bf59b02ac95aaae52b64177f24a996f706c22 https://github.com/10up/distributor/pull/1237/files#diff-5da9a41590fb261de0e464c95862528100c42c77dffad53b7c6de228b6afd2bd https://github.com/10up/distributor/pull/1237/files#diff-fb5314afdcfb013b9945785877b0501d5b8fdfbe6d379a51fd4690bf5f00feca

Work remaining: Here is a sample error that's occuring:

            {
              "title": "Should distribute blocks when pushing to network connections.",
              "fullTitle": "Distributed content block tests Should distribute blocks when pushing to network connections.",
              "timedOut": null,
              "duration": 16925,
              "state": "failed",
              "speed": null,
              "pass": false,
              "fail": true,
              "pending": false,
              "context": null,
              "code": "const postTitle = 'Post to push ' + randomName();\ncy.createPost({\n  title: postTitle\n}).then(sourcePost => {\n  cy.distributorPushPost(sourcePost.id, 'second', '', 'publish').then(distributedPost => {\n    cy.postContains(distributedPost.distributedPostId, '<!-- wp:paragraph -->', 'http://localhost/second/');\n  });\n});",
              "err": {
                "message": "CypressError: `cy.exec('npm --silent run env run tests-cli \"post get 33 --field=content --url=http://localhost/second/\"')` failed because the command exited with a non-zero code.\n\nPass `{failOnNonZeroExit: false}` to ignore exit code failures.\n\nInformation about the failure:\nCode: 1\n\nStdout:\nOCI runtime exec failed: exec failed: unable to start container process: exec: \"post get 33 --field=content --url=http://localhost/second/\": stat post get 33 --field=content --url=http://localhost/...\nStderr:\n(node:1726) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.\n(Use `node --trace...\n\nhttps://on.cypress.io/exec",
                "estack": "CypressError: `cy.exec('npm --silent run env run tests-cli \"post get 33 --field=content --url=http://localhost/second/\"')` failed because the command exited with a non-zero code.\n\nPass `{failOnNonZeroExit: false}` to ignore exit code failures.\n\nInformation about the failure:\nCode: 1\n\nStdout:\nOCI runtime exec failed: exec failed: unable to start container process: exec: \"post get 33 --field=content --url=http://localhost/second/\": stat post get 33 --field=content --url=http://localhost/...\nStderr:\n(node:1726) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.\n(Use `node --trace...\n\nhttps://on.cypress.io/exec\n    at <unknown> (http://localhost/__cypress/runner/cypress_runner.js:119010:77)\n    at tryCatcher (http://localhost/__cypress/runner/cypress_runner.js:1807:23)\n    at Promise._settlePromiseFromHandler (http://localhost/__cypress/runner/cypress_runner.js:1519:31)\n    at Promise._settlePromise (http://localhost/__cypress/runner/cypress_runner.js:1576:18)\n    at Promise._settlePromise0 (http://localhost/__cypress/runner/cypress_runner.js:1621:10)\n    at Promise._settlePromises (http://localhost/__cypress/runner/cypress_runner.js:1701:18)\n    at _drainQueueStep (http://localhost/__cypress/runner/cypress_runner.js:2407:12)\n    at _drainQueue (http://localhost/__cypress/runner/cypress_runner.js:2400:9)\n    at Async._drainQueues (http://localhost/__cypress/runner/cypress_runner.js:2416:5)\n    at Async.drainQueues (http://localhost/__cypress/runner/cypress_runner.js:2286:14)\nFrom Your Spec Code:\n    at Context.wpCli (webpack:///../../node_modules/@10up/cypress-wp-utils/lib/commands/wp-cli.js:23:0)",
                "diff": null
              },
              "uuid": "bc33304f-9d27-47f7-91bd-fc8b95dcff4b",
              "parentUUID": "ea14640d-eb3f-43e4-a81e-0e5b13765920",
              "isHook": false,
              "skipped": false
            }

Here we need to change

cy.exec('npm --silent run env run tests-cli \"post get 33 --field=content --url=http://localhost/second/\"')

to

cy.exec('npx wp-env run tests-cli post get 33 --field=content --url=http://localhost/second/')

That command is coming from here - https://github.com/10up/cypress-wp-utils/blob/develop/src/commands/wp-cli.ts#L21.

I think we should create a separate issue to fixing build pipeline given the work it's requiring so it can be completed in parallel to this PR.

kirtangajjar commented 2 weeks ago

@faisal-alvi I've resolved all your comments. LMK there is any additional feedback.

faisal-alvi commented 1 week ago

@kirtangajjar Thanks for the update. Let's wait on the review/merge until the E2E tests are fixed in #1242 and merged. After that, we'll merge develop here to run the E2E tests and verify if they pass.