@@ -36,69 +36,69 @@ const files = readFileIntoArray(FILE_NAME).filter((name) => skipfiles.indexOf(na
36
36
const testCount = Math . ceil ( files . length / CSAE_CI_JOB_COUNT ) ;
37
37
38
38
for ( let i = 0 ; i < testCount ; i ++ ) {
39
+
39
40
const idx = i * CSAE_CI_JOB_COUNT + CSAE_CI_JOB_IDX ;
40
41
if ( idx >= files . length ) {
41
42
break ;
42
43
}
43
-
44
44
const name = files [ idx ] ;
45
45
if ( name === '' ) {
46
46
continue ;
47
47
}
48
+
48
49
test ( `test ${ i } : ${ name } ` , async ( { page} , testInfo ) => {
49
50
test . setTimeout ( 10800000 ) ;
50
51
51
52
// Create Env or get existing Env
52
53
const env = await envPool . getEnv ( testInfo . parallelIndex ) ;
53
-
54
- await sleep ( 5000 ) ;
55
54
console . log ( 'url:' + env . getJuypterUrl ( name . substring ( 3 ) ) ) ;
56
-
57
55
await page . goto ( env . getJuypterUrl ( name . substring ( 3 ) ) ) ;
58
56
59
57
await page . waitForLoadState ( ) ;
60
58
61
- // Wait for content to appear before moving on. Jupyter is slow to load (Done) (Hack job)
62
- await page . locator ( 'span[class="f1235lqo"]' ) . getByText ( '| Idle' ) . waitFor ( { timeout : 300000 } )
63
-
64
- const data = JSON . parse ( fs . readFileSync ( name , 'utf8' ) ) ;
65
- console . log ( 'data: ' + data . metadata . kernelspec . language ) ;
59
+ const juypterNotebookData = JSON . parse ( fs . readFileSync ( name , 'utf8' ) ) ;
66
60
67
61
let strKernelType = '' ;
68
- if ( data . metadata . kernelspec . language === 'python' ) {
62
+ if ( juypterNotebookData . metadata . kernelspec . language === 'python' ) {
69
63
console . log ( 'Python Notebook' ) ;
70
64
strKernelType = "Python 3 (ipykernel) " ;
71
65
}
72
- else if ( data . metadata . kernelspec . language === 'Teradata SQL' ) {
66
+ else if ( juypterNotebookData . metadata . kernelspec . language === 'Teradata SQL' ) {
73
67
console . log ( 'Teradata SQL Notebook' ) ;
74
68
strKernelType = 'Teradata SQL ' ;
75
- } else if ( data . metadata . kernelspec . language === 'R' ) {
69
+ } else if ( juypterNotebookData . metadata . kernelspec . language === 'R' ) {
76
70
console . log ( 'R Notebook' ) ;
77
71
strKernelType = 'R ' ;
78
72
}
79
73
80
74
console . log ( 'Kernel Type: ' + strKernelType ) ;
81
75
expect ( strKernelType ) . not . toBe ( '' ) ;
76
+
82
77
await page . locator ( 'span[class="f1235lqo"] >> text="' + strKernelType + '| Idle"' ) . waitFor ( { timeout : 600000 } ) ;
83
78
84
79
//Get the number of cells in the notebook
85
80
const jpCells = await page . locator ( 'div.jp-NotebookPanel:not(.p-mod-hidden)> div > div.jp-Cell' ) ;
86
81
await jpCells . first ( ) . waitFor ( { timeout : 300000 } ) ;
87
82
console . log ( 'jpCells: ' + await jpCells . count ( ) ) ;
88
83
89
- var dm = await jpCells . count ( ) ; // Default Number of iterations for each Notebook demo
90
-
84
+ var dm = await juypterNotebookData . cells . length ; // Default Number of iterations for each Notebook demo
85
+
86
+ //Clicking to activate the note book
91
87
jpCells . first ( ) . click ( ) ;
88
+
92
89
for ( let i = 0 ; i < dm ; i ++ ) {
93
- await sleep ( 100 ) ;
90
+ //Check for any errors so far
94
91
expect ( await page . locator ( ".jp-RenderedText[data-mime-type='application/vnd.jupyter.stderr']" ) ) . toHaveCount ( 0 ) ;
95
- await page . locator ( 'span[class="f1235lqo"] >> text="' + strKernelType + '| Idle"' ) . waitFor ( { timeout : 600000 } ) ;
96
- if ( await page . locator ( 'span[class="f1235lqo"] >> text="' + strKernelType + '| Idle"' ) . isVisible ( ) )
92
+
93
+ // To continute the notebook the kernel should be in Idle state. i.e previous cell execution should be completed.
94
+ // await page.locator('span[class="f1235lqo"] >> text="'+strKernelType+'| Idle"').waitFor({timeout: 600000});
95
+ if ( await page . locator ( 'span[class="f1235lqo"] >> text="' + strKernelType + '| Idle"' ) . isVisible ( { timeout : 600000 } ) )
97
96
{
98
- // Go to next step by clicking Shift+Enter
97
+ // Go to next step by clicking the Run button
99
98
await page . getByRole ( 'button' , { name : 'Run the selected cells and' } ) . click ( ) ;
100
-
101
- }
99
+ }
100
+
101
+ // Wait to see if the kernel is started because of the cell execution (some cell does not have execution like text).
102
102
try {
103
103
await page . locator ( 'span[class="f1235lqo"] >> text="' + strKernelType + '| Busy"' ) . waitFor ( { timeout : 2000 } ) ;
104
104
expect
@@ -108,18 +108,14 @@ for (let i = 0; i < testCount; i++) {
108
108
109
109
if ( await page . locator ( 'span[class="f1235lqo"] >> text="' + strKernelType + '| Busy"' ) . isVisible ( ) )
110
110
{
111
- // Check if wating for Password Prompt
112
- await sleep ( 1000 ) ; // Wait one sec... It's slow to load
113
- //if (await page.locator('pre', { hasText: 'Enter password:'}).isVisible())
114
111
const passwordField = await page . locator ( 'pre[class="jp-Stdin-prompt"]' , { hasText : 'password' } )
115
- if ( await passwordField . isVisible ( ) )
112
+ if ( await passwordField . isVisible ( { timeout : 1000 } ) )
116
113
{
117
114
await page . fill ( 'input[class="jp-Stdin-input"]' , CSAE_ENV_PASSWORD ) ;
118
115
await page . locator ( 'input[class="jp-Stdin-input"]' ) . click ( ) ;
119
116
await page . keyboard . press ( 'Enter' ) ;
120
117
}
121
118
}
122
-
123
119
}
124
120
} ) ;
125
121
}
0 commit comments