-
Notifications
You must be signed in to change notification settings - Fork 3.3k
chore: add ui states tests #31768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
chore: add ui states tests #31768
Changes from 11 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
d8096f0
chore: add ui states tests
estrada9166 9d67afc
refactor: enhance UI states tests with specific Percy snapshot names
estrada9166 c5804e3
Merge branch 'develop' into alejandro/chore/add-ui-states-tests
jennifer-shehane 395026f
refactor: streamline UI states tests by using aliases for elements an…
estrada9166 18da72a
Merge branch 'develop' into alejandro/chore/add-ui-states-tests
estrada9166 945e2a9
Trigger run
estrada9166 6847bf2
Enhance UI states tests by adding new test files for commands, errors…
estrada9166 b7113f5
Merge branch 'develop' into alejandro/chore/add-ui-states-tests
estrada9166 a3c6419
Refactor UI states tests to include multiple parts for commands and o…
estrada9166 de90067
Refactor UI states tests by renaming command test files for clarity a…
estrada9166 e25a545
Remove outdated UI commands tests to streamline the test suite and im…
estrada9166 f0865e6
Add additional command options tests for UI states, enhancing coverag…
estrada9166 6e876e8
Update with code review
estrada9166 d3ee106
Merge branch 'develop' into alejandro/chore/add-ui-states-tests
estrada9166 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,260 @@ | ||
import { runSpec } from './support/spec-loader' | ||
|
||
describe('src/cypress/runner ui states', { retries: 0, defaultCommandTimeout: 600000 }, () => { | ||
beforeEach(() => { | ||
cy.viewport(1000, 1500) | ||
}) | ||
|
||
it('hooks', () => { | ||
runSpec({ | ||
fileName: 'ui-states/hooks.cy.js', | ||
}) | ||
.then((win) => { | ||
return new Promise<void>((resolve) => { | ||
win.getEventManager().on('cypress:in:cypress:run:complete', () => { | ||
resolve() | ||
}) | ||
}).then(() => { | ||
cy.contains('test hooks').should('be.visible') | ||
cy.percySnapshot() | ||
}) | ||
}) | ||
}) | ||
|
||
it('nested tests', () => { | ||
runSpec({ | ||
fileName: 'ui-states/nested-tests.cy.js', | ||
}) | ||
.then((win) => { | ||
return new Promise<void>((resolve) => { | ||
win.getEventManager().on('cypress:in:cypress:run:complete', () => { | ||
resolve() | ||
}) | ||
}).then(() => { | ||
cy.contains('Nested Tests').should('be.visible') | ||
cy.percySnapshot() | ||
}) | ||
}) | ||
}) | ||
|
||
describe('commands', () => { | ||
it('commands that dont display in UI', () => { | ||
AtofStryker marked this conversation as resolved.
Show resolved
Hide resolved
|
||
runSpec({ | ||
fileName: 'ui-states/commands.cy.js', | ||
}) | ||
.then((win) => { | ||
return new Promise<void>((resolve) => { | ||
win.getEventManager().on('cypress:in:cypress:run:complete', () => { | ||
resolve() | ||
}) | ||
}).then(() => { | ||
cy.contains('commands that dont display in UI').should('be.visible').click() | ||
cy.percySnapshot() | ||
}) | ||
}) | ||
}) | ||
|
||
it('commands that display in UI - part 1', () => { | ||
runSpec({ | ||
fileName: 'ui-states/commandsToDisplay.cy.js', | ||
}) | ||
.then((win) => { | ||
return new Promise<void>((resolve) => { | ||
win.getEventManager().on('cypress:in:cypress:run:complete', () => { | ||
resolve() | ||
}) | ||
}).then(() => { | ||
cy.contains('commands that display in UI - part 1').should('be.visible') | ||
.click() | ||
|
||
cy.percySnapshot() | ||
}) | ||
}) | ||
}) | ||
|
||
it('commands that display in UI - part 2', () => { | ||
runSpec({ | ||
fileName: 'ui-states/commandsToDisplay.cy.js', | ||
}) | ||
.then((win) => { | ||
return new Promise<void>((resolve) => { | ||
win.getEventManager().on('cypress:in:cypress:run:complete', () => { | ||
resolve() | ||
}) | ||
}).then(() => { | ||
cy.contains('commands that display in UI - part 2').should('be.visible') | ||
.click() | ||
|
||
cy.percySnapshot() | ||
}) | ||
}) | ||
}) | ||
|
||
it('commands that display in UI - part 3', () => { | ||
runSpec({ | ||
fileName: 'ui-states/commandsToDisplay.cy.js', | ||
}) | ||
.then((win) => { | ||
return new Promise<void>((resolve) => { | ||
win.getEventManager().on('cypress:in:cypress:run:complete', () => { | ||
resolve() | ||
}) | ||
}).then(() => { | ||
cy.contains('commands that display in UI - part 3').should('be.visible') | ||
.click() | ||
|
||
cy.percySnapshot() | ||
}) | ||
}) | ||
}) | ||
|
||
it('commands that display in UI - part 4', () => { | ||
runSpec({ | ||
fileName: 'ui-states/commandsToDisplay.cy.js', | ||
}) | ||
.then((win) => { | ||
return new Promise<void>((resolve) => { | ||
win.getEventManager().on('cypress:in:cypress:run:complete', () => { | ||
resolve() | ||
}) | ||
}).then(() => { | ||
cy.contains('commands that display in UI - part 3').should('be.visible') | ||
.click() | ||
|
||
cy.percySnapshot() | ||
}) | ||
}) | ||
}) | ||
|
||
it('command options - part 1', () => { | ||
runSpec({ | ||
fileName: 'ui-states/commands.cy.js', | ||
}) | ||
.then((win) => { | ||
return new Promise<void>((resolve) => { | ||
win.getEventManager().on('cypress:in:cypress:run:complete', () => { | ||
resolve() | ||
}) | ||
}).then(() => { | ||
cy.contains('command options - part 1').should('be.visible').click() | ||
cy.percySnapshot() | ||
}) | ||
}) | ||
}) | ||
|
||
it('command options - part 2', () => { | ||
runSpec({ | ||
fileName: 'ui-states/commands.cy.js', | ||
}) | ||
.then((win) => { | ||
return new Promise<void>((resolve) => { | ||
win.getEventManager().on('cypress:in:cypress:run:complete', () => { | ||
resolve() | ||
}) | ||
}).then(() => { | ||
cy.contains('command options - part 2').should('be.visible').click() | ||
cy.percySnapshot() | ||
}) | ||
}) | ||
}) | ||
|
||
it('command options - part 3', () => { | ||
runSpec({ | ||
fileName: 'ui-states/commands.cy.js', | ||
}) | ||
.then((win) => { | ||
return new Promise<void>((resolve) => { | ||
win.getEventManager().on('cypress:in:cypress:run:complete', () => { | ||
resolve() | ||
}) | ||
}).then(() => { | ||
cy.contains('command options - part 3').should('be.visible').click() | ||
cy.percySnapshot() | ||
}) | ||
}) | ||
}) | ||
|
||
it('Element Visibility', () => { | ||
runSpec({ | ||
fileName: 'ui-states/commands.cy.js', | ||
}) | ||
.then((win) => { | ||
return new Promise<void>((resolve) => { | ||
win.getEventManager().on('cypress:in:cypress:run:complete', () => { | ||
resolve() | ||
}) | ||
}).then(() => { | ||
cy.contains('Element Visibility').should('be.visible').click() | ||
cy.percySnapshot() | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
||
it('status codes', () => { | ||
runSpec({ | ||
fileName: 'ui-states/status-codes.cy.js', | ||
}) | ||
.then((win) => { | ||
return new Promise<void>((resolve) => { | ||
win.getEventManager().on('cypress:in:cypress:run:complete', () => { | ||
resolve() | ||
}) | ||
}).then(() => { | ||
cy.contains('Request Statuses').should('be.visible') | ||
cy.percySnapshot() | ||
}) | ||
}) | ||
}) | ||
|
||
it('page events', () => { | ||
runSpec({ | ||
fileName: 'ui-states/page-events.cy.js', | ||
}) | ||
.then((win) => { | ||
return new Promise<void>((resolve) => { | ||
win.getEventManager().on('cypress:in:cypress:run:complete', () => { | ||
resolve() | ||
}) | ||
}).then(() => { | ||
cy.contains('events - page events').should('be.visible') | ||
cy.percySnapshot() | ||
}) | ||
}) | ||
}) | ||
|
||
describe('errors', () => { | ||
it('simple error with docs link', () => { | ||
runSpec({ | ||
fileName: 'ui-states/errors.cy.js', | ||
}) | ||
.then((win) => { | ||
return new Promise<void>((resolve) => { | ||
win.getEventManager().on('cypress:in:cypress:run:complete', () => { | ||
resolve() | ||
}) | ||
}).then(() => { | ||
cy.contains('simple error with docs link').should('be.visible') | ||
cy.percySnapshot() | ||
}) | ||
}) | ||
}) | ||
|
||
it('long error', () => { | ||
runSpec({ | ||
fileName: 'ui-states/errors.cy.js', | ||
}) | ||
.then((win) => { | ||
return new Promise<void>((resolve) => { | ||
win.getEventManager().on('cypress:in:cypress:run:complete', () => { | ||
resolve() | ||
}) | ||
}).then(() => { | ||
cy.contains('simple error with docs link').click() | ||
cy.contains('long error').should('be.visible') | ||
cy.percySnapshot() | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) |
137 changes: 137 additions & 0 deletions
137
system-tests/project-fixtures/runner-specs/cypress/e2e/runner/ui-states/commands.cy.js
This file contains hidden or 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,137 @@ | ||
describe('Commands', () => { | ||
it('commands that dont display in UI', () => { | ||
cy.visit('cypress/fixtures/commandsActions.html') | ||
|
||
cy.wrap({ foo: { bar: 'baz' } }) | ||
.then((obj) => obj) | ||
.should('have.property', 'foo') | ||
.and('have.property', 'bar') | ||
|
||
cy.wrap({ foo: { bar: 'baz' } }) | ||
.as('myObject') | ||
|
||
cy.get('@myObject').then((obj) => { | ||
cy.log(obj) | ||
}) | ||
|
||
cy.get('div').each(($div) => { }).end() | ||
|
||
cy.fixture('uiStates') | ||
|
||
cy.intercept('GET', 'comments/*').as('getComment') | ||
|
||
cy.wrap(['foo', 'bar']).spread(() => {}) | ||
|
||
const obj = { | ||
foo () { }, | ||
bar () { }, | ||
} | ||
|
||
cy.spy(obj, 'foo') | ||
cy.stub(obj, 'bar') | ||
}) | ||
|
||
it('command options - part 1', () => { | ||
AtofStryker marked this conversation as resolved.
Show resolved
Hide resolved
|
||
cy.visit('cypress/fixtures/uiStates.html') | ||
|
||
cy.get('#a').focus().blur({ force: false }) | ||
cy.get('#checkbox').check({ force: false }) | ||
cy.get('form').children({ timeout: 2000 }) | ||
cy.get('#a').clear({ force: false }) | ||
cy.clearCookie('authId', { timeout: 2001 }) | ||
cy.clearCookies({ timeout: 2002 }) | ||
|
||
cy.contains('button').click({ force: false }) | ||
cy.contains('button').click(1, 2, { force: false }) | ||
cy.contains('button').click('bottom', { force: false }) | ||
|
||
cy.get('#a').closest('form', { timeout: 2003 }) | ||
cy.contains('.test', 'Hello', { timeout: 2004 }) | ||
cy.get('button').dblclick({ force: false }) | ||
|
||
cy.document({ timeout: 2005 }) | ||
|
||
cy.get('input').eq(0, { timeout: 2006 }) | ||
cy.exec('ls', { env: { 'a': true } }) | ||
cy.get('input').filter('#a', { timeout: 2007 }) | ||
cy.get('form').find('#a', { timeout: 2008 }) | ||
cy.get('input').first({ timeout: 2009 }) | ||
}) | ||
|
||
it('command options - part 2', () => { | ||
cy.visit('cypress/fixtures/uiStates.html') | ||
|
||
cy.get('#a').focus({ timeout: 2010 }) | ||
cy.get('#a').focus() | ||
cy.focused({ timeout: 2011 }) | ||
cy.get('#a', { withinSubject: document.forms[0] }) | ||
cy.getCookie('auth_key', { timeout: 2012 }) | ||
cy.getCookies({ timeout: 2013 }) | ||
cy.go('forward', { timeout: 2014 }) | ||
cy.hash({ timeout: 2015 }) | ||
cy.get('input').last({ timeout: 2016 }) | ||
cy.location('port', { timeout: 2017 }) | ||
cy.get('#a').next('input', { timeout: 2018 }) | ||
cy.get('#a').nextAll('input', { timeout: 2019 }) | ||
cy.get('#a').nextUntil('#b', { timeout: 2020 }) | ||
cy.get('input').not('#a', { timeout: 2021 }) | ||
cy.get('#a').parent('form', { timeout: 2022 }) | ||
cy.get('#a').parents('form', { timeout: 2023 }) | ||
cy.get('#a').parentsUntil('body', { timeout: 2024 }) | ||
|
||
cy.get('#b').prev('input', { timeout: 2025 }) | ||
cy.get('#b').prevAll('input', { timeout: 2026 }) | ||
cy.get('#b').prevUntil('#a', { timeout: 2027 }) | ||
cy.readFile('./cypress/fixtures/uiStates.json', { timeout: 2028 }) | ||
cy.reload(true, { timeout: 2028 }) | ||
|
||
cy.get('button').rightclick({ timeout: 2028 }) | ||
cy.root({ timeout: 2028 }) | ||
}) | ||
|
||
it('command options - part 3', () => { | ||
cy.visit('cypress/fixtures/uiStates.html') | ||
|
||
cy.screenshot({ capture: 'viewport' }) | ||
cy.get('form').scrollIntoView({ | ||
offset: { top: 20, left: 30, right: 20, bottom: 40 }, | ||
log: true, | ||
timeout: 3000, | ||
duration: 0, | ||
}) | ||
|
||
cy.scrollTo(0, 500, { duration: 100 }) | ||
cy.get('#fruits').select('apples', { force: false }) | ||
|
||
cy.setCookie('auth_key', '123key', { httpOnly: true }) | ||
|
||
cy.get('#a').siblings('input', { timeout: 2029 }) | ||
|
||
cy.get('form').submit({ timeout: 2030 }) | ||
|
||
cy.title({ timeout: 2032 }) | ||
cy.get('#a').trigger('mouseenter', 'top', { cancelable: true }) | ||
cy.get('#a').type('hi?', { | ||
delay: 10, | ||
force: true, | ||
}) | ||
|
||
cy.get('#checkbox').uncheck('good', { force: false }) | ||
cy.url({ timeout: 2033 }) | ||
cy.visit('cypress/fixtures/uiStates.html', { | ||
timeout: 20000, | ||
}) | ||
|
||
cy.wait(100, { requestTimeout: 2000 }) | ||
cy.window({ timeout: 2034 }) | ||
cy.wrap({ name: 'John Doe' }, { timeout: 2035 }) | ||
cy.writeFile('./cypress/_test-output/test.txt', 'test', { timeout: 2036 }) | ||
}) | ||
|
||
it('Element Visibility', () => { | ||
cy.visit('cypress/fixtures/commandsActions.html') | ||
|
||
cy.get('#scroll-horizontal button') | ||
.should('not.be.visible') | ||
}) | ||
}) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of
runSpec
, can we leverageloadSpec
with the correct num of 'pass/
failed assertions to avoid the
cypress:in:cypress:run:complete` event? That method should wait for the test to finnish