fix(app): only load specs for current testingType (#18431)

* update server

* add launchMode param

* update logic

* update types

* update gql

* basic WIP for e2e

* revert un-necessary changes

* do not rely on wizard for launchProject action

* move launchMode to app

* make specs field return based on activeTestingType

* update type

* types
This commit is contained in:
Lachlan Miller
2021-10-12 14:40:12 +10:00
committed by GitHub
parent 7f6a64d789
commit 11d07d720b
8 changed files with 29 additions and 15 deletions
@@ -11,7 +11,7 @@ describe('App', () => {
skipPluginIntializeForTesting: true,
})
await ctx.actions.project.launchProject({
await ctx.actions.project.launchProject('e2e', {
skipBrowserOpenForTest: true,
})
@@ -62,7 +62,5 @@ describe('<SpecsList />', { keystrokeDelay: 0 }, () => {
.should('contain.text', specs[0].node.fileName)
.and('contain.text', specs[0].node.fileExtension)
.click()
.url()
.should('contain', fullFile(specs[0]))
})
})
@@ -1,4 +1,4 @@
import type { MutationAddProjectArgs, MutationAppCreateConfigFileArgs } from '@packages/graphql/src/gen/nxs.gen'
import type { MutationAddProjectArgs, MutationAppCreateConfigFileArgs, TestingTypeEnum } from '@packages/graphql/src/gen/nxs.gen'
import type { FindSpecs, FoundBrowser, FoundSpec, FullConfig, LaunchArgs, LaunchOpts, OpenProjectLaunchOptions } from '@packages/types'
import path from 'path'
import type { ProjectShape } from '../data/coreDataShape'
@@ -134,7 +134,11 @@ export class ProjectActions {
}
}
async launchProject (options: LaunchOpts = {}) {
async launchProject (testingType: TestingTypeEnum, options: LaunchOpts) {
if (!this.ctx.activeProject) {
return null
}
const browser = this.ctx.wizardData.chosenBrowser ?? this.ctx.appData.browsers?.[0]
if (!browser) {
@@ -145,9 +149,11 @@ export class ProjectActions {
name: '',
absolute: '',
relative: '',
specType: this.ctx.wizardData.chosenTestingType === 'e2e' ? 'integration' : 'component',
specType: testingType === 'e2e' ? 'integration' : 'component',
}
this.ctx.appData.activeTestingType = testingType
return this.api.launchProject(browser, spec, options)
}
@@ -1,5 +1,5 @@
import { BUNDLERS, FoundBrowser, FoundSpec, ResolvedFromConfig, StorybookFile } from '@packages/types'
import type { NexusGenEnums } from '@packages/graphql/src/gen/nxs.gen'
import type { NexusGenEnums, TestingTypeEnum } from '@packages/graphql/src/gen/nxs.gen'
export type Maybe<T> = T | null | undefined
@@ -34,6 +34,7 @@ export interface AppDataShape {
projects: ProjectShape[]
activeProject: ActiveProjectShape | null
isInGlobalMode: boolean
activeTestingType: Maybe<TestingTypeEnum>
}
export interface WizardDataShape {
@@ -64,6 +65,7 @@ export function makeCoreData (): CoreDataShape {
refreshState: null,
},
app: {
activeTestingType: null,
navItem: 'settings',
browsers: null,
projects: [],
+3 -1
View File
@@ -7,6 +7,9 @@ type App {
"""Active project"""
activeProject: Project
"""The mode the interactive runner was launched in"""
activeTestingType: TestingTypeEnum
"""Browsers found that are compatible with Cypress"""
browsers: [Browser!]
@@ -458,7 +461,6 @@ type Project implements Node {
"""Returns the last n elements from the list."""
last: Int
specType: SpecType
): SpecConnection
title: String!
}
@@ -29,6 +29,11 @@ export const App = objectType({
resolve: () => 'OK',
})
t.field('activeTestingType', {
description: 'The mode the interactive runner was launched in',
type: 'TestingTypeEnum',
})
t.nonNull.boolean('isInGlobalMode', {
description: 'Whether the app is in global mode or not',
resolve: (source, args, ctx) => {
@@ -217,7 +217,11 @@ export const mutation = mutationType({
type: 'App',
description: 'Launches project from open_project global singleton',
async resolve (_root, args, ctx) {
await ctx.actions.project.launchProject()
if (!ctx.wizardData.chosenTestingType) {
throw Error('Cannot launch project without chosen testing type')
}
await ctx.actions.project.launchProject(ctx.wizardData.chosenTestingType, {})
return ctx.appData
},
@@ -1,6 +1,5 @@
import { arg, objectType } from 'nexus'
import { objectType } from 'nexus'
import { cloudProjectBySlug } from '../../stitching/remoteGraphQLCalls'
import { SpecTypeEnum } from '../enumTypes'
export interface ProjectShape {
projectId?: string | null
@@ -28,6 +27,7 @@ export const Project = objectType({
})
t.nonNull.string('projectRoot')
t.nonNull.string('title', {
resolve: (source, args, ctx) => ctx.project.projectTitle(source.projectRoot),
})
@@ -61,11 +61,8 @@ export const Project = objectType({
t.connectionField('specs', {
description: 'Specs for a project conforming to Relay Connection specification',
type: 'Spec',
additionalArgs: {
specType: arg({ type: SpecTypeEnum }),
},
nodes: (source, args, ctx) => {
return ctx.project.findSpecs(source.projectRoot, args.specType)
return ctx.project.findSpecs(source.projectRoot, ctx.appData.activeTestingType === 'component' ? 'component' : 'integration')
},
})