Skip to content

Commit

Permalink
fix(c8yscrn): Use new default wait selector for visit (#168)
Browse files Browse the repository at this point in the history
Visit wait selector is using new default that works with latest Cumulocity. Added support for overwriting visit selector globally with `global.visitWaitSelector`.
  • Loading branch information
thomaswinkler authored Oct 30, 2024
1 parent 139260b commit 4e36009
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 7 deletions.
11 changes: 8 additions & 3 deletions src/lib/screenshots/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ export type GlobalVisitOptions = {
* @examples ["2024-09-26T19:17:35+02:00"]
*/
date?: string;
/**
* The selector to wait for when visiting a page
* @default "c8y-drawer-outlet c8y-app-icon .c8y-icon"
* @examples ["c8y-drawer-outlet c8y-app-icon .c8y-icon"]
*/
visitWaitSelector?: string;
};

export type Screenshot = GlobalVisitOptions &
Expand All @@ -70,7 +76,7 @@ export type Screenshot = GlobalVisitOptions &
*/
image: string;
/**
* The URI to visit
* The URI to visit. This typically a relative path to the baseUrl.
* @examples ["/apps/cockpit/index.html#/"]
*/
visit: string | Visit;
Expand Down Expand Up @@ -184,8 +190,7 @@ export type Visit = GlobalVisitOptions & {
timeout?: number;
/**
* The selector to wait for before taking the screenshot.
* @examples ["c8y-navigator-outlet c8y-app-icon"]
* @default "c8y-navigator-outlet c8y-app-icon"
* @examples ["c8y-drawer-outlet c8y-app-icon .c8y-icon"]
*/
selector?: string;
};
Expand Down
6 changes: 5 additions & 1 deletion src/screenshot/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,11 @@ export class C8yScreenshotRunner {
cy.login(visitUser);

const url = visitObject?.url ?? (item.visit as string);
const visitSelector = visitObject?.selector;
const visitSelector =
visitObject?.selector ??
this.config.global?.visitWaitSelector ??
"c8y-drawer-outlet c8y-app-icon .c8y-icon";
cy.task("debug", `Visiting ${url} Selector: ${visitSelector}`);
const visitTimeout = visitObject?.timeout;

const language =
Expand Down
29 changes: 26 additions & 3 deletions src/screenshot/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -718,10 +718,18 @@
"type": "string"
}
],
"description": "The URI to visit",
"description": "The URI to visit. This typically a relative path to the baseUrl.",
"examples": [
"/apps/cockpit/index.html#/"
]
},
"visitWaitSelector": {
"default": "c8y-drawer-outlet c8y-app-icon .c8y-icon",
"description": "The selector to wait for when visiting a page",
"examples": [
"c8y-drawer-outlet c8y-app-icon .c8y-icon"
],
"type": "string"
}
},
"required": [
Expand Down Expand Up @@ -762,10 +770,9 @@
"type": "string"
},
"selector": {
"default": "c8y-navigator-outlet c8y-app-icon",
"description": "The selector to wait for before taking the screenshot.",
"examples": [
"c8y-navigator-outlet c8y-app-icon"
"c8y-drawer-outlet c8y-app-icon .c8y-icon"
],
"type": "string"
},
Expand All @@ -787,6 +794,14 @@
"admin"
],
"type": "string"
},
"visitWaitSelector": {
"default": "c8y-drawer-outlet c8y-app-icon .c8y-icon",
"description": "The selector to wait for when visiting a page",
"examples": [
"c8y-drawer-outlet c8y-app-icon .c8y-icon"
],
"type": "string"
}
},
"required": [
Expand Down Expand Up @@ -913,6 +928,14 @@
"description": "The width in px to use for the browser window",
"minimum": 0,
"type": "integer"
},
"visitWaitSelector": {
"default": "c8y-drawer-outlet c8y-app-icon .c8y-icon",
"description": "The selector to wait for when visiting a page",
"examples": [
"c8y-drawer-outlet c8y-app-icon .c8y-icon"
],
"type": "string"
}
},
"type": "object"
Expand Down

0 comments on commit 4e36009

Please sign in to comment.