Skip to content

Commit

Permalink
test: only run the collaborative env when needed
Browse files Browse the repository at this point in the history
In an effort to reduce the flakiness of the tests, we now only run tests with
multiple pages (multiple editors) when needed.
  • Loading branch information
christianhg committed Sep 24, 2024
1 parent 33941cf commit 1d0fc29
Show file tree
Hide file tree
Showing 27 changed files with 596 additions and 367 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Feature: Annotations Across Blocks

Background:
Given two editors
Given one editor
And a global keymap

Scenario: Adding annotation across blocks
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Feature: Annotations Collaboration

Background:
Given two editors
And a global keymap

Scenario: Editor B inserts text after Editor A's half-deleted annotation
Given the text "foo"
And a "comment" "c1" around "foo"
When the caret is put after "foo"
And "Backspace" is pressed
And the caret is put after "fo" by editor B
And "a" is typed by editor B
Then the text is "fo,a"
And "fo" has marks "c1"
And "a" has no marks
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/** @jest-environment ./setup/collaborative.jest.env.ts */

import {Feature} from '@sanity/gherkin-driver/jest'
import annotationsCollaboration from './annotations-collaboration.feature'
import {parameterTypes, stepDefinitions} from './gherkin-step-definitions'

Feature({
featureText: annotationsCollaboration,
stepDefinitions,
parameterTypes,
})
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
Feature: Annotations Edge Cases

Background:
Given two editors
Given one editor
And a global keymap

Scenario: Editor B inserts text after Editor A's half-deleted annotation
Given the text "foo"
And a "comment" "c1" around "foo"
When the caret is put after "foo"
And "Backspace" is pressed
And the caret is put after "fo" by editor B
And "a" is typed by editor B
Then the text is "fo,a"
And "fo" has marks "c1"
And "a" has no marks

Scenario: Deleting emphasised paragraph with comment in the middle
Given the text "foo bar baz"
And "em" around "foo bar baz"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Feature: Annotations Overlapping Decorators

Background:
Given two editors
Given one editor
And a global keymap

Scenario: Annotation and decorator on the same text
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Feature: Overlapping Annotations

Background:
Given two editors
Given one editor
And a global keymap

Scenario: Overlapping annotation
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/e2e-tests/__tests__/annotations.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Feature: Annotations

Background:
Given two editors
Given one editor
And a global keymap

Scenario: Selection after adding an annotation
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/e2e-tests/__tests__/annotations.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @jest-environment ./setup/collaborative.jest.env.ts */
/** @jest-environment ./setup/jest.env.ts */

import {Feature} from '@sanity/gherkin-driver/jest'
import annotationsAcrossBlocks from './annotations-across-blocks.feature'
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/e2e-tests/__tests__/block-objects.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Feature: Block Objects

Background:
Given two editors
Given one editor
And a global keymap

Scenario: Pressing ArrowUp on a lonely image
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/e2e-tests/__tests__/block-objects.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @jest-environment ./setup/collaborative.jest.env.ts */
/** @jest-environment ./setup/jest.env.ts */

import {Feature} from '@sanity/gherkin-driver/jest'
import featureFile from './block-objects.feature'
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/e2e-tests/__tests__/decorators.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Feature: Decorators

Background:
Given two editors
Given one editor
And a global keymap

Scenario: Inserting text after a decorator
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/e2e-tests/__tests__/decorators.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @jest-environment ./setup/collaborative.jest.env.ts */
/** @jest-environment ./setup/jest.env.ts */

import {Feature} from '@sanity/gherkin-driver/jest'
import featureFile from './decorators.feature'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ export const stepDefinitions = [
context.keyMap = new Map()
}),

Given<Context>('one editor', async (context) => {
const editor = await getEditor()
context.editorA = editor
}),

