Skip to content

Commit df59248

Browse files
authored
Merge pull request #191 from KevinBatdorf/test-with-wp-7
2 parents 8d50561 + 8735e12 commit df59248

11 files changed

Lines changed: 15884 additions & 15881 deletions

File tree

.github/workflows/cypress-main.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@ on:
88
# At 08:00 daily
99
- cron: '0 8 * * *'
1010
jobs:
11+
lint:
12+
name: Lint and Build
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Clone repo
16+
uses: actions/checkout@v4
17+
18+
- name: Install and Build
19+
run: |
20+
npm ci
21+
npx eslint --max-warnings 0 .
22+
npm run build
1123
test:
1224
name: WordPress ${{ matrix.wp-version }} (${{ matrix.spec }})
1325
concurrency:
@@ -26,7 +38,6 @@ jobs:
2638
- name: Install and Build
2739
run: |
2840
npm ci
29-
npx eslint --max-warnings 0 .
3041
npm run build
3142
- name: Get Latest WP Branch
3243
if: ${{ matrix.wp-version }}
@@ -50,16 +61,17 @@ jobs:
5061
uses: cypress-io/github-action@v6
5162
with:
5263
browser: chrome
64+
install: false
5365
spec: cypress/e2e/${{ matrix.spec }}.cy.js
5466
env:
5567
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5668
- uses: actions/upload-artifact@v4
5769
if: failure()
5870
with:
59-
name: cypress-screenshots
71+
name: cypress-screenshots-${{ matrix.spec }}
6072
path: cypress/screenshots
6173
- uses: actions/upload-artifact@v4
6274
if: failure()
6375
with:
64-
name: cypress-videos
76+
name: cypress-videos-${{ matrix.spec }}
6577
path: cypress/videos

.github/workflows/cypress-push.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ on:
55
- main
66
workflow_dispatch:
77
jobs:
8+
lint:
9+
name: Lint and Build
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Clone repo
13+
uses: actions/checkout@v4
14+
15+
- name: Install and build
16+
run: |
17+
npm ci
18+
npx eslint --max-warnings 0 .
19+
npm run build
820
test:
921
name: WordPress (${{ matrix.spec }})
1022
concurrency:
@@ -22,7 +34,6 @@ jobs:
2234
- name: Install and build
2335
run: |
2436
npm ci
25-
npx eslint --max-warnings 0 .
2637
npm run build
2738
- name: Start server
2839
run: |
@@ -33,16 +44,17 @@ jobs:
3344
uses: cypress-io/github-action@v6
3445
with:
3546
browser: chrome
47+
install: false
3648
spec: cypress/e2e/${{ matrix.spec }}.cy.js
3749
env:
3850
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3951
- uses: actions/upload-artifact@v4
4052
if: failure()
4153
with:
42-
name: cypress-screenshots
54+
name: cypress-screenshots-${{ matrix.spec }}
4355
path: cypress/screenshots
4456
- uses: actions/upload-artifact@v4
4557
if: failure()
4658
with:
47-
name: cypress-videos
59+
name: cypress-videos-${{ matrix.spec }}
4860
path: cypress/videos

cypress/e2e/block.cy.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -314,15 +314,10 @@ context('Pattern Css (Block)', () => {
314314
});
315315
});
316316
it('Removes @import, @keyframes, and others', () => {
317-
const css = `@charset "UTF-8";
318-
@import url('https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css');
319-
@media screen and (max-width: 600px) { .f { foo: 'bar';} }
320-
@page :left {}
321-
@font-face {font-family: MyFont;src: url('myfont.woff2');}
322-
@keyframes slidein {from {}to {}}
323-
@view-transition { navigation: auto }
324-
@counter-style customCounter { system: cyclic; }
325-
@namespace svg url(http://www.w3.org/2000/svg);`;
317+
const css = `@font-face {font-family: MyFont;src: url('myfont.woff2');}
318+
@keyframes slidein {from {opacity: 0} to {opacity: 1}}
319+
@media screen and (max-width: 600px) { [block] { color: red; } }
320+
[block] { padding: 1rem; }`;
326321

327322
cy.withEditorWp((_win, wp) => {
328323
const block = wp.blocks.createBlock('core/group', {}, [
@@ -340,7 +335,7 @@ context('Pattern Css (Block)', () => {
340335

341336
cy.previewCurrentPage();
342337

343-
// should not have any of the rules except media query
338+
// should not have any of the rules except media query and block styles
344339
cy.get(`style#pcss-block-${className}-inline-css`)
345340
.invoke('text')
346341
.should('not.contain', '@import')
@@ -352,7 +347,8 @@ context('Pattern Css (Block)', () => {
352347
.and('not.contain', '@view-transition')
353348
.and('not.contain', '@counter-style')
354349
.and('not.contain', '@namespace')
355-
.and('contain', '@media');
350+
.and('contain', '@media')
351+
.and('contain', 'padding');
356352
});
357353
});
358354
});

cypress/support/wp-cli.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,33 @@
1+
let snapshotCreated = false;
2+
3+
const createSnapshot = () => {
4+
cy.exec('wp-env run cli wp db export /tmp/clean-snapshot.sql', {
5+
failOnNonZeroExit: false,
6+
});
7+
snapshotCreated = true;
8+
};
9+
10+
const restoreSnapshot = () => {
11+
cy.exec('wp-env run cli wp db import /tmp/clean-snapshot.sql', {
12+
failOnNonZeroExit: false,
13+
});
14+
cy.exec('wp-env run cli wp cache flush', {
15+
failOnNonZeroExit: false,
16+
});
17+
};
18+
119
export const resetDatabase = () => {
20+
if (snapshotCreated) {
21+
restoreSnapshot();
22+
return;
23+
}
224
cy.exec('wp-env clean all', {
325
failOnNonZeroExit: false,
426
});
527
cy.exec(
628
'wp-env run cli wp user meta add 1 wp_persisted_preferences \'{"core/edit-post":{"welcomeGuide":false,"core/edit-post/pattern-modal":false,"pattern-modal":false,"edit-post/pattern-modal":false,"patternModal":false},"core":{"enableChoosePatternModal":false},"_modified":"2025-03-23T02:16:33.561Z"}\' --format=json',
729
);
30+
createSnapshot();
831
};
932
export const installPlugin = (slug) =>
1033
cy.exec(`wp-env run cli wp plugin install ${slug} --activate`, {

0 commit comments

Comments
 (0)