Skip to content

Commit c2f2806

Browse files
authored
Merge branch 'main' into preview-variable-widgets
2 parents 734403b + 8b8e873 commit c2f2806

File tree

44 files changed

+835
-239
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+835
-239
lines changed

.github/workflows/nodejs.yml

Lines changed: 12 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ name: Node CI
22

33
on:
44
push:
5-
branches:
6-
- main
75
pull_request:
86
types: [opened, synchronize, reopened]
97

@@ -28,73 +26,37 @@ jobs:
2826
matrix:
2927
os: [macos-latest, windows-latest, ubuntu-latest]
3028
node-version: [18.x, 20.x]
29+
fail-fast: true
3130
if: ${{ needs.changes.outputs.cms == 'true' }}
3231
steps:
3332
- uses: actions/checkout@v3
34-
- name: Use Node.js {{ matrix.node-version }}
33+
- name: Use Node.js ${{ matrix.node-version }}
3534
uses: actions/setup-node@v3
3635
with:
3736
node-version: ${{ matrix.node-version }}
3837
check-latest: true
38+
cache: 'npm'
3939
- name: log versions
4040
run: node --version && npm --version && yarn --version
41-
- name: install dependecies
42-
run: npm install
41+
- name: install dependencies
42+
run: npm ci
4343
- name: run unit tests
4444
run: npm run test:ci
45-
env:
46-
CI: true
47-
NODE_OPTIONS: --max-old-space-size=4096
4845
- name: build demo site
4946
run: npm run build:demo
47+
- name: run e2e tests
48+
if: matrix.os == 'ubuntu-latest' && matrix.node-version == '20.x'
49+
run: npm run test:e2e:run-ci
5050
env:
51-
NODE_OPTIONS: --max-old-space-size=4096
52-
- uses: actions/upload-artifact@master
53-
with:
54-
name: dev-test-website-${{ runner.os }}-${{ matrix.node-version }}
55-
path: dev-test
56-
57-
e2e-with-cypress:
58-
needs: [changes, build]
59-
runs-on: ubuntu-latest
60-
61-
strategy:
62-
matrix:
63-
node-version: [18.x, 20.x]
64-
fail-fast: false
65-
66-
if: ${{ needs.changes.outputs.cms == 'true' }}
67-
steps:
68-
- uses: actions/checkout@v3
69-
- name: Use Node.js
70-
uses: actions/setup-node@v3
71-
with:
72-
node-version: ${{ matrix.node-version }}
73-
check-latest: true
74-
- uses: actions/download-artifact@master
75-
with:
76-
name: dev-test-website-${{ runner.os }}-18.x
77-
path: dev-test
78-
- name: npm install
79-
run: |
80-
node --version
81-
npm --version
82-
yarn --version
83-
npm install
84-
- name: e2e test
85-
run: |
86-
npm run test:e2e:run-ci
87-
env:
88-
IS_FORK: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == true }}
51+
IS_FORK: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == true || github.repository_owner != 'decaporg' }}
8952
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
9053
NODE_OPTIONS: --max-old-space-size=4096
91-
MACHINE_COUNT: 2
92-
MACHINE_INDEX: ${{ matrix.node-version }}
9354
TZ: Europe/Amsterdam
9455
- uses: actions/upload-artifact@v3
95-
if: ${{ always() }}
56+
if: matrix.os == 'ubuntu-latest' && matrix.node-version == '20.x' && failure()
9657
with:
97-
name: cypress-results-${{ matrix.node-version }}
58+
name: cypress-results
9859
path: |
9960
cypress/screenshots
10061
cypress/videos
62+

babel.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const svgo = {
4242
function presets() {
4343
return [
4444
'@babel/preset-react',
45-
'@babel/preset-env',
45+
['@babel/preset-env', isESM ? { modules: false } : {}],
4646
[
4747
'@emotion/babel-preset-css-prop',
4848
{

cypress/e2e/editorial_workflow_spec_test_backend.js

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -207,17 +207,16 @@ describe('Test Backend Editorial Workflow', () => {
207207
login();
208208

209209
inSidebar(() => cy.contains('a', 'Pages').click());
210-
inSidebar(() => cy.contains('a', 'Directory'));
210+
inSidebar(() => cy.contains('a', /^Directory$/));
211211
inGrid(() => cy.contains('a', 'Root Page'));
212-
inGrid(() => cy.contains('a', 'Directory'));
213212

214-
inSidebar(() => cy.contains('a', 'Directory').click());
213+
inSidebar(() => cy.contains('a', /^Directory$/).click());
215214

216-
inGrid(() => cy.contains('a', 'Sub Directory'));
217-
inGrid(() => cy.contains('a', 'Another Sub Directory'));
215+
inSidebar(() => cy.contains('a', /^Sub Directory$/));
216+
inSidebar(() => cy.contains('a', 'Another Sub Directory'));
218217

219-
inSidebar(() => cy.contains('a', 'Sub Directory').click());
220-
inGrid(() => cy.contains('a', 'Nested Directory'));
218+
inSidebar(() => cy.contains('a', /^Sub Directory$/).click());
219+
inSidebar(() => cy.contains('a', 'Nested Directory'));
221220
cy.url().should(
222221
'eq',
223222
'http://localhost:8080/#/collections/pages/filter/directory/sub-directory',
@@ -233,21 +232,17 @@ describe('Test Backend Editorial Workflow', () => {
233232
login();
234233

235234
inSidebar(() => cy.contains('a', 'Pages').click());
236-
inSidebar(() => cy.contains('a', 'Directory').click());
237-
inGrid(() => cy.contains('a', 'Another Sub Directory').click());
238-
239-
cy.url().should(
240-
'eq',
241-
'http://localhost:8080/#/collections/pages/entries/directory/another-sub-directory/index',
242-
);
235+
inSidebar(() => cy.contains('a', /^Directory$/).click());
236+
inSidebar(() => cy.contains('a', 'Another Sub Directory').click());
237+
inGrid(() => cy.contains('a', 'Another Sub Directory'));
243238
});
244239

245240
it(`can create a new entry with custom path`, () => {
246241
login();
247242

248243
inSidebar(() => cy.contains('a', 'Pages').click());
249-
inSidebar(() => cy.contains('a', 'Directory').click());
250-
inSidebar(() => cy.contains('a', 'Sub Directory').click());
244+
inSidebar(() => cy.contains('a', /^Directory$/).click());
245+
inSidebar(() => cy.contains('a', /^Sub Directory$/).click());
251246
cy.contains('a', 'New Page').click();
252247

253248
cy.get('[id^="path-field"]').should('have.value', 'directory/sub-directory');
@@ -262,18 +257,18 @@ describe('Test Backend Editorial Workflow', () => {
262257
publishEntryInEditor(publishTypes.publishNow);
263258
exitEditor();
264259

265-
inGrid(() => cy.contains('a', 'New Path Title'));
266-
inSidebar(() => cy.contains('a', 'Directory').click());
267-
inSidebar(() => cy.contains('a', 'Directory').click());
260+
inSidebar(() => cy.contains('a', 'New Path Title'));
261+
inSidebar(() => cy.contains('a', /^Directory$/).click());
262+
inSidebar(() => cy.contains('a', /^Directory$/).click());
268263
inGrid(() => cy.contains('a', 'New Path Title').should('not.exist'));
269264
});
270265

271266
it(`can't create an entry with an existing path`, () => {
272267
login();
273268

274269
inSidebar(() => cy.contains('a', 'Pages').click());
275-
inSidebar(() => cy.contains('a', 'Directory').click());
276-
inSidebar(() => cy.contains('a', 'Sub Directory').click());
270+
inSidebar(() => cy.contains('a', /^Directory$/).click());
271+
inSidebar(() => cy.contains('a', /^Sub Directory$/).click());
277272

278273
cy.contains('a', 'New Page').click();
279274
cy.get('[id^="title-field"]').type('New Path Title');
@@ -292,7 +287,8 @@ describe('Test Backend Editorial Workflow', () => {
292287
login();
293288

294289
inSidebar(() => cy.contains('a', 'Pages').click());
295-
inGrid(() => cy.contains('a', 'Directory').click());
290+
inSidebar(() => cy.contains('a', /^Directory$/).click());
291+
inGrid(() => cy.contains('a', /^Directory$/).click());
296292

297293
cy.get('[id^="path-field"]').should('have.value', 'directory');
298294
cy.get('[id^="path-field"]').clear();
@@ -310,7 +306,7 @@ describe('Test Backend Editorial Workflow', () => {
310306

311307
inSidebar(() => cy.contains('a', 'New Directory').click());
312308

313-
inGrid(() => cy.contains('a', 'Sub Directory'));
314-
inGrid(() => cy.contains('a', 'Another Sub Directory'));
309+
inSidebar(() => cy.contains('a', /^Sub Directory$/));
310+
inSidebar(() => cy.contains('a', 'Another Sub Directory'));
315311
});
316312
});

cypress/e2e/markdown_widget_code_block_spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ function codeBlock(content) {
7777
<div>
7878
<div></div>
7979
<div>
80-
<div><label>Code Block</label>
80+
<div>
81+
<div><label>Code Block</label></div>
8182
<div><button><span><svg>
8283
<path></path>
8384
</svg></span></button>

cypress/run.mjs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,40 @@ import execa from 'execa';
22
import { globby } from 'globby';
33

44
async function runCypress() {
5+
const args = ['run', '--browser', 'chrome', '--headless'];
6+
7+
const specs = await globby(['cypress/e2e/*spec*.js']);
8+
if (specs.length === 0) {
9+
console.log('No test files found in cypress/e2e/*spec*.js');
10+
process.exit(1);
11+
}
12+
513
if (process.env.IS_FORK === 'true') {
614
const machineIndex = parseInt(process.env.MACHINE_INDEX);
715
const machineCount = parseInt(process.env.MACHINE_COUNT);
8-
const specs = await globby(['cypress/integration/*spec*.js']);
916
const specsPerMachine = Math.floor(specs.length / machineCount);
1017
const start = (machineIndex - 1) * specsPerMachine;
1118
const machineSpecs =
1219
machineIndex === machineCount
1320
? specs.slice(start)
1421
: specs.slice(start, start + specsPerMachine);
1522

16-
await execa(
17-
'cypress',
18-
['run', '--browser', 'chrome', '--headless', '--spec', machineSpecs.join(',')],
19-
{ stdio: 'inherit', preferLocal: true },
20-
);
23+
args.push('--spec', machineSpecs.join(','));
2124
} else {
22-
await execa(
23-
'cypress',
24-
[
25-
'run',
26-
'--browser',
27-
'chrome',
28-
'--headless',
29-
'--record',
30-
'--parallel',
31-
'--ci-build-id',
32-
process.env.GITHUB_SHA,
33-
'--group',
34-
'GitHub CI',
35-
],
36-
{ stdio: 'inherit', preferLocal: true },
25+
args.push(
26+
'--record',
27+
'--parallel',
28+
'--ci-build-id',
29+
process.env.GITHUB_SHA,
30+
'--group',
31+
'GitHub CI',
32+
'--spec',
33+
specs.join(','),
3734
);
3835
}
36+
37+
console.log('Running Cypress with args:', args.join(' '));
38+
await execa('cypress', args, { stdio: 'inherit', preferLocal: true });
3939
}
4040

4141
runCypress();

cypress/support/e2e.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,9 @@ addMatchImageSnapshotCommand({
2626
Cypress.on('uncaught:exception', () => false);
2727

2828
import './commands';
29+
30+
afterEach(function () {
31+
if (this.currentTest.state === 'failed') {
32+
Cypress.runner.stop();
33+
}
34+
});

cypress/utils/steps.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ function assertColorOn(cssProperty, color, opts) {
6969
} else {
7070
(opts.scope ? opts.scope : cy)
7171
.contains('label', opts.label)
72+
.parents()
7273
.next()
7374
.should(assertion);
7475
}
@@ -518,23 +519,31 @@ function validateNestedListFields() {
518519
cy.contains('button', 'hotel locations').click();
519520
cy.contains('button', 'cities').click();
520521
cy.contains('label', 'City')
522+
.parents()
521523
.next()
524+
.first()
522525
.type('Washington DC');
523526
cy.contains('label', 'Number of Hotels in City')
527+
.parents()
524528
.next()
529+
.first()
525530
.type('5');
526531
cy.contains('button', 'city locations').click();
527532

528533
// add second city list item
529534
cy.contains('button', 'cities').click();
530535
cy.contains('label', 'Cities')
536+
.parents()
531537
.next()
538+
.first()
532539
.find('div[class*=SortableListItem]')
533540
.eq(2)
534541
.as('secondCitiesListControl');
535542
cy.get('@secondCitiesListControl')
536543
.contains('label', 'City')
544+
.parents()
537545
.next()
546+
.first()
538547
.type('Boston');
539548
cy.get('@secondCitiesListControl')
540549
.contains('button', 'city locations')
@@ -561,21 +570,25 @@ function validateNestedListFields() {
561570

562571
// list control aliases
563572
cy.contains('label', 'Hotel Locations')
573+
.parents()
564574
.next()
565575
.find('div[class*=SortableListItem]')
566576
.first()
567577
.as('hotelLocationsListControl');
568578
cy.contains('label', 'Cities')
579+
.parents()
569580
.next()
570581
.find('div[class*=SortableListItem]')
571582
.eq(0)
572583
.as('firstCitiesListControl');
573584
cy.contains('label', 'City Locations')
585+
.parents()
574586
.next()
575587
.find('div[class*=SortableListItem]')
576588
.eq(0)
577589
.as('firstCityLocationsListControl');
578590
cy.contains('label', 'Cities')
591+
.parents()
579592
.next()
580593
.find('div[class*=SortableListItem]')
581594
.eq(3)
@@ -589,7 +602,9 @@ function validateNestedListFields() {
589602
assertListControlErrorStatus([colorError, colorError], '@secondCityLocationsListControl');
590603

591604
cy.contains('label', 'Hotel Name')
605+
.parents()
592606
.next()
607+
.first()
593608
.type('The Ritz Carlton');
594609
cy.contains('button', 'Save').click();
595610
assertNotification(notifications.error.missingField);
@@ -598,12 +613,20 @@ function validateNestedListFields() {
598613
// fill out rest of form and save
599614
cy.get('@secondCitiesListControl')
600615
.contains('label', 'Number of Hotels in City')
616+
.parents()
617+
.next()
618+
.first()
601619
.type(3);
602620
cy.get('@secondCitiesListControl')
603621
.contains('label', 'Hotel Name')
622+
.parents()
623+
.next()
624+
.first()
604625
.type('Grand Hyatt');
605626
cy.contains('label', 'Country')
627+
.parents()
606628
.next()
629+
.first()
607630
.type('United States');
608631
flushClockAndSave();
609632
assertNotification(notifications.saved);

nx.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
{
22
"targetDefaults": {
33
"build:esm": {
4-
"cache": true
4+
"cache": true,
5+
"dependsOn": ["^build:esm"]
56
},
67
"build": {
7-
"cache": true
8+
"cache": true,
9+
"dependsOn": ["^build"]
810
}
911
},
1012
"namedInputs": {

0 commit comments

Comments
 (0)