Given<Context>('two editors', async (context) => {
const [editorA, editorB] = await getEditors()
context.editorA = editorA
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/e2e-tests/__tests__/inline-objects.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Feature: Inline Objects

Background:
Given two editors
Given one editor
And a global keymap

# Currently fails
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/e2e-tests/__tests__/inline-objects.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @jest-environment ./setup/collaborative.jest.env.ts */
/** @jest-environment ./setup/jest.env.ts */

import {Feature} from '@sanity/gherkin-driver/jest'
import {parameterTypes, stepDefinitions} from './gherkin-step-definitions'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Feature: Removing Blocks

Background:
Given two editors
Given one editor
And a global keymap

Scenario: Pressing Delete in empty block with text below
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @jest-environment ./setup/collaborative.jest.env.ts */
/** @jest-environment ./setup/jest.env.ts */

import {Feature} from '@sanity/gherkin-driver/jest'
import {parameterTypes, stepDefinitions} from './gherkin-step-definitions'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Feature: Splitting Blocks

Background:
Given two editors
Given one editor
And a global keymap

Scenario: Splitting block at the beginning
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @jest-environment ./setup/collaborative.jest.env.ts */
/** @jest-environment ./setup/jest.env.ts */

import {Feature} from '@sanity/gherkin-driver/jest'
import {parameterTypes, stepDefinitions} from './gherkin-step-definitions'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
Feature: Undo/Redo Collaboration

Background:
Given two editors
And a global keymap

Scenario: Undoing local annotation added before remote annotation
Given the text "foobar"
And a "comment" "c1" around "foo"
And a "link" "l1" around "bar" by editor B
When undo is performed
Then the text is "foo,bar"
And "foo" has no marks
And "bar" has marks "l1"

Scenario: Undoing local annotation added after remote annotation
Given the text "foobar"
And a "link" "l1" around "bar" by editor B
And a "comment" "c1" around "foo"
When undo is performed
Then the text is "foo,bar"
And "foo" has no marks
And "bar" has marks "l1"

Scenario: Undoing local same-type annotation added before remote annotation
Given the text "foobar"
And a "comment" "c1" around "foo"
And a "comment" "c2" around "bar" by editor B
When undo is performed
Then the text is "foo,bar"
And "foo" has no marks
And "bar" has marks "c2"

# Currently fails
@skip
Scenario: Undoing and redoing local annotation before remote annotation
Given the text "foobar"
And a "comment" "c1" around "foo"
And a "comment" "c2" around "bar" by editor B
When undo is performed
Then the text is "foo,bar"
And "foo" has no marks
And "bar" has marks "c2"
When redo is performed
Then "foo" has marks "c1"
And "bar" has marks "c2"
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/** @jest-environment ./setup/collaborative.jest.env.ts */

import {Feature} from '@sanity/gherkin-driver/jest'
import {parameterTypes, stepDefinitions} from './gherkin-step-definitions'
import undoRedoCollaboration from './undo-redo-collaboration.feature'

Feature({
featureText: undoRedoCollaboration,
stepDefinitions,
parameterTypes,
})
43 changes: 1 addition & 42 deletions packages/editor/e2e-tests/__tests__/undo-redo.feature
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Feature: Undo/Redo

Background:
Given two editors
Given one editor
And a global keymap

Scenario: Undoing annotation
Expand Down Expand Up @@ -43,47 +43,6 @@ Feature: Undo/Redo
Then the text is "foo"
And "foo" has marks "c1"

Scenario: Undoing local annotation added before remote annotation
Given the text "foobar"
And a "comment" "c1" around "foo"
And a "link" "l1" around "bar" by editor B
When undo is performed
Then the text is "foo,bar"
And "foo" has no marks
And "bar" has marks "l1"

Scenario: Undoing local annotation added after remote annotation
Given the text "foobar"
And a "link" "l1" around "bar" by editor B
And a "comment" "c1" around "foo"
When undo is performed
Then the text is "foo,bar"
And "foo" has no marks
And "bar" has marks "l1"

Scenario: Undoing local same-type annotation added before remote annotation
Given the text "foobar"
And a "comment" "c1" around "foo"
And a "comment" "c2" around "bar" by editor B
When undo is performed
Then the text is "foo,bar"
And "foo" has no marks
And "bar" has marks "c2"

# Currently fails
@skip
Scenario: Undoing and redoing local annotation before remote annotation
Given the text "foobar"
And a "comment" "c1" around "foo"
And a "comment" "c2" around "bar" by editor B
When undo is performed
Then the text is "foo,bar"
And "foo" has no marks
And "bar" has marks "c2"
When redo is performed
Then "foo" has marks "c1"
And "bar" has marks "c2"

Scenario: Undoing and redoing inserting text after annotated text
Given the text "foo"
And a "comment" "c1" around "foo"
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/e2e-tests/__tests__/undo-redo.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @jest-environment ./setup/collaborative.jest.env.ts */
/** @jest-environment ./setup/jest.env.ts */

import {Feature} from '@sanity/gherkin-driver/jest'
import {parameterTypes, stepDefinitions} from './gherkin-step-definitions'
Expand Down
Loading

0 comments on commit 1d0fc29

Please sign in to comment.