1
1
// Parsec Cloud (https://parsec.cloud) Copyright (c) BUSL-1.1 2016-present Scille SAS
2
2
3
- import { clientAreaSwitchOrganization , DEFAULT_ORGANIZATION_INFORMATION , expect , msTest } from '@tests/e2e/helpers' ;
3
+ import { clientAreaSwitchOrganization , DEFAULT_ORGANIZATION_INFORMATION , expect , MockBms , msTest } from '@tests/e2e/helpers' ;
4
4
5
5
msTest ( 'Test all orgs' , async ( { clientAreaCustomOrder } ) => {
6
6
const title = clientAreaCustomOrder . locator ( '.header-content' ) . locator ( '.header-title' ) ;
@@ -9,7 +9,13 @@ msTest('Test all orgs', async ({ clientAreaCustomOrder }) => {
9
9
await expect ( title ) . toHaveText ( 'Invoices' ) ;
10
10
const content = clientAreaCustomOrder . locator ( '.client-page-invoices' ) ;
11
11
const invoices = content . locator ( '.invoices-year-content-list-item' ) ;
12
- await expect ( invoices ) . toHaveCount ( 24 ) ;
12
+ await expect ( invoices ) . toHaveCount ( 30 ) ;
13
+ await expect ( content . locator ( '.no-invoices' ) ) . toBeHidden ( ) ;
14
+ for ( const invoice of await invoices . all ( ) ) {
15
+ await expect ( invoice . locator ( '.invoices-organization' ) ) . toHaveText ( / ^ B l a c k M e s a ( - 2 ) ? $ / ) ;
16
+ await expect ( invoice . locator ( '.invoices-amount' ) ) . toHaveText ( / ^ € \d + \. \d { 2 } $ / ) ;
17
+ await expect ( invoice . locator ( '.badge-status' ) ) . toHaveText ( / ^ T o p a y | P a i d | V o i d | I n p r o g r e s s | U n c o l l e c t i b l e $ / ) ;
18
+ }
13
19
} ) ;
14
20
15
21
msTest ( 'Test only one org' , async ( { clientAreaCustomOrder } ) => {
@@ -21,5 +27,111 @@ msTest('Test only one org', async ({ clientAreaCustomOrder }) => {
21
27
await expect ( title ) . toHaveText ( 'Invoices' ) ;
22
28
const content = clientAreaCustomOrder . locator ( '.client-page-invoices' ) ;
23
29
const invoices = content . locator ( '.invoices-year-content-list-item' ) ;
24
- await expect ( invoices ) . toHaveCount ( 12 ) ;
30
+ await expect ( invoices ) . toHaveCount ( 15 ) ;
31
+ await expect ( content . locator ( '.no-invoices' ) ) . toBeHidden ( ) ;
32
+ for ( const invoice of await invoices . all ( ) ) {
33
+ await expect ( invoice . locator ( '.invoices-organization' ) ) . toHaveText ( 'BlackMesa' ) ;
34
+ await expect ( invoice . locator ( '.invoices-amount' ) ) . toHaveText ( / ^ € \d + \. \d { 2 } $ / ) ;
35
+ await expect ( invoice . locator ( '.badge-status' ) ) . toHaveText ( / ^ T o p a y | P a i d | V o i d | I n p r o g r e s s | U n c o l l e c t i b l e $ / ) ;
36
+ }
25
37
} ) ;
38
+
39
+ msTest ( 'Test filter date' , async ( { clientAreaCustomOrder } ) => {
40
+ const title = clientAreaCustomOrder . locator ( '.header-content' ) . locator ( '.header-title' ) ;
41
+
42
+ await clientAreaCustomOrder . locator ( '.menu-client' ) . locator ( '.menu-client-list' ) . getByRole ( 'listitem' ) . nth ( 3 ) . click ( ) ;
43
+ await expect ( title ) . toHaveText ( 'Invoices' ) ;
44
+
45
+ const containers = clientAreaCustomOrder . locator ( '.invoices-year:visible' ) ;
46
+ await expect ( containers ) . toHaveCount ( 2 ) ;
47
+ await expect ( containers . locator ( '.invoices-year-text' ) ) . toHaveText ( [ '2025' , '2024' ] ) ;
48
+
49
+ const yearFilterButton = clientAreaCustomOrder . locator ( '.invoices-header-filter' ) . locator ( '.invoices-header-filter-button' ) . nth ( 0 ) ;
50
+ const monthFilterButton = clientAreaCustomOrder . locator ( '.invoices-header-filter' ) . locator ( '.invoices-header-filter-button' ) . nth ( 1 ) ;
51
+ const popover = clientAreaCustomOrder . locator ( '.time-filter-popover' ) ;
52
+ await expect ( popover ) . toBeHidden ( ) ;
53
+
54
+ await yearFilterButton . click ( ) ;
55
+ await expect ( popover ) . toBeVisible ( ) ;
56
+ await expect ( popover . locator ( '.time-list-item' ) ) . toHaveText ( [ '2025' , '2024' ] ) ;
57
+
58
+ await popover . locator ( '.time-list-item' ) . nth ( 1 ) . click ( ) ;
59
+ await popover . locator ( 'ion-backdrop' ) . click ( ) ;
60
+ await expect ( popover ) . toBeHidden ( ) ;
61
+
62
+ await expect ( containers ) . toHaveCount ( 1 ) ;
63
+ await expect ( containers . locator ( '.invoices-year-text' ) ) . toHaveText ( '2024' ) ;
64
+ await expect ( containers . locator ( '.invoices-year-content-list-item:visible' ) ) . toHaveCount ( 24 ) ;
65
+
66
+ await monthFilterButton . click ( ) ;
67
+ await expect ( popover ) . toBeVisible ( ) ;
68
+ await expect ( popover . locator ( '.time-list-item' ) ) . toHaveText ( [
69
+ 'Jan' ,
70
+ 'Feb' ,
71
+ 'Mar' ,
72
+ 'Apr' ,
73
+ 'May' ,
74
+ 'Jun' ,
75
+ 'Jul' ,
76
+ 'Aug' ,
77
+ 'Sep' ,
78
+ 'Oct' ,
79
+ 'Nov' ,
80
+ 'Dec' ,
81
+ ] ) ;
82
+ await popover . locator ( '.time-list-item' ) . nth ( 1 ) . click ( ) ;
83
+ await popover . locator ( '.time-list-item' ) . nth ( 3 ) . click ( ) ;
84
+ await popover . locator ( '.time-list-item' ) . nth ( 4 ) . click ( ) ;
85
+ await popover . locator ( '.time-list-item' ) . nth ( 10 ) . click ( ) ;
86
+ await popover . locator ( 'ion-backdrop' ) . click ( ) ;
87
+ await expect ( popover ) . toBeHidden ( ) ;
88
+ await expect ( containers . locator ( '.invoices-year-content-list-item:visible' ) ) . toHaveCount ( 8 ) ;
89
+ } ) ;
90
+
91
+ msTest ( 'Test no invoices' , async ( { clientAreaCustomOrder } ) => {
92
+ await MockBms . mockGetCustomOrderInvoices ( clientAreaCustomOrder , { } , { empty : true } ) ;
93
+ const title = clientAreaCustomOrder . locator ( '.header-content' ) . locator ( '.header-title' ) ;
94
+
95
+ await clientAreaCustomOrder . locator ( '.menu-client' ) . locator ( '.menu-client-list' ) . getByRole ( 'listitem' ) . nth ( 3 ) . click ( ) ;
96
+ await expect ( title ) . toHaveText ( 'Invoices' ) ;
97
+ const content = clientAreaCustomOrder . locator ( '.client-page-invoices' ) ;
98
+ await expect ( content . locator ( '.invoices-year-content-list-item' ) ) . toHaveCount ( 0 ) ;
99
+ await expect ( content . locator ( '.no-invoices' ) ) . toBeVisible ( ) ;
100
+ await expect ( content . locator ( '.no-invoices' ) ) . toHaveText ( "You don't have any invoice yet." ) ;
101
+ } ) ;
102
+
103
+ for ( const orgMode of [ 'oneOrg' , 'allOrgs' ] ) {
104
+ msTest ( `List the invoices for ${ orgMode } generic error` , async ( { clientAreaCustomOrder } ) => {
105
+ await MockBms . mockGetCustomOrderInvoices ( clientAreaCustomOrder , { POST : { errors : { status : 400 } } } ) ;
106
+
107
+ if ( orgMode === 'orgOrg' ) {
108
+ await clientAreaSwitchOrganization ( clientAreaCustomOrder , DEFAULT_ORGANIZATION_INFORMATION . name ) ;
109
+ }
110
+
111
+ const title = clientAreaCustomOrder . locator ( '.header-content' ) . locator ( '.header-title' ) ;
112
+ await clientAreaCustomOrder . locator ( '.menu-client' ) . locator ( '.menu-client-list' ) . getByRole ( 'listitem' ) . nth ( 3 ) . click ( ) ;
113
+ await expect ( title ) . toHaveText ( 'Invoices' ) ;
114
+ const content = clientAreaCustomOrder . locator ( '.client-page-invoices' ) ;
115
+ await expect ( content . locator ( '.no-invoices' ) ) . toBeHidden ( ) ;
116
+ await expect ( content . locator ( '.invoices-year-content-list-item' ) ) . toHaveCount ( 0 ) ;
117
+ await expect ( clientAreaCustomOrder . locator ( '.main-content' ) . locator ( '.form-error' ) ) . toHaveText ( 'Could not retrieve your invoices.' ) ;
118
+ await expect ( clientAreaCustomOrder . locator ( '.main-content' ) . locator ( '.no-invoices' ) ) . toBeHidden ( ) ;
119
+ } ) ;
120
+
121
+ msTest ( `List the invoices for ${ orgMode } timeout` , async ( { clientAreaCustomOrder } ) => {
122
+ await MockBms . mockGetCustomOrderInvoices ( clientAreaCustomOrder , { POST : { timeout : true } } ) ;
123
+
124
+ if ( orgMode === 'orgOrg' ) {
125
+ await clientAreaSwitchOrganization ( clientAreaCustomOrder , DEFAULT_ORGANIZATION_INFORMATION . name ) ;
126
+ }
127
+
128
+ const title = clientAreaCustomOrder . locator ( '.header-content' ) . locator ( '.header-title' ) ;
129
+ await clientAreaCustomOrder . locator ( '.menu-client' ) . locator ( '.menu-client-list' ) . getByRole ( 'listitem' ) . nth ( 3 ) . click ( ) ;
130
+ await expect ( title ) . toHaveText ( 'Invoices' ) ;
131
+ const content = clientAreaCustomOrder . locator ( '.client-page-invoices' ) ;
132
+ await expect ( content . locator ( '.no-invoices' ) ) . toBeHidden ( ) ;
133
+ await expect ( content . locator ( '.invoices-year-content-list-item' ) ) . toHaveCount ( 0 ) ;
134
+ await expect ( clientAreaCustomOrder . locator ( '.main-content' ) . locator ( '.form-error' ) ) . toHaveText ( 'Could not retrieve your invoices.' ) ;
135
+ await expect ( clientAreaCustomOrder . locator ( '.main-content' ) . locator ( '.no-invoices' ) ) . toBeHidden ( ) ;
136
+ } ) ;
137
+ }
0 commit comments