Skip to content

Commit

Permalink
feature: add editor pin test (#1291)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonSiefke authored Sep 30, 2024
1 parent 54636c1 commit 72cdba9
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/e2e/src/editor.toggle-pin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export const setup = async ({ Workspace, Explorer, Editor }) => {
await Workspace.setFiles([
{
name: 'file.txt',
content: '',
},
])
await Editor.closeAll()
await Explorer.focus()
await Explorer.shouldHaveItem('file.txt')
await Editor.open('file.txt')
}

export const run = async ({ Editor }) => {
await Editor.pin()
await Editor.unpin()
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ export const toHaveClass = (element, { className }) => {
return element.className === className || element.classList.contains(className)
}

export const notToHaveClass = (element, { className }) => {
Assert.string(className)
return !element.classList.contains(className)
}

export const toHaveId = (element, { id }) => {
Assert.string(id)
return element.id === id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export const getFunction = (fnName) => {
return SingleElementConditions.toHaveClass
case 'toBeHidden':
return SingleElementConditions.toBeHidden
case 'notToHaveClass':
return SingleElementConditions.notToHaveClass
default:
throw new Error(`unexpected function name ${fnName}`)
}
Expand Down
30 changes: 30 additions & 0 deletions packages/page-object/src/parts/Editor/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -664,5 +664,35 @@ export const create = ({ page, expect, VError }) => {
throw new VError(error, `Failed to wait for editor error`)
}
},
// tab tab-actions-right sizing-fit has-icon active selected tab-border-bottom tab-border-top sticky sticky-normal
// tab tab-actions-right sizing-fit has-icon active selected tab-border-bottom tab-border-top
async pin() {
try {
const tabsContainer = page.locator('.tabs-and-actions-container')
await expect(tabsContainer).toBeVisible()
const activeTab = tabsContainer.locator('.tab.active')
await expect(activeTab).notToHaveClass('sticky-normal')
const quickPick = QuickPick.create({ page, expect, VError })
await quickPick.executeCommand(WellKnownCommands.PinEditor)
await page.waitForIdle()
await expect(activeTab).toHaveClass('sticky-normal')
} catch (error) {
throw new VError(error, `Failed to pin editor`)
}
},
async unpin() {
try {
const tabsContainer = page.locator('.tabs-and-actions-container')
await expect(tabsContainer).toBeVisible()
const activeTab = tabsContainer.locator('.tab.active')
await expect(activeTab).toHaveClass('sticky-normal')
const quickPick = QuickPick.create({ page, expect, VError })
await quickPick.executeCommand(WellKnownCommands.UnPinEditor)
await page.waitForIdle()
await expect(activeTab).notToHaveClass('sticky-normal')
} catch (error) {
throw new VError(error, `Failed to unpin editor`)
}
},
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const MoveActivityBarToTheSide = 'View: Move Activity Bar to Side'
export const NewUntitledTextFile = 'File: New Untitled Text File'
export const OpenKeyboardShortcuts = 'Preferences: Open Keyboard Shortcuts'
export const OutputFocusOnOutputView = 'Output: Focus on Output View'
export const PinEditor = 'View: Pin Editor'
export const PreferencesOpenSettingsUi = 'Preferences: Open Settings (UI)'
export const ProblemsFocusOnProblemsView = 'Problems: Focus on Problems View'
export const ProfilesCreateProfile = 'Profiles: Create Profile...'
Expand Down Expand Up @@ -59,6 +60,7 @@ export const Undo = 'Undo'
export const ViewCloseAllEditors = 'View: Close All Editors'
export const ViewShowProfiles = 'View: Show Profiles'
export const ViewSplitEditorDown = 'View: Split Editor Down'
export const UnPinEditor = 'View: Unpin Editor'
export const ViewSplitEditorLeft = 'View: Split Editor Left'
export const ViewSplitEditorRight = 'View: Split Editor Right'
export const ViewSplitEditorUp = 'View: Split Editor Up'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from '../ExpectLocatorNotToHaveClass/ExpectLocatorNotToHaveClass.js'
export * from '../ExpectLocatorToBeFocused/ExpectLocatorToBeFocused.js'
export * from '../ExpectLocatorToBeHidden/ExpectLocatorToBeHidden.js'
export * from '../ExpectLocatorToBeVisible/ExpectLocatorToBeVisible.js'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import * as ExpectLocatorSingleElementCondition from '../ExpectLocatorSingleElementCondition/ExpectLocatorSingleElementCondition.js'

export const notToHaveClass = (locator, className) => {
return ExpectLocatorSingleElementCondition.checkSingleElementCondition('notToHaveClass', locator, {
className,
})
}

0 comments on commit 72cdba9

Please sign in to comment.