-
Notifications
You must be signed in to change notification settings - Fork 385
/
BucketsPage.ts
191 lines (154 loc) · 7.85 KB
/
BucketsPage.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
// Copyright (C) 2023 Storj Labs, Inc.
// See LICENSE for copying information.
import { BucketsPageObjects, BucketsPageObjectsV2 } from '@objects/BucketsPageObjects';
import type { Page } from '@playwright/test';
import { expect } from '@playwright/test';
import { CommonObjectsV2 } from '@objects/CommonObjects';
import { ObjectBrowserPageObjects } from '@objects/ObjectBrowserPageObjects';
export class BucketsPage {
constructor(readonly page: Page) {}
async openBucketByName(name: string): Promise<void> {
await this.page.getByText(name).click();
}
async verifyBucketNotVisible(name: string): Promise<void> {
await expect(this.page.getByText(name)).toBeHidden();
}
async enterPassphrase(phrase: string): Promise<void> {
await this.page.locator(BucketsPageObjects.ENCRYPTION_PASSPHRASE_XPATH).fill(phrase);
}
async clickContinueConfirmPassphrase() {
await this.page.locator(BucketsPageObjects.CONTINUE_BUTTON_PASSPHRASE_MODAL_XPATH).click();
}
async downloadFromPreview(name: string): Promise<void> {
const uiTestFile = this.page.getByText(name, { exact: true }).nth(1);
await expect(uiTestFile).toBeVisible();
await Promise.all([
this.page.waitForEvent('download'),
this.page.locator(BucketsPageObjects.OBJECT_PREVIEW_BUTTON_XPATH).nth(2).click(),
]);
await expect(this.page.getByText('Keep this download link private.If you want to share, use the Share option.')).toBeVisible();
}
async clickShareButton(): Promise<void> {
await this.page.locator(BucketsPageObjects.OBJECT_PREVIEW_BUTTON_XPATH).nth(3).click();
}
async clickCopyLinkButton(): Promise<void> {
await this.page.locator(BucketsPageObjects.COPY_LINK_BUTTON_XPATH).click();
await this.page.locator('span').filter({ hasText: BucketsPageObjects.COPIED_TEXT }).isVisible();
await expect(this.page.getByText('Link copied successfully.')).toBeVisible();
}
async clickCopyButtonShareBucketModal(): Promise<void> {
await this.page.locator('span').filter({ hasText: 'Copy link' }).click();
await this.page.locator('span').filter({ hasText: BucketsPageObjects.COPIED_TEXT }).isVisible();
}
async verifyObjectMapIsVisible(): Promise<void> {
await this.page.locator(BucketsPageObjects.OBJECT_PREVIEW_BUTTON_XPATH).nth(1).click();
await this.page.locator(BucketsPageObjects.OBJECT_MAP_IMAGE_XPATH).isVisible();
}
async verifyImagePreviewIsVisible(): Promise<void> {
await this.page.getByRole('img', { name: 'preview' }).isVisible();
}
async closeFilePreview(): Promise<void> {
await this.page.locator(BucketsPageObjects.OBJECT_PREVIEW_BUTTON_XPATH).nth(4).click();
}
async openFileDropdownByName(name: string): Promise<void> {
const row = await this.page.waitForSelector('*css=tr >> text=' + name);
const button = await row.$('th:nth-child(5)');
await button.click();
}
async clickDeleteFileButton(): Promise<void> {
await this.page.locator(BucketsPageObjects.DELETE_BUTTON_XPATH).click();
}
async clickNewFolderButton(): Promise<void> {
await this.page.getByText(BucketsPageObjects.NEW_FOLDER_BUTTON_TEXT).click();
}
async createNewFolder(name: string): Promise<void> {
await this.clickNewFolderButton();
await this.page.locator(BucketsPageObjects.NEW_FOLDER_NAME_FIELD_XPATH).fill(name);
await this.page.getByText(BucketsPageObjects.CREATE_FOLDER_BUTTON_TEXT).click();
}
async openBucketSettings(): Promise<void> {
await this.page.locator(BucketsPageObjects.BUCKET_SETTINGS_BUTTON_CSS).click();
}
async clickViewBucketDetails(): Promise<void> {
await this.page.locator(BucketsPageObjects.VIEW_BUCKET_DETAILS_BUTTON_CSS).first().click();
}
async deleteFileByName(name: string): Promise<void> {
await this.openFileDropdownByName(name);
await this.clickDeleteFileButton();
await this.page.locator(BucketsPageObjects.YES_BUTTON_XPATH).click();
await this.page.getByText(name).waitFor({ state: 'hidden' });
}
async dragAndDropFile(name: string, format: string): Promise<void> {
await this.page.setInputFiles('input[type=\'file\']', {
name: name,
mimeType: format,
buffer: Buffer.from('Test,T'),
});
}
async dragAndDropFolder(folder: string, filename: string, format: string): Promise<void> {
await this.page.setInputFiles('input[type=\'file\']', {
name: folder + '/' + filename,
mimeType: format,
buffer: Buffer.from('Test,T'),
});
await expect(this.page.getByText(folder)).toBeVisible();
}
async verifyDetails(name: string): Promise<void> {
await this.page.getByRole('cell', { name: name }).isVisible();
}
async clickShareBucketButton(): Promise<void> {
await this.page.locator(BucketsPageObjects.SHARE_BUCKET_BUTTON_XPATH).click();
}
async clickNewBucketButton(): Promise<void> {
await this.page.locator(BucketsPageObjects.NEW_BUCKET_BUTTON_XPATH).nth(0).click();
}
async enterNewBucketName(name: string): Promise<void> {
await this.page.locator(BucketsPageObjects.BUCKET_NAME_INPUT_FIELD_XPATH).fill(name);
}
async clickContinueCreateBucket(): Promise<void> {
await this.page.locator(BucketsPageObjects.CONTINUE_BUTTON_CREATE_BUCKET_FLOW_XPATH).click();
}
async openBucketDropdownByName(name: string): Promise<void> {
const row = await this.page.waitForSelector('*css=tr >> text=' + name);
const button = await row.$('th:nth-child(7)');
await button.click();
}
async clickDeleteBucketButton(): Promise<void> {
await this.page.locator(BucketsPageObjects.DELETE_BUCKET_XPATH).click();
}
async enterBucketNameDeleteBucket(name: string): Promise<void> {
await this.page.locator(BucketsPageObjects.BUCKET_NAME_DELETE_BUCKET_MODAL_XPATH).fill(name);
}
async clickConfirmDeleteButton(): Promise<void> {
await this.page.locator(BucketsPageObjects.CONFIRM_DELETE_BUTTON_XPATH).click();
}
}
export class BucketsPageV2 {
constructor(readonly page: Page) {}
async createBucket(name: string): Promise<void> {
await this.page.locator(BucketsPageObjectsV2.NEW_BUCKET_BUTTON_XPATH).click();
await this.page.locator(BucketsPageObjectsV2.BUCKET_NAME_INPUT_FIELD_XPATH).fill(name);
await this.page.locator(BucketsPageObjectsV2.CONFIRM_BUTTON_CREATE_BUCKET_FLOW_XPATH).click();
}
async openBucketSettings(): Promise<void> {
await this.page.locator(BucketsPageObjectsV2.BUCKET_ROW_MORE_BUTTON_XPATH).click();
}
async verifyBucketDetails(name: string): Promise<void> {
await this.page.locator(BucketsPageObjectsV2.VIEW_BUCKET_DETAILS_BUTTON_XPATH).click();
const elems = await this.page.getByText(name).all();
expect(elems).toHaveLength(2);
}
async verifyShareBucket(): Promise<void> {
await this.page.locator(BucketsPageObjectsV2.SHARE_BUCKET_BUTTON_XPATH).click();
const loader = this.page.locator(ObjectBrowserPageObjects.SHARE_MODAL_LOADER_CLASS);
await expect(loader).toBeHidden();
await this.page.locator(ObjectBrowserPageObjects.COPY_LINK_BUTTON_XPATH).click();
await this.page.locator('span').filter({ hasText: ObjectBrowserPageObjects.COPIED_TEXT }).isVisible();
await this.page.locator(CommonObjectsV2.CLOSE_MODAL_BUTTON_XPATH).click();
}
async verifyDeleteBucket(name: string): Promise<void> {
await this.page.locator(BucketsPageObjectsV2.DELETE_BUCKET_BUTTON_XPATH).click();
await this.page.locator(BucketsPageObjectsV2.CONFIRM_BUTTON_DELETE_BUCKET_FLOW_XPATH).click();
await expect(this.page.getByRole('button', { name: `Bucket ${name}` })).toBeHidden();
}
}