Skip to content

Commit

Permalink
Merge branch 'develop' into stokes/26693_spec_run_logic
Browse files Browse the repository at this point in the history
  • Loading branch information
warrensplayer committed May 26, 2023
2 parents c26768e + 0cf11fe commit 1e67eae
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .circleci/workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ windowsWorkflowFilters: &windows-workflow-filters
- equal: [ develop, << pipeline.git.branch >> ]
# use the following branch as well to ensure that v8 snapshot cache updates are fully tested
- equal: [ 'update-v8-snapshot-cache-on-develop', << pipeline.git.branch >> ]
- equal: [ 'ryanm/feat/unify-cdp-approach-in-electron', << pipeline.git.branch >> ]
- equal: [ 'stokes/fix_windows_e2e_test', << pipeline.git.branch >> ]
- matches:
pattern: /^release\/\d+\.\d+\.\d+$/
value: << pipeline.git.branch >>
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/stale_issues_and_pr_cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
max-operations-per-run:
description: 'max operations per run'
required: false
default: 800
default: 3000
days-before-stale:
description: 'days-before-stale'
required: false
Expand All @@ -33,7 +33,7 @@ permissions:
pull-requests: write
env:
DEFAULT_DEBUG_ONLY: true
DEFAULT_MAX_OPS: 800
DEFAULT_MAX_OPS: 3000
DEFAULT_DAYS_BEFORE_STALE: 180
DEFAULT_DAYS_BEFORE_CLOSE: 14
DEFAULT_EXEMPT_ISSUE_LABELS: 'type: feature,type: enhancement,routed-to-e2e,routed-to-ct,routed-to-tools,routed-to-cloud,prevent-stale,triaged'
Expand Down
4 changes: 3 additions & 1 deletion packages/app/cypress/e2e/specs_list_e2e.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ describe('App: Spec List (E2E)', () => {
it('lists files after folders when in same directory', () => {
cy.findAllByTestId('row-directory-depth-2').first().click()

cy.get('[id="speclist-cypress/e2e/admin_users/"]')
const rowId = getPathForPlatform('speclist-cypress/e2e/admin_users/').replaceAll('\\', '\\\\')

cy.get(`[id="${rowId}"]`)
.next()
.should('contain', 'admin.user')
.next()
Expand Down
17 changes: 16 additions & 1 deletion packages/data-context/src/actions/ElectronActions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { App, BrowserWindow, OpenDialogOptions, OpenDialogReturnValue, SaveDialogOptions, SaveDialogReturnValue } from 'electron'
import type { App, BrowserWindow, OpenDialogOptions, OpenDialogReturnValue, SaveDialogOptions, SaveDialogReturnValue, Notification } from 'electron'
import os from 'os'
import type { DataContext } from '..'
import _ from 'lodash'
Expand All @@ -13,6 +13,7 @@ export interface ElectronApiShape {
copyTextToClipboard(text: string): void
isMainWindowFocused(): boolean
focusMainWindow(): void
createNotification(title: string, body: string): Notification
}

export class ElectronActions {
Expand Down Expand Up @@ -104,4 +105,18 @@ export class ElectronActions {
return obj.filePath || null
})
}

showSystemNotification (title: string, body: string, onClick?: () => void) {
const notification = this.ctx.electronApi.createNotification(title, body)

const defaultOnClick = async () => {
await this.ctx.actions.browser.focusActiveBrowserWindow()
}

const clickHandler = onClick || defaultOnClick

notification.on('click', clickHandler)

notification.show()
}
}
7 changes: 5 additions & 2 deletions packages/data-context/src/actions/ProjectActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type { ProjectShape } from '../data/coreDataShape'
import type { DataContext } from '..'
import { hasNonExampleSpec } from '../codegen'
import templates from '../codegen/templates'
import { insertValuesInConfigFile } from '../util'
import { insertValuesInConfigFile, toPosix } from '../util'
import { getError } from '@packages/errors'
import { resetIssuedWarnings } from '@packages/config'
import type { RunSpecErrorCode } from '@packages/graphql/src/schemaTypes'
Expand Down Expand Up @@ -606,9 +606,12 @@ export class ProjectActions {
// Now that we're in the correct testingType, verify the requested spec actually exists
// We don't have specs available until a testingType is loaded, so even through we validated
// a matching file exists above it may not end up loading as a valid spec so we validate that here
const spec = this.ctx.project.getCurrentSpecByAbsolute(absoluteSpecPath)
//
// Have to use toPosix here to align windows absolute paths with how the absolute path is storied in the data context
const spec = this.ctx.project.getCurrentSpecByAbsolute(toPosix(absoluteSpecPath))

if (!spec) {
debug(`Spec not found with path: ${absoluteSpecPath}`)
throw new RunSpecError('SPEC_NOT_FOUND', `Unable to find matching spec with path ${absoluteSpecPath}`)
}

Expand Down
3 changes: 3 additions & 0 deletions packages/graphql/schemas/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1786,6 +1786,9 @@ type Mutation {
"""Set failed tests for the current run to be used by the runner"""
setTestsForRun(testsBySpec: [TestsBySpecInput!]!): Boolean

"""Show system notification via Electron"""
showSystemNotification(body: String!, title: String!): Boolean

"""Switch Testing type and relaunch browser"""
switchTestingTypeAndRelaunch(testingType: TestingTypeEnum!): Boolean

Expand Down
15 changes: 14 additions & 1 deletion packages/graphql/src/schemaTypes/objectTypes/gql-Mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,19 @@ export const mutation = mutationType({
},
})

t.boolean('showSystemNotification', {
description: 'Show system notification via Electron',
args: {
title: nonNull(stringArg()),
body: nonNull(stringArg()),
},
resolve: async (source, args, ctx) => {
ctx.actions.electron.showSystemNotification(args.title, args.body)

return true
},
})

t.boolean('moveToRelevantRun', {
description: 'Allow the relevant run for debugging marked as next to be considered the current relevant run',
args: {
Expand All @@ -787,7 +800,7 @@ export const mutation = mutationType({
},
})

//Using a mutation to just return data in order to be able to await the results in the component
// Using a mutation to just return data in order to be able to await the results in the component
t.list.nonNull.string('testsForRun', {
description: 'Return the set of test titles for the given spec path',
args: {
Expand Down
3 changes: 3 additions & 0 deletions packages/server/lib/makeDataContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ export function makeDataContext (options: MakeDataContextOptions): DataContext {
focusMainWindow () {
return focusMainWindow()
},
createNotification (title, body) {
return new electron.Notification({ title, body })
},
},
localSettingsApi: {
async setPreferences (object: AllowedState) {
Expand Down
5 changes: 5 additions & 0 deletions packages/server/lib/modes/interactive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ export = {
},

async run (options: LaunchArgs, _loading: Promise<void>) {
// Need to set this for system notifications to appear as "Cypress" on Windows
if (app.setAppUserModelId) {
app.setAppUserModelId('Cypress')
}

// Note: We do not await the `_loading` promise here since initializing
// the data context can significantly delay initial render of the UI
// https://github.com/cypress-io/cypress/issues/26388#issuecomment-1492616609
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"dependencies": {
"find-up": "6.3.0",
"typescript": "4.7.4"
"typescript": "4.9.5"
},
"type": "module",
"projectFixtureDirectory": "simple_passing"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ path-exists@^5.0.0:
resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-5.0.0.tgz#a6aad9489200b21fab31e49cf09277e5116fb9e7"
integrity "sha1-pqrZSJIAsh+rMeSc8JJ35RFvuec= sha512-RjhtfwJOxzcFmNOi6ltcbcu4Iu+FL3zEj83dk4kAS+fVpTxXLO1b38RvJgT/0QwvV/L3aY9TAnyv0EOqW4GoMQ=="

typescript@4.7.4:
version "4.7.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.4.tgz#1a88596d1cf47d59507a1bcdfb5b9dfe4d488235"
integrity sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==
typescript@4.9.5:
version "4.9.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a"
integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==

yocto-queue@^1.0.0:
version "1.0.0"
Expand Down

0 comments on commit 1e67eae

Please sign in to comment.