1
- import { appendRandomString } from "commands/common" ;
1
+ import { appendRandomString , submitButtonClick } from "commands/common" ;
2
2
import { createPostgresSource , deleteSource , updateSource } from "commands/source" ;
3
3
import { initialSetupCompleted } from "commands/workspaces" ;
4
+ import { goToSourcePage , openNewSourceForm } from "pages/sourcePage" ;
5
+ import { openHomepage } from "pages/sidebar" ;
6
+ import { selectServiceType } from "pages/createConnectorPage" ;
7
+ import { fillPokeAPIForm } from "commands/connector" ;
4
8
5
9
describe ( "Source main actions" , ( ) => {
6
- beforeEach ( ( ) => {
7
- initialSetupCompleted ( ) ;
8
- } ) ;
10
+ beforeEach ( ( ) => initialSetupCompleted ( ) ) ;
9
11
10
12
it ( "Create new source" , ( ) => {
13
+ cy . intercept ( "/api/v1/sources/create" ) . as ( "createSource" ) ;
11
14
createPostgresSource ( "Test source cypress" ) ;
12
15
13
- cy . url ( ) . should ( "include" , `/source/` ) ;
16
+ cy . wait ( "@createSource" , { timeout : 30000 } ) . then ( ( interception ) => {
17
+ assert ( "include" , `/source/${ interception . response ?. body . Id } ` ) } ) ;
14
18
} ) ;
15
19
16
20
//TODO: add update source on some other connector or create 1 more user for pg
@@ -32,3 +36,60 @@ describe("Source main actions", () => {
32
36
cy . get ( "div" ) . contains ( sourceName ) . should ( "not.exist" ) ;
33
37
} ) ;
34
38
} ) ;
39
+
40
+ describe ( "Unsaved changes modal" , ( ) => {
41
+ beforeEach ( ( ) => initialSetupCompleted ( ) ) ;
42
+
43
+ it ( "Check leaving Source page without any changes" , ( ) => {
44
+ goToSourcePage ( ) ;
45
+ openNewSourceForm ( ) ;
46
+
47
+ openHomepage ( ) ;
48
+
49
+ cy . url ( ) . should ( "include" , "/onboarding" ) ;
50
+ cy . get ( "[data-testid='confirmationModal']" ) . should ( "not.exist" ) ;
51
+ } ) ;
52
+
53
+ it ( "Check leaving Source page without any changes after selection type" , ( ) => {
54
+ goToSourcePage ( ) ;
55
+ openNewSourceForm ( ) ;
56
+ selectServiceType ( "PokeAPI" ) ;
57
+
58
+ openHomepage ( ) ;
59
+
60
+ cy . url ( ) . should ( "include" , "/onboarding" ) ;
61
+ cy . get ( "[data-testid='confirmationModal']" ) . should ( "not.exist" ) ;
62
+ } ) ;
63
+
64
+ it ( "Check leaving Source page without any changes" , ( ) => {
65
+ goToSourcePage ( ) ;
66
+ openNewSourceForm ( ) ;
67
+ fillPokeAPIForm ( "testName" , "ditto" ) ;
68
+
69
+ openHomepage ( ) ;
70
+
71
+ cy . get ( "[data-testid='confirmationModal']" ) . should ( "exist" ) ;
72
+ cy . get ( "[data-testid='confirmationModal']" ) . contains ( "Discard changes" ) ;
73
+ cy . get ( "[data-testid='confirmationModal']" )
74
+ . contains ( "There are unsaved changes. Are you sure you want to discard your changes?" ) ;
75
+ } ) ;
76
+
77
+ //BUG - https://github.com/airbytehq/airbyte/issues/18246
78
+ it . skip ( "Check leaving Source page after failing testing" , ( ) => {
79
+ cy . intercept ( "/api/v1/scheduler/sources/check_connection" ) . as ( "checkSourceUpdateConnection" ) ;
80
+
81
+ goToSourcePage ( ) ;
82
+ openNewSourceForm ( ) ;
83
+ fillPokeAPIForm ( "testName" , "name" ) ;
84
+ submitButtonClick ( ) ;
85
+
86
+ cy . wait ( "@checkSourceUpdateConnection" , { timeout : 5000 } ) ;
87
+
88
+ openHomepage ( ) ;
89
+
90
+ cy . get ( "[data-testid='confirmationModal']" ) . should ( "exist" ) ;
91
+ cy . get ( "[data-testid='confirmationModal']" ) . contains ( "Discard changes" ) ;
92
+ cy . get ( "[data-testid='confirmationModal']" )
93
+ . contains ( "There are unsaved changes. Are you sure you want to discard your changes?" ) ;
94
+ } ) ;
95
+ } ) ;
0 commit comments