@@ -7,7 +7,7 @@ import { CloudRunStubs } from '@packages/graphql/test/stubCloudTypes'
7
7
8
8
describe ( '<DebugContainer />' , ( ) => {
9
9
context ( 'empty states' , ( ) => {
10
- const validateEmptyState = ( expectedMessage : string ) => {
10
+ const validateEmptyState = ( expectedMessages : string [ ] ) => {
11
11
cy . mountFragment ( DebugSpecsFragmentDoc , {
12
12
render : ( gqlVal ) => {
13
13
return (
@@ -18,19 +18,24 @@ describe('<DebugContainer />', () => {
18
18
} ,
19
19
} )
20
20
21
- cy . findByTestId ( 'debug-empty' ) . contains ( expectedMessage )
21
+ expectedMessages . forEach ( ( message ) => {
22
+ cy . findByTestId ( 'debug-empty' ) . contains ( message )
23
+ } )
22
24
}
23
25
24
26
it ( 'shows not logged in' , ( ) => {
25
- validateEmptyState ( defaultMessages . debugPage . notLoggedIn )
27
+ validateEmptyState ( [ defaultMessages . debugPage . emptyStates . connectToCypressCloud , defaultMessages . debugPage . emptyStates . debugDirectlyInCypress , defaultMessages . debugPage . emptyStates . notLoggedInTestMessage ] )
28
+ cy . findByRole ( 'button' , { name : 'Connect to Cypress Cloud' } ) . should ( 'be.visible' )
26
29
} )
27
30
28
- it ( 'is logged in' , ( ) => {
31
+ it ( 'is logged in with no project ' , ( ) => {
29
32
const loginConnectStore = useLoginConnectStore ( )
30
33
31
34
loginConnectStore . setUserFlag ( 'isLoggedIn' , true )
35
+ loginConnectStore . setProjectFlag ( 'isProjectConnected' , false )
32
36
33
- validateEmptyState ( defaultMessages . debugPage . notConnected )
37
+ validateEmptyState ( [ defaultMessages . debugPage . emptyStates . debugDirectlyInCypress , defaultMessages . debugPage . emptyStates . reviewRerunAndDebug , defaultMessages . debugPage . emptyStates . noProjectTestMessage ] )
38
+ cy . findByRole ( 'button' , { name : 'Connect a Cypress Cloud project' } ) . should ( 'be.visible' )
34
39
} )
35
40
36
41
it ( 'has no runs' , ( ) => {
@@ -39,16 +44,24 @@ describe('<DebugContainer />', () => {
39
44
loginConnectStore . setUserFlag ( 'isLoggedIn' , true )
40
45
loginConnectStore . setProjectFlag ( 'isProjectConnected' , true )
41
46
cy . mountFragment ( DebugSpecsFragmentDoc , {
42
- render : ( gqlVal ) => {
43
- return (
44
- < DebugContainer
45
- gql = { gqlVal }
46
- />
47
- )
48
- } ,
47
+ render : ( gqlVal ) => < DebugContainer gql = { gqlVal } /> ,
48
+ } )
49
+
50
+ validateEmptyState ( [ defaultMessages . debugPage . emptyStates . recordYourFirstRun , defaultMessages . debugPage . emptyStates . almostThere , defaultMessages . debugPage . emptyStates . noRunsTestMessage ] )
51
+ cy . findByDisplayValue ( 'npx cypress run --record --key 2aaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' ) . should ( 'be.visible' )
52
+ } )
53
+
54
+ it ( 'errors' , ( ) => {
55
+ const loginConnectStore = useLoginConnectStore ( )
56
+
57
+ loginConnectStore . setUserFlag ( 'isLoggedIn' , true )
58
+ loginConnectStore . setProjectFlag ( 'isProjectConnected' , true )
59
+ cy . mountFragment ( DebugSpecsFragmentDoc , {
60
+ render : ( gqlVal ) => < DebugContainer gql = { gqlVal } showError = { true } /> ,
49
61
} )
50
62
51
- cy . findByTestId ( 'debug-empty' ) . contains ( defaultMessages . debugPage . noRuns )
63
+ cy . findByTestId ( 'debug-empty' ) . should ( 'not.exist' )
64
+ cy . findByTestId ( 'debug-alert' ) . should ( 'be.visible' )
52
65
} )
53
66
} )
54
67
0 commit comments