bigbite / wp-cypress

WordPress end to end testing with Cypress.io.
MIT License
86 stars 19 forks source link

Update .htaccess when multisite enabled #52

Closed SimeonUnder2 closed 2 years ago

SimeonUnder2 commented 3 years ago

This project is awesome!!

Found a bug though :/

Describe the bug I enabled Multisite (subdirectories) and managed to get everything running but since the .htaccess isn't updated, the styles/scripts when viewing pages on blogs other than the main one are broken.

To Reproduce Setup a multisite Create an additional site Create a page View the page, eg localhost/site/example-page

Expected behavior .htaccess is updated on wp start with multisite

SimeonUnder2 commented 3 years ago

Oh ... and I'm not recommending this method, but it fixed my problem. I put this into the DefaultSeeder

        // Fix .htaccess
        file_put_contents(ABSPATH . '.htaccess', "
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
# END WordPress
        ");
liamdefty commented 3 years ago

Hi @SimeonUnder2

I'm glad you like this project! It is very much under active development so if you any feedback please let us know 😄

Good spot with this, I'm not sure how we haven't ran into this issue yet. I'm glad you found a workaround, we will try and get this fixed in the next release.

@jasonagnew I've assigned you to this, I suspect this will be an issue with some of the projects we are using this on?

SimeonUnder2 commented 3 years ago

Only other note (and perhaps this should be a separate issue) is that wp-cypress start will "successfully" run even if Docker Desktop isn't open. Where I think it should throw an alert of some kind?

liamdefty commented 3 years ago

@SimeonUnder2 I noticed that the other day on mac, it used to throw a warning but a regression must of slipped in. I've created another issue https://github.com/bigbite/wp-cypress/issues/53

Thanks!

jasonagnew commented 3 years ago

This is interesting one. I think the reason we haven't hit this issue before is we mostly focus subdomain multisite. I'll take a look as this should be easy fix.