diff --git a/packages/data-context/src/actions/AppActions.ts b/packages/data-context/src/actions/AppActions.ts index 630fb0baa145..41105f211c7a 100644 --- a/packages/data-context/src/actions/AppActions.ts +++ b/packages/data-context/src/actions/AppActions.ts @@ -48,7 +48,10 @@ export class AppActions { let browser try { - browser = (await this.ctx._apis.appApi.ensureAndGetByNameOrPath(browserNameOrPath)) as FoundBrowser | undefined + await this.ctx.coreData.app.refreshingBrowsers + const foundBrowsers = this.ctx.coreData.app.browsers ? [...this.ctx.coreData.app.browsers] : undefined + + browser = (await this.ctx._apis.appApi.ensureAndGetByNameOrPath(browserNameOrPath, false, foundBrowsers)) as FoundBrowser | undefined } catch (err: unknown?) { this.ctx.debug('Error getting browser by name or path (%s): %s', browserNameOrPath, err?.stack || err) const message = err.details ? `${err.message}\n\n\`\`\`\n${err.details}\n\`\`\`` : err.message diff --git a/packages/frontend-shared/cypress/e2e/support/e2eSupport.ts b/packages/frontend-shared/cypress/e2e/support/e2eSupport.ts index 78e4ac8df25a..b3dc99744c3b 100644 --- a/packages/frontend-shared/cypress/e2e/support/e2eSupport.ts +++ b/packages/frontend-shared/cypress/e2e/support/e2eSupport.ts @@ -39,9 +39,17 @@ export interface RemoteGraphQLInterceptPayload { export type RemoteGraphQLInterceptor = (obj: RemoteGraphQLInterceptPayload) => ExecutionResult | Promise -export interface SetFoundBrowsersOptions { - filter?(browser: Browser): boolean +export interface FindBrowsersOptions { + // Array of FoundBrowser objects that will be used as the mock output browsers?: FoundBrowser[] + /** + * Function used to filter the standard set of mocked browsers. Ignored if browsers option is provided. + * Ex. + * cy.findBrowsers({ + * filter: (browser) => browser.name === 'chrome' // Sets Chrome, Chrome Beta, Canary + * }) + */ + filter?(browser: Browser): boolean } declare global { @@ -100,7 +108,10 @@ declare global { disableRemoteGraphQLFakes(): void visitApp(href?: string): Chainable visitLaunchpad(href?: string): Chainable - findBrowsers(options?: SetFoundBrowsersOptions): void + /** + * Mocks the system browser retrieval to return the desired browsers + */ + findBrowsers(options?: FindBrowsersOptions): void } } } @@ -253,7 +264,7 @@ function loginUser (userShape: Partial = {}) { }) } -function findBrowsers (options: SetFoundBrowsersOptions = {}) { +function findBrowsers (options: FindBrowsersOptions = {}) { let filteredBrowsers = options.browsers if (!filteredBrowsers) { @@ -281,7 +292,7 @@ function findBrowsers (options: SetFoundBrowsersOptions = {}) { } cy.withCtx(async (ctx, o) => { - // @ts-ignore sinon is a global in the node process where this is executed + // @ts-ignore sinon is a global in the process where this is executed sinon.stub(ctx._apis.appApi, 'getBrowsers').resolves(o.browsers) }, { browsers: filteredBrowsers }) } diff --git a/packages/frontend-shared/src/components/Alert.spec.tsx b/packages/frontend-shared/src/components/Alert.spec.tsx index 577e1a0ed733..271978f2a45b 100644 --- a/packages/frontend-shared/src/components/Alert.spec.tsx +++ b/packages/frontend-shared/src/components/Alert.spec.tsx @@ -7,14 +7,14 @@ import { ref } from 'vue' const messages = defaultMessages.components.alert -const alertBodySelector = '[data-testid=alert-body]' -const alertHeaderSelector = '[data-testid=alert-header]' +const alertBodySelector = '[data-cy=alert-body]' +const alertHeaderSelector = '[data-cy=alert-header]' -const suffixIconSelector = '[data-testid=alert-suffix-icon]' -const prefixIconSelector = '[data-testid=alert-prefix-icon]' +const suffixIconSelector = '[data-cy=alert-suffix-icon]' +const prefixIconSelector = '[data-cy=alert-prefix-icon]' // This divider should eventually be tested inside of a visual regression test. -const dividerLineSelector = '[data-testid=alert-body-divider]' +const dividerLineSelector = '[data-cy=alert-body-divider]' const dismissSelector = `[aria-label=${messages.dismissAriaLabel}]` const alertTitle = faker.hacker.phrase() @@ -31,8 +31,8 @@ const makeDismissibleProps = () => { return { modelValue, methods } } -const prefixIcon = () => -const suffixIcon = () => +const prefixIcon = () => +const suffixIcon = () => describe('', () => { describe('classes', () => { @@ -49,23 +49,23 @@ describe('', () => { it('renders the prefixIcon slot', () => { cy.mount(() => ) - .get('[data-testid=coffee-icon]').should('be.visible') + .get('[data-cy=coffee-icon]').should('be.visible') }) it('renders the prefixIcon slot even when an icon is passed in', () => { cy.mount(() => ( } + icon={() => } />)) - .get('[data-testid=coffee-icon]').should('be.visible') - .get('[data-testid=loading-icon]').should('not.exist') + .get('[data-cy=coffee-icon]').should('be.visible') + .get('[data-cy=loading-icon]').should('not.exist') }) }) describe('suffix', () => { it('renders the suffixIcon slot', () => { cy.mount(() => ) - .get('[data-testid=loading-icon]').should('be.visible') + .get('[data-cy=loading-icon]').should('be.visible') }) }) @@ -74,12 +74,12 @@ describe('', () => { cy.mount(() => (
-

{ faker.lorem.paragraphs(5) }

+

{ faker.lorem.paragraphs(5) }

)) - cy.get('[data-testid=body-content]').should('be.visible') + cy.get('[data-cy=body-content]').should('be.visible') }) }) @@ -90,19 +90,19 @@ describe('', () => { cy.mount(() => (
-

{ faker.lorem.paragraphs(5) }

+

{ faker.lorem.paragraphs(5) }

)) - cy.get('[data-testid=body-content]').should('be.visible') + cy.get('[data-cy=body-content]').should('be.visible') }) it('cannot be collapsed', () => { const { modelValue, methods } = makeDismissibleProps() cy.mount(() => ( -

{ faker.lorem.paragraphs(5) }

+

{ faker.lorem.paragraphs(5) }

)) .get(alertBodySelector).should('be.visible') .get(alertHeaderSelector).click() diff --git a/packages/frontend-shared/src/components/Alert.vue b/packages/frontend-shared/src/components/Alert.vue index a0275125cf7a..a660f94f1c7a 100644 --- a/packages/frontend-shared/src/components/Alert.vue +++ b/packages/frontend-shared/src/components/Alert.vue @@ -13,7 +13,7 @@ >