Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

chore: initial cypress tests #979

Closed
wants to merge 129 commits into from
Closed
Show file tree
Hide file tree
Changes from 124 commits
Commits
Show all changes
129 commits
Select commit Hold shift + click to select a range
a5878b1
feat: resizable-editor (#882)
KaneFreeman Sep 14, 2023
a724f1b
feat: add defaults to view filter and view group (#883)
KaneFreeman Sep 14, 2023
21673c6
docs: add docs link to releases page
KaneFreeman Sep 14, 2023
4a908d5
feat: custom themes (#885)
KaneFreeman Sep 19, 2023
b8de5f1
chore: clean up aria labels (#886)
KaneFreeman Sep 19, 2023
22ff427
feat: add prefix/suffix options for boolean, number and string widget…
KaneFreeman Sep 19, 2023
f61d914
feat: date fns template string (#890)
KaneFreeman Sep 20, 2023
c10f404
Update BREAKING_CHANGES.md
KaneFreeman Sep 20, 2023
4ad9dfd
Merge branch 'main' into next
KaneFreeman Sep 24, 2023
9ffceef
feat: better matching for lists and objects (#895)
KaneFreeman Sep 28, 2023
76cb69e
feat: editorial workflow (#898)
KaneFreeman Oct 3, 2023
9c655f0
Merge branch 'main' into next
KaneFreeman Oct 3, 2023
6f129d4
feat: keyboard support datetime input (#902)
KaneFreeman Oct 3, 2023
79b6996
Merge branch 'main' into next
KaneFreeman Oct 4, 2023
de56cbe
chore: update locales
KaneFreeman Oct 4, 2023
0fb04fc
feat: update eslint, prettier and typescript (#912)
KaneFreeman Oct 4, 2023
edba6a6
feat: update react-virtual (#913)
KaneFreeman Oct 4, 2023
fa0027a
chore: update postcss and tailwind (#914)
KaneFreeman Oct 4, 2023
eb3a9cc
chore: update graphql (#915)
KaneFreeman Oct 4, 2023
2423fa1
chore: update-webpack (#916)
KaneFreeman Oct 4, 2023
f9eae15
feat: update lerna, lint-staged and all-contributors-cli (#917)
KaneFreeman Oct 4, 2023
7fc9afd
chore: update babel (#919)
KaneFreeman Oct 4, 2023
0a5481a
fix: translate untranslated widgets (#918)
denyskon Oct 4, 2023
555f773
chore: update css-loader, clean up @emotion babel/eslint config (#920)
KaneFreeman Oct 4, 2023
c2c1360
fix: balloon toolbar tests
KaneFreeman Oct 4, 2023
26914e8
chore: update locales
KaneFreeman Oct 4, 2023
6aaa787
chore: remove old unused translation key
KaneFreeman Oct 4, 2023
60da7f5
chore: update codemirror (#922)
KaneFreeman Oct 4, 2023
19dfc08
chore: update docs site dependencies and sync with mono repo (#923)
KaneFreeman Oct 5, 2023
524803f
Merge branch 'main' into next
KaneFreeman Oct 5, 2023
7c06bee
chore: update jest (#924)
KaneFreeman Oct 5, 2023
f8bd840
chore: update minor dependencies (#925)
KaneFreeman Oct 5, 2023
3483eb0
Merge branch 'main' into next
KaneFreeman Oct 10, 2023
1d42b63
Merge branch 'main' into next
KaneFreeman Oct 12, 2023
ff44124
WIP
KaneFreeman Oct 12, 2023
ee29bff
Merge branch 'main' into next
KaneFreeman Oct 12, 2023
434cbb8
Merge branch 'main' into next
KaneFreeman Oct 23, 2023
cc816c4
WIP
KaneFreeman Oct 23, 2023
7e82dde
Update config.yml
KaneFreeman Oct 23, 2023
27e0685
WIP
KaneFreeman Oct 23, 2023
04cb146
Update config.yml
KaneFreeman Oct 23, 2023
c25ae0f
Update steps.js
KaneFreeman Oct 23, 2023
aa0883e
WIP
KaneFreeman Oct 23, 2023
41ef585
WIP
KaneFreeman Oct 23, 2023
d9c9423
Merge branch 'main' into next
KaneFreeman Oct 23, 2023
721c458
Merge branch 'main' into next
KaneFreeman Oct 24, 2023
3cc7647
Merge branch 'main' into next
KaneFreeman Oct 25, 2023
aaa184d
Merge branch 'next' into feat/cypress-tests
KaneFreeman Oct 25, 2023
83b0bdb
fix: update i18n editor code after merge from main
KaneFreeman Oct 26, 2023
f0aca25
Merge branch 'main' into next
KaneFreeman Oct 26, 2023
ee8ff07
fix: formatting
KaneFreeman Oct 26, 2023
b9504fb
fix: type error after main merge
KaneFreeman Oct 26, 2023
d6fc0c5
fix: tests and types
KaneFreeman Oct 26, 2023
65fb9ad
Merge branch 'next' into feat/cypress-tests
KaneFreeman Oct 26, 2023
3690e45
WIP
KaneFreeman Oct 27, 2023
7a89cf8
WIP
KaneFreeman Oct 27, 2023
7cfef68
WIP
KaneFreeman Oct 27, 2023
6519b67
WIP
KaneFreeman Oct 27, 2023
b2126c4
WIP
KaneFreeman Oct 27, 2023
c6b5cf0
fix: resizing the editor doesn't work correctly in Firefox due to poi…
Mathieu-COSYNS Oct 27, 2023
0da49f1
Merge branch 'main' into next
KaneFreeman Oct 27, 2023
5763a57
Merge branch 'next' into feat/cypress-tests
KaneFreeman Oct 27, 2023
45ab780
Merge branch 'main' into next
KaneFreeman Oct 29, 2023
a97d063
Merge branch 'next' into feat/cypress-tests
KaneFreeman Oct 29, 2023
83d6112
WIP
KaneFreeman Oct 29, 2023
ec75fcd
Merge branch 'main' into next
KaneFreeman Oct 29, 2023
d69ed92
Merge branch 'next' into feat/cypress-tests
KaneFreeman Oct 29, 2023
b297bd2
WIP
KaneFreeman Oct 30, 2023
f201fbe
WIP
KaneFreeman Oct 30, 2023
c8e3dcc
WIP
KaneFreeman Oct 30, 2023
b0b20cf
WIP
KaneFreeman Oct 30, 2023
945a020
WIP
KaneFreeman Oct 30, 2023
da8c4b0
WIP
KaneFreeman Oct 30, 2023
1a0a2f5
WIP
KaneFreeman Oct 30, 2023
c5a597b
WIP
KaneFreeman Oct 30, 2023
49c7b3d
Update steps.js
KaneFreeman Oct 30, 2023
e7a9bb5
WIP
KaneFreeman Oct 30, 2023
daad93f
WIP
KaneFreeman Oct 30, 2023
27ee994
Merge branch 'main' into next
KaneFreeman Oct 30, 2023
d112e80
Update config.yml
KaneFreeman Oct 30, 2023
f5352b4
Update package.json
KaneFreeman Oct 30, 2023
4ffd38c
Merge branch 'main' into next
KaneFreeman Oct 31, 2023
426a796
Merge branch 'next' into feat/cypress-tests
KaneFreeman Oct 31, 2023
9f3bd50
feat: open authoring (#938)
KaneFreeman Nov 1, 2023
3e60df3
v4.0.0-beta.0
KaneFreeman Nov 1, 2023
7924fde
docs: update for beta
KaneFreeman Nov 1, 2023
ce0968e
chore: update locales
KaneFreeman Nov 1, 2023
a937e7c
docs: demo version and update release page
KaneFreeman Nov 2, 2023
66a1351
docs: do not show pre versions on homepage
KaneFreeman Nov 2, 2023
98ed101
Update index.tsx
KaneFreeman Nov 2, 2023
12a6f1e
chore: update demo
KaneFreeman Nov 2, 2023
0eeaa52
fix: hide dashboard nav item when not using editorial workflow (#966)
KaneFreeman Nov 2, 2023
0be8be2
fix: translate dashboard nav item (#967)
KaneFreeman Nov 2, 2023
a1761e1
docs: update demo with both simple and editorial workflows
KaneFreeman Nov 2, 2023
5973234
docs: update to next 14
KaneFreeman Nov 2, 2023
cf9658b
v4.0.0-beta.1
KaneFreeman Nov 2, 2023
aa20633
chore: bump github actions node version to 18
KaneFreeman Nov 2, 2023
b64b7b4
chore: add v4.0.0-beta.1 release
KaneFreeman Nov 2, 2023
7de6bb9
feat: add demo url
KaneFreeman Nov 3, 2023
56679ac
fix: demo url computation
KaneFreeman Nov 3, 2023
6354675
fix: open demo in new tab
KaneFreeman Nov 3, 2023
b40aeec
Merge branch 'next' into feat/cypress-tests
KaneFreeman Nov 3, 2023
c01bd87
WIP
KaneFreeman Nov 3, 2023
f0fefd2
WIP
KaneFreeman Nov 3, 2023
d438138
WIP
KaneFreeman Nov 3, 2023
0f049c5
WIP
KaneFreeman Nov 3, 2023
bc08759
WIP
KaneFreeman Nov 6, 2023
1804df3
WIP
KaneFreeman Nov 6, 2023
778ee1f
WIP
KaneFreeman Nov 7, 2023
d10e754
feat: allow events to be registered without collection specified (#972)
KaneFreeman Nov 7, 2023
f903bf5
Merge branch 'main' into next
KaneFreeman Nov 7, 2023
a10cd5d
docs: update all post hints
KaneFreeman Nov 7, 2023
2346734
Merge branch 'main' into next
KaneFreeman Nov 7, 2023
b1bf500
docs: add release 4.0.0-beta.2
KaneFreeman Nov 7, 2023
037ac0b
v4.0.0-beta.2
KaneFreeman Nov 7, 2023
dd246a4
Merge branch 'next' into feat/cypress-tests
KaneFreeman Nov 7, 2023
8b92537
WIP
KaneFreeman Nov 7, 2023
33a71f1
WIP
KaneFreeman Nov 7, 2023
801a6c2
WIP
KaneFreeman Nov 7, 2023
84b73db
feat: allow yaml parse/stringify options in config (#977)
KaneFreeman Nov 8, 2023
ab0f4cb
v4.0.0-beta.3
KaneFreeman Nov 8, 2023
c4cc999
Update releases.json
KaneFreeman Nov 8, 2023
464aec1
Merge branch 'next' into feat/cypress-tests
KaneFreeman Nov 8, 2023
8347d4f
WIP
KaneFreeman Nov 8, 2023
f894b0a
WIP
KaneFreeman Nov 8, 2023
c68fc33
Update cypress.yml
KaneFreeman Nov 8, 2023
5a13c61
WIP
KaneFreeman Nov 8, 2023
82a9571
Merge branch 'main' into next
KaneFreeman Nov 8, 2023
5152a01
Merge branch 'next' into feat/cypress-tests
KaneFreeman Nov 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
packages/app/yarn.lock
packages/core/yarn.lock
packages/docs/yarn.lock
node-version: 16
node-version: 18

- name: Install
run: |
Expand All @@ -50,7 +50,7 @@ jobs:
packages/app/yarn.lock
packages/core/yarn.lock
packages/docs/yarn.lock
node-version: 16
node-version: 18

- name: Install
run: |
Expand All @@ -75,7 +75,7 @@ jobs:
packages/app/yarn.lock
packages/core/yarn.lock
packages/docs/yarn.lock
node-version: 16
node-version: 18

- name: Install
run: |
Expand Down Expand Up @@ -105,7 +105,7 @@ jobs:
packages/app/yarn.lock
packages/core/yarn.lock
packages/docs/yarn.lock
node-version: 16
node-version: 18

- name: Install
run: |
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Cypress Tests

on:
workflow_dispatch:
push:
branches: ["main", "next"]
pull_request:
branches: ["main", "next"]

jobs:
cypress-run:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3
with:
cache: yarn
cache-dependency-path: |
yarn.lock
packages/app/yarn.lock
packages/core/yarn.lock
packages/docs/yarn.lock
node-version: 18

- name: Install
run: |
yarn install --frozen-lockfile

- name: Run Cypress Tests
uses: cypress-io/github-action@v6
with:
start: yarn dev
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
/node_modules
*.log
.vscode
cypress/screenshots
cypress/downloads
.env
.temp
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dist/
bin/
public/
.cache/
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"arrowParens": "avoid",
"trailingComma": "all",
"singleQuote": true,
"printWidth": 100
}
9 changes: 9 additions & 0 deletions BREAKING_CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- View Filters config structure changed
- View Groups config structure changed
- `theme` props removed (use new `useTheme` hook instead)
- date string template filter now use date-fns instead of momentjs
- filter rules behavior changed for objects and lists
- i18n settings `defaultLocale` => `default_locale`

# Typescript
- `StringOrTextField` has been split into `StringField` and `TextField`.
19 changes: 19 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { defineConfig } from "cypress";
import setupNodeEvents from "./cypress/plugins";

export default defineConfig({
projectId: "1c35bs",
retries: {
runMode: 0,
openMode: 0,
},
chromeWebSecurity: false,
e2e: {
video: false,
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents,
baseUrl: "http://localhost:8080",
specPattern: "cypress/e2e/*.spec.ts",
},
});
72 changes: 72 additions & 0 deletions cypress/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Cypress Tests Guide

## Introduction

[Cypress](https://www.cypress.io/) is a JavaScript End to End Testing Framework that runs in the browser.

Cypress tests run with a [local version](../packages/core/dev-test) of the CMS.

During the setup of a spec file, the relevant `index.html` and `config.yml` are copied from `packages/core/dev-test/backends/<backend>` to `dev-test`.

Tests for the `test` backend use mock data generated in `dev-test/backends/test/index.html`.

Tests for the other backends use previously [recorded data](fixtures) and stub `fetch` [calls](support/commands.js#L52). See more about recording tests data [here](#recording-tests-data).

## Run Tests Locally

```bash
yarn test:e2e # builds the demo site and runs Cypress in headless mode with mock data
```

## Debug Tests

```bash
yarn develop # starts a local dev server with the demo site
yarn test:e2e:exec # runs Cypress in non-headless mode with mock data
```

## Recording Tests Data

When recording tests, access to the relevant backend API is required, thus one must set up a `.env` file in the root project directory in the following format:

```bash
GITHUB_REPO_OWNER=owner
GITHUB_REPO_NAME=repo
GITHUB_REPO_TOKEN=tokenWithWritePermissions
GITHUB_OPEN_AUTHORING_OWNER=forkOwner
GITHUB_OPEN_AUTHORING_TOKEN=tokenWithWritePermissions

GITLAB_REPO_OWNER=owner
GITLAB_REPO_NAME=repo
GITLAB_REPO_TOKEN=tokenWithWritePermissions

BITBUCKET_REPO_OWNER=owner
BITBUCKET_REPO_NAME=repo
BITBUCKET_OUATH_CONSUMER_KEY=ouathConsumerKey
BITBUCKET_OUATH_CONSUMER_SECRET=ouathConsumerSecret

NETLIFY_API_TOKEN=netlifyApiToken
NETLIFY_INSTALLATION_ID=netlifyGitHubInstallationId
```

> The structure of the relevant repo should match the settings in [`config.yml`](../packages/core/dev-test/backends/<backend>/config.yml#L1)

To start a recording run the following commands:

```bash
yarn develop # starts a local dev server with the demo site
yarn mock:server:start # starts the recording proxy
yarn test:e2e:record-fixtures:dev # runs Cypress in non-headless and pass data through the recording proxy
yarn mock:server:stop # stops the recording proxy
```

> During the recorded process a clone of the relevant repo will be created under `.temp` and reset between tests.

Recordings are sanitized from any possible sensitive data and [transformed](plugins/common.js#L34) into an easier to process format.

To avoid recording all the tests over and over again, a recommended process is to:

1. Mark the specific test as `only` by changing `it("some test...` to `it.only("some test...` for the relevant test.
2. Run the test in recording mode.
3. Exit Cypress and stop the proxy.
4. Run the test normally (with mock data) to verify the recording works.
82 changes: 82 additions & 0 deletions cypress/cypress.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/// <reference types="cypress" />

import type {
SetupBackendProps,
SetupBackendTestProps,
SeedRepoProps,
TeardownBackendTestProps,
TeardownBackendProps,
} from './interface';
import type { Config as CMSConfig, DeepPartial } from '@staticcms/core/interface';

interface KeyProps {
shift?: boolean;
times?: number;
}

declare global {
namespace Cypress {
interface Chainable {
task(event: 'setupBackend', props: SetupBackendProps): Chainable<SetupBackendResponse>;
task(event: 'setupBackendTest', props: SetupBackendTestProps): Chainable<Promise<null>>;
task(event: 'seedRepo', props: SeedRepoProps): Chainable<Promise<null>>;
task(event: 'teardownBackendTest', props: TeardownBackendTestProps): Chainable<Promise<null>>;
task(event: 'teardownBackend', props: TeardownBackendProps): Chainable<Promise<null>>;
task(event: 'updateConfig', props: DeepPartial<CMSConfig>): Chainable<Promise<null>>;

login(): Chainable;
loginAndNewPost(): Chainable;

dragTo(selector: string, options?: { delay?: number }): Chainable;

getMarkdownEditor(): Chainable;
confirmMarkdownEditorContent(expected: string): Chainable;
clearMarkdownEditorContent(): Chainable;
confirmRawEditorContent(expected: string): Chainable;

enter(props?: KeyProps): Chainable;
backspace(props?: KeyProps): Chainable;
selectAll(props?: KeyProps): Chainable;
up(props?: KeyProps): Chainable;
down(props?: KeyProps): Chainable;
left(props?: KeyProps): Chainable;
right(props?: KeyProps): Chainable;
tabkey(props?: KeyProps): Chainable;

selection(
fn: (this: Cypress.ObjectLike, currentSubject: JQuery<any>) => Chainable,
): Chainable;
setSelection(
query:
| string
| {
anchorQuery: string;
anchorOffset?: number;
focusQuery: string;
focusOffset?: number;
},
endQuery: string,
): Chainable;

setCursor(query: string, atStart?: boolean): Chainable;
setCursorBefore(query: string): Chainable;
setCursorAfter(query: string): Chainable;

print(message: string): Chainable;

insertCodeBlock(): Chainable;
insertEditorComponent(title: string): Chainable;

clickToolbarButton(title: string, opts: { times: number }): Chainable;
clickHeadingOneButton(opts: { times: number }): Chainable;
clickHeadingTwoButton(opts: { times: number }): Chainable;
clickOrderedListButton(opts: { times: number }): Chainable;
clickUnorderedListButton(opts: { times: number }): Chainable;
clickCodeButton(opts: { times: number }): Chainable;
clickItalicButton(opts: { times: number }): Chainable;
clickQuoteButton(opts: { times: number }): Chainable;
clickLinkButton(opts: { times: number }): Chainable;
clickModeToggle(): Chainable;
}
}
}
30 changes: 30 additions & 0 deletions cypress/e2e/_old/editorial_workflow_spec_bitbucket_backend.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import fixture from '../common/editorial_workflow';
import * as specUtils from '../common/spec_utils';
import { entry1, entry2, entry3 } from '../common/entries';

const backend = 'bitbucket';

describe('BitBucket Backend Editorial Workflow', () => {
let taskResult = { data: {} };

before(() => {
specUtils.before(taskResult, { publish_mode: 'editorial_workflow' }, backend);
});

after(() => {
specUtils.after(taskResult, backend);
});

beforeEach(() => {
specUtils.beforeEach(taskResult, backend);
});

afterEach(() => {
specUtils.afterEach(taskResult, backend);
});

fixture({
entries: [entry1, entry2, entry3],
getUser: () => taskResult.data.user,
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import fixture from '../common/editorial_workflow';
import * as specUtils from '../common/spec_utils';
import { entry1, entry2, entry3 } from '../common/entries';

const backend = 'git-gateway';
const provider = 'github';

describe('Git Gateway (GitHub) Backend Editorial Workflow', () => {
let taskResult = { data: {} };

before(() => {
specUtils.before(taskResult, { publish_mode: 'editorial_workflow', provider }, backend);
});

after(() => {
specUtils.after(taskResult, backend);
});

beforeEach(() => {
specUtils.beforeEach(taskResult, backend);
});

afterEach(() => {
specUtils.afterEach(taskResult, backend);
});

fixture({
entries: [entry1, entry2, entry3],
getUser: () => taskResult.data.user,
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import fixture from '../common/editorial_workflow';
import * as specUtils from '../common/spec_utils';
import { entry1, entry2, entry3 } from '../common/entries';

const backend = 'git-gateway';
const provider = 'gitlab';

describe('Git Gateway (GitLab) Backend Editorial Workflow', () => {
let taskResult = { data: {} };

before(() => {
specUtils.before(taskResult, { publish_mode: 'editorial_workflow', provider }, backend);
});

after(() => {
specUtils.after(taskResult, backend);
});

beforeEach(() => {
specUtils.beforeEach(taskResult, backend);
});

afterEach(() => {
specUtils.afterEach(taskResult, backend);
});

fixture({
entries: [entry1, entry2, entry3],
getUser: () => taskResult.data.user,
});
});
Loading
Loading