Skip to content

Commit 1f4f565

Browse files
authored
test INFOPORTAL-6441: Add initial typescript support for helpers. (#18)
1 parent 7393f7f commit 1f4f565

File tree

2 files changed

+129
-0
lines changed

2 files changed

+129
-0
lines changed

tests/helpers/drupal-commands.d.ts

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
export function drush(command: string): Buffer;
2+
3+
/**
4+
* Finds node ID via drush and returns it.
5+
* @param {Array<{page: Page, node_title: String}>} array Page object and
6+
* node title
7+
* @returns {Promise<string>} The result.
8+
*/
9+
export function getNodeIdByTitle([page, node_title]): Promise<string>;
10+
11+
/**
12+
* Removes content prefixed with given keyword.
13+
* @param {String} keyword Keyword to find content by.
14+
*/
15+
export function cleanUpContent(keyword): Promise<void>;
16+
17+
/**
18+
* Finds node ID via drush and visits node edit page.
19+
* @param {Array<{page: Page, node_title: String}>} array Page object and
20+
* node title
21+
* @return {Response} The response.
22+
*/
23+
export async function visitNodeEditPage([page, node_title]): Promise<Response>;
24+
25+
/**
26+
* Finds node ID via drush and visits node layout page.
27+
* @param {Array<{page: Page, node_title: String}>} array Page object and
28+
* node title
29+
* @return {Response} The response.
30+
*/
31+
export async function visitNodeLayoutPage([page, node_title]): Promise<Response>;
32+
33+
/**
34+
* Finds node ID via drush and visits node layout preview page in the frontend.
35+
* @param {Array<{page: Page, node_title: String}>} array Page object and
36+
* node title
37+
* @return {Response} The response.
38+
*/
39+
export async function visitNodeLayoutPreviewPage([page, node_title]): Promise<Response>;
40+
41+
42+
/**
43+
* Visits node path found by title via drush.
44+
* @param {Array<{page: Page, node_title: String}>} array Page object and
45+
* node title
46+
* @return {Response} The response.
47+
*/
48+
export async function visitNodeByTitle([page, node_title]): Promise<Response>;
49+
50+
51+
/**
52+
* Visits node api with path alias found by title via drush.
53+
* @param {Object[]} array Page object and node title
54+
* @return {Response} The response.
55+
*/
56+
export async function visitNodeAPIByTitle([page, node_title]): Promise<Response>;
57+
58+
/**
59+
* Clones node with given title to a new node with new title.
60+
* @param {Array<{page: Page, node_title: String, new_node_title: String}>}
61+
* array Page object and node title
62+
* @return Promise{Buffer} The response.
63+
*/
64+
export async function cloneNodeByTitle([page, node_type, node_title, new_node_title]): Promise<Buffer>;
65+
66+
/**
67+
* Checks if there are any errors in the watchdog starting from a certain timestamp.
68+
*
69+
* @param timestamp Timestamp from when to look for errors.
70+
* @param fail_on_notice Boolean to change severity level of watchdog errors.
71+
* @returns {Promise<string>} The json result.
72+
*/
73+
export async function checkWatchdogErrors(timestamp, fail_on_notice = false): Promise<number>;

tests/helpers/test-methods.d.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
export function IShouldNotBeLoggedIn(page): Promise<void>;
2+
3+
export function ILogInAs([page, username]): Promise<void>;
4+
5+
export function theCacheHitExists([page, response]): Promise<void>;
6+
7+
export function theHeaderContains([response, headerValue, shouldContain, ...headers]): Promise<void>;
8+
9+
export function checkMetaContentByProperty([response, key, value, content]): Promise<void>;
10+
11+
/**
12+
* Checks the canonical URL within the given CE-API response.
13+
*
14+
* @param {Response} response The given CE-API response
15+
* @param canonicalURL The expected URL
16+
* @returns {Promise<void>}
17+
*/
18+
export function expectCanonicalUrl(response, canonicalURL): Promise<void>;
19+
20+
/**
21+
* @deprecated
22+
*/
23+
export function checkHomepageCanonicalUrls([response, frontendURL]): Promise<void>;
24+
25+
/**
26+
* Checks if current drupal installation is contentpool.
27+
* @returns {Boolean} Weather site is contentpool or not.
28+
*/
29+
export function isContentpoolSite(): Promise<boolean>;
30+
31+
/**
32+
* Checks if given ldp extensions are enabled.
33+
* @param {Array<String>} extensions Extensions to check.
34+
* @returns {Boolean} Weather extensions are enabled or not.
35+
*/
36+
export function areExtensionsEnabled(extensions): Promise<void>;
37+
38+
/**
39+
* Checks if there are javascript errors in the browser console.
40+
* @param {String} message Expected message.
41+
*/
42+
export function checkJavascriptErrors(page): Promise<void>;
43+
44+
/**
45+
* Checks if given message exists in drupal status messages.
46+
* @param {Array.<{message: String, page: Page}>} array Expected message
47+
* and page object.
48+
*/
49+
export function theStatusMessageShouldContain([message, page]): Promise<void>;
50+
51+
/**
52+
* Fills CKEditor Text Area.
53+
* @param {Array.<{page: Page, locator: String, textAreaContent: String}>}
54+
* array page object, selector and text to be filled.
55+
*/
56+
export function fillCKEditorTextArea([page, locator, textAreaContent]): Promise<void>;

0 commit comments

Comments
 (0)