Skip to content

Commit 58715ef

Browse files
committed
Fix tests and linter
1 parent 7cd15ba commit 58715ef

File tree

8 files changed

+73
-50
lines changed

8 files changed

+73
-50
lines changed

context-menu/ui-tests/tests/context-menu.spec.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@ test('should have new context menu for example files', async ({ page }) => {
1515

1616
// Click li[role="menuitem"]:has-text("File")
1717
await page.click('li[role="menuitem"]:has-text("File")');
18-
1918
// Click ul[role="menu"] >> text=New
2019
await page.click('ul[role="menu"] >> text=New');
21-
2220
// Click #jp-mainmenu-file-new >> text=Text File
2321
await page.click('#jp-mainmenu-file-new >> text=Text File');
2422

@@ -36,6 +34,15 @@ test('should have new context menu for example files', async ({ page }) => {
3634
// Press Enter
3735
await page.press('input.jp-DirListing-editor', 'Enter');
3836

37+
// Wait for the data attribute to be set
38+
let type = '';
39+
do {
40+
type = await page.getAttribute(
41+
'[aria-label="File Browser Section"] >> text=test.example',
42+
'data-file-type'
43+
);
44+
} while (!type);
45+
3946
// Click [aria-label="File Browser Section"] >> text=test.example
4047
await page.click('[aria-label="File Browser Section"] >> text=test.example', {
4148
button: 'right',

documents/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,4 @@
8585
"outputDir": "jupyterlab_examples_documents/labextension"
8686
},
8787
"styleModule": "style/index.js"
88-
}
88+
}

documents/src/factory.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class ExampleWidgetFactory extends ABCWidgetFactory<
1818
/**
1919
* Constructor of ExampleWidgetFactory.
2020
*
21-
* @param options
21+
* @param options Constructor options
2222
*/
2323
constructor(options: DocumentRegistry.IWidgetFactoryOptions) {
2424
super(options);
@@ -27,8 +27,8 @@ export class ExampleWidgetFactory extends ABCWidgetFactory<
2727
/**
2828
* Create a new widget given a context.
2929
*
30-
* @param context: Contains the information of the file
31-
* @param context
30+
* @param context Contains the information of the file
31+
* @returns The widget
3232
*/
3333
protected createNewWidget(
3434
context: DocumentRegistry.IContext<ExampleDocModel>
@@ -48,27 +48,35 @@ export class ExampleDocModelFactory
4848
{
4949
/**
5050
* The name of the model.
51+
*
52+
* @returns The name
5153
*/
5254
get name(): string {
5355
return 'example-model';
5456
}
5557

5658
/**
5759
* The content type of the file.
60+
*
61+
* @returns The content type
5862
*/
5963
get contentType(): Contents.ContentType {
6064
return 'file';
6165
}
6266

6367
/**
6468
* The format of the file.
69+
*
70+
* @returns the file format
6571
*/
6672
get fileFormat(): Contents.FileFormat {
6773
return 'text';
6874
}
6975

7076
/**
7177
* Get whether the model factory has been disposed.
78+
*
79+
* @returns disposed status
7280
*/
7381
get isDisposed(): boolean {
7482
return this._disposed;
@@ -84,8 +92,8 @@ export class ExampleDocModelFactory
8492
/**
8593
* Get the preferred language given the path on the file.
8694
*
87-
* @param path: path of the file represented by this document model
88-
* @param path
95+
* @param path path of the file represented by this document model
96+
* @returns The preferred language
8997
*/
9098
preferredLanguage(path: string): string {
9199
return '';
@@ -94,8 +102,9 @@ export class ExampleDocModelFactory
94102
/**
95103
* Create a new instance of ExampleDocModel.
96104
*
97-
* @param languagePreference
98-
* @param modelDB
105+
* @param languagePreference Language
106+
* @param modelDB Model database
107+
* @returns The model
99108
*/
100109
createNew(languagePreference?: string, modelDB?: IModelDB): ExampleDocModel {
101110
return new ExampleDocModel(languagePreference, modelDB);

documents/src/model.ts

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ export class ExampleDocModel implements DocumentRegistry.IModel {
3030
/**
3131
* Construct a new ExampleDocModel.
3232
*
33-
* @param languagePreference
34-
* @param modelDB
33+
* @param languagePreference Language
34+
* @param modelDB Document model database
3535
*/
3636
constructor(languagePreference?: string, modelDB?: IModelDB) {
3737
this.modelDB = modelDB || new ModelDB();
@@ -44,6 +44,8 @@ export class ExampleDocModel implements DocumentRegistry.IModel {
4444
/**
4545
* get/set the dirty attribute to know when the
4646
* content in the document differs from disk
47+
*
48+
* @returns dirty attribute
4749
*/
4850
get dirty(): boolean {
4951
return this._dirty;
@@ -55,6 +57,8 @@ export class ExampleDocModel implements DocumentRegistry.IModel {
5557
/**
5658
* get/set the readOnly attribute to know whether this model
5759
* is read only or not
60+
*
61+
* @returns readOnly attribute
5862
*/
5963
get readOnly(): boolean {
6064
return this._readOnly;
@@ -66,6 +70,8 @@ export class ExampleDocModel implements DocumentRegistry.IModel {
6670
/**
6771
* get the isDisposed attribute to know whether this model
6872
* has been disposed or not
73+
*
74+
* @returns Model status
6975
*/
7076
get isDisposed(): boolean {
7177
return this._isDisposed;
@@ -77,6 +83,8 @@ export class ExampleDocModel implements DocumentRegistry.IModel {
7783
*
7884
* NOTE: The content refers to de data stored in the model while the state refers
7985
* to the metadata or attributes of the model.
86+
*
87+
* @returns The signal
8088
*/
8189
get contentChanged(): ISignal<this, void> {
8290
return this._contentChanged;
@@ -88,6 +96,8 @@ export class ExampleDocModel implements DocumentRegistry.IModel {
8896
*
8997
* NOTE: The content refers to de data stored in the model while the state refers
9098
* to the metadata or attributes of the model.
99+
*
100+
* @returns The signal
91101
*/
92102
get stateChanged(): ISignal<this, IChangedArgs<any, any, string>> {
93103
return this._stateChanged;
@@ -96,6 +106,8 @@ export class ExampleDocModel implements DocumentRegistry.IModel {
96106
/**
97107
* get the signal sharedModelChanged to listen for changes on the content
98108
* of the shared model.
109+
*
110+
* @returns The signal
99111
*/
100112
get sharedModelChanged(): ISignal<this, ExampleDocChange> {
101113
return this._sharedModelChanged;
@@ -104,6 +116,8 @@ export class ExampleDocModel implements DocumentRegistry.IModel {
104116
/**
105117
* get the signal clientChanged to listen for changes on the clients sharing
106118
* the same document.
119+
*
120+
* @returns The signal
107121
*/
108122
get clientChanged(): ISignal<this, Map<number, any>> {
109123
return this._clientChanged;
@@ -144,6 +158,8 @@ export class ExampleDocModel implements DocumentRegistry.IModel {
144158
* Should return the data that you need to store in disk as a string.
145159
* The context will call this method to get the file's content and save it
146160
* to disk
161+
*
162+
* @returns The data
147163
*/
148164
toString(): string {
149165
const pos = this.sharedModel.getContent('position');
@@ -160,7 +176,7 @@ export class ExampleDocModel implements DocumentRegistry.IModel {
160176
* This method should implement the logic to parse the data and store it
161177
* on the datastore.
162178
*
163-
* @param data
179+
* @param data Serialized data
164180
*/
165181
fromString(data: string): void {
166182
const obj = JSON.parse(data);
@@ -177,6 +193,8 @@ export class ExampleDocModel implements DocumentRegistry.IModel {
177193
*
178194
* NOTE: This method is only used by the context of the notebook, every other
179195
* document will load/save the data through toString/fromString.
196+
*
197+
* @returns Model JSON representation
180198
*/
181199
toJSON(): PartialJSONObject {
182200
const pos = this.sharedModel.getContent('position');
@@ -196,7 +214,7 @@ export class ExampleDocModel implements DocumentRegistry.IModel {
196214
* NOTE: This method is only used by the context of the notebook, every other
197215
* document will load/save the data through toString/fromString.
198216
*
199-
* @param data
217+
* @param data Serialized model
200218
*/
201219
fromJSON(data: PartialJSONObject): void {
202220
this.sharedModel.transact(() => {
@@ -236,7 +254,7 @@ export class ExampleDocModel implements DocumentRegistry.IModel {
236254
/**
237255
* Sets the position of the SharedObject
238256
*
239-
* @param pos
257+
* @param pos Position
240258
*/
241259
setPosition(pos: Position): void {
242260
this.sharedModel.setContent('position', pos);
@@ -245,7 +263,7 @@ export class ExampleDocModel implements DocumentRegistry.IModel {
245263
/**
246264
* Sets the text inside the SharedObject
247265
*
248-
* @param content
266+
* @param content Text
249267
*/
250268
setContent(content: string): void {
251269
this.sharedModel.setContent('content', content);
@@ -254,7 +272,7 @@ export class ExampleDocModel implements DocumentRegistry.IModel {
254272
/**
255273
* Sets the mouse's position of the client
256274
*
257-
* @param pos
275+
* @param pos Mouse position
258276
*/
259277
setClient(pos: Position): void {
260278
// Adds the position of the mouse from the client to the shared state.
@@ -265,10 +283,8 @@ export class ExampleDocModel implements DocumentRegistry.IModel {
265283
* Callback to listen for changes on the sharedModel. This callback listens
266284
* to changes on shared model's content and propagates them to the DocumentWidget.
267285
*
268-
* @param sender: The sharedModel that triggers the changes.
269-
* @param change: The changes on the sharedModel.
270-
* @param sender
271-
* @param changes
286+
* @param sender The sharedModel that triggers the changes.
287+
* @param changes The changes on the sharedModel.
272288
*/
273289
private _onSharedModelChanged = (
274290
sender: ExampleDoc,
@@ -281,9 +297,6 @@ export class ExampleDocModel implements DocumentRegistry.IModel {
281297
* Callback to listen for changes on the sharedModel. This callback listens
282298
* to changes on the different clients sharing the document and propagates
283299
* them to the DocumentWidget.
284-
*
285-
* @param sender: The sharedModel that triggers the changes.
286-
* @param clients: The list of client's states.
287300
*/
288301
private _onClientChanged = () => {
289302
const clients = this.sharedModel.awareness.getStates();
@@ -337,6 +350,8 @@ export class ExampleDoc extends YDocument<ExampleDocChange> {
337350

338351
/**
339352
* Static method to create instances on the sharedModel
353+
*
354+
* @returns The sharedModel instance
340355
*/
341356
public static create(): ExampleDoc {
342357
return new ExampleDoc();
@@ -345,8 +360,8 @@ export class ExampleDoc extends YDocument<ExampleDocChange> {
345360
/**
346361
* Returns an the requested object.
347362
*
348-
* @param key: The key of the object.
349-
* @param key
363+
* @param key The key of the object.
364+
* @returns The content
350365
*/
351366
public getContent(key: string): any {
352367
return this._content.get(key);
@@ -355,10 +370,8 @@ export class ExampleDoc extends YDocument<ExampleDocChange> {
355370
/**
356371
* Adds new data.
357372
*
358-
* @param key: The key of the object.
359-
* @param value: New object.
360-
* @param key
361-
* @param value
373+
* @param key The key of the object.
374+
* @param value New object.
362375
*/
363376
public setContent(key: string, value: any): void {
364377
this._content.set(key, value);
@@ -367,7 +380,7 @@ export class ExampleDoc extends YDocument<ExampleDocChange> {
367380
/**
368381
* Handle a change.
369382
*
370-
* @param event
383+
* @param event Model event
371384
*/
372385
private _contentObserver = (event: Y.YMapEvent<any>): void => {
373386
const changes: ExampleDocChange = {};

documents/src/widget.tsx

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export class ExamplePanel extends Widget {
9696
/**
9797
* Handle `after-attach` messages sent to the widget.
9898
*
99-
* @param msg
99+
* @param msg Widget layout message
100100
*/
101101
protected onAfterAttach(msg: Message): void {
102102
super.onAfterAttach(msg);
@@ -110,7 +110,7 @@ export class ExamplePanel extends Widget {
110110
/**
111111
* Handle `before-detach` messages sent to the widget.
112112
*
113-
* @param msg
113+
* @param msg Widget layout message
114114
*/
115115
protected onBeforeDetach(msg: Message): void {
116116
super.onBeforeDetach(msg);
@@ -124,7 +124,7 @@ export class ExamplePanel extends Widget {
124124
/**
125125
* Handle event messages sent to the widget.
126126
*
127-
* @param event
127+
* @param event Event on the widget
128128
*/
129129
public handleEvent(event: MouseEvent): void {
130130
event.preventDefault();
@@ -176,10 +176,8 @@ export class ExamplePanel extends Widget {
176176
* Callback to listen for changes on the model. This callback listens
177177
* to changes on shared model's content.
178178
*
179-
* @param sender: The DocumentModel that triggers the changes.
180-
* @param change: The changes on the model
181-
* @param sender
182-
* @param change
179+
* @param sender The DocumentModel that triggers the changes.
180+
* @param change The changes on the model
183181
*/
184182
private _onContentChanged = (
185183
sender: ExampleDocModel,
@@ -198,10 +196,8 @@ export class ExamplePanel extends Widget {
198196
* Callback to listen for changes on the model. This callback listens
199197
* to changes on the different clients sharing the document.
200198
*
201-
* @param sender: The DocumentModel that triggers the changes.
202-
* @param clients: The list of client's states.
203-
* @param sender
204-
* @param clients
199+
* @param sender The DocumentModel that triggers the changes.
200+
* @param clients The list of client's states.
205201
*/
206202
private _onClientChanged = (
207203
sender: ExampleDocModel,

documents/ui-tests/tests/documents.spec.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ test('should check if the cube is loaded', async ({ page }) => {
99

1010
// Click text=File
1111
await page.click('text=File');
12-
1312
// Click ul[role="menu"] >> text=New
1413
await page.click('ul[role="menu"] >> text=New');
15-
1614
// Click #jp-mainmenu-file-new >> text=Text File
1715
page.click('#jp-mainmenu-file-new >> text=Text File');
1816

@@ -28,10 +26,10 @@ test('should check if the cube is loaded', async ({ page }) => {
2826
// Press s with modifiers
2927
await page.keyboard.press('Control+s');
3028

31-
// Click div[role="main"] >> text=Launcheruntitled.txt >> :nth-match(svg, 4)
32-
await page.click(
33-
'div[role="main"] >> text=Launcheruntitled.txt >> :nth-match(svg, 4)'
34-
);
29+
// Close file
30+
await page.click('text=File');
31+
// Click ul[role="menu"] >> text=New
32+
await page.click('ul[role="menu"] >> text=Close Tab');
3533

3634
// Click [aria-label="File Browser Section"] >> text=untitled.txt
3735
await page.click('[aria-label="File Browser Section"] >> text=untitled.txt', {

0 commit comments

Comments
 (0)