This repository has been archived by the owner on Sep 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Denys Konovalov <[email protected]> Co-authored-by: Mathieu COSYNS <[email protected]>
- Loading branch information
1 parent
682576f
commit 799c7e6
Showing
732 changed files
with
48,463 additions
and
10,872 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Cypress Tests | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: ['main', 'next'] | ||
pull_request: | ||
branches: ['main', 'next'] | ||
|
||
jobs: | ||
cypress-run: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
fail-fast: false # https://github.com/cypress-io/github-action/issues/48 | ||
matrix: | ||
containers: [1, 2] # Uses 2 parallel instances | ||
|
||
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 | ||
wait-on: 'http://localhost:8080' | ||
record: true # Records to Cypress Cloud | ||
parallel: true # Runs test in parallel using settings above | ||
env: | ||
# For recording and parallelization to work you must set your CYPRESS_RECORD_KEY | ||
# in GitHub repo → Settings → Secrets → Actions | ||
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} | ||
# Creating a token https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token | ||
GITHUB_TOKEN: ${{ secrets.CYPRESS_GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,7 @@ | |
/node_modules | ||
*.log | ||
.vscode | ||
cypress/screenshots | ||
cypress/downloads | ||
.env | ||
.temp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
dist/ | ||
bin/ | ||
public/ | ||
.cache/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"arrowParens": "avoid", | ||
"trailingComma": "all", | ||
"singleQuote": true, | ||
"printWidth": 100 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: "wvw3x3", | ||
retries: { | ||
runMode: 2, | ||
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", | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
30
cypress/e2e/_old/editorial_workflow_spec_bitbucket_backend.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}); | ||
}); |
31 changes: 31 additions & 0 deletions
31
cypress/e2e/_old/editorial_workflow_spec_git-gateway_github_backend.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}); | ||
}); |
31 changes: 31 additions & 0 deletions
31
cypress/e2e/_old/editorial_workflow_spec_git-gateway_gitlab_backend.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}); | ||
}); |
Oops, something went wrong.