MCPcopy Index your code
hub / github.com/coder/coder / toHavePathNameEndingWith

Function toHavePathNameEndingWith

site/e2e/expectUrl.ts:45–76  ·  view source on GitHub ↗

* toHavePathNameEndingWith allows checking the end of the URL (ie. to make * sure we redirected to a specific page) without caring about the entire URL, * which might depend on things like whether or not organizations or other * features are enabled.

(
		page: Page,
		expected: string,
		options?: PollingOptions,
	)

Source from the content-addressed store, hash-verified

43 * features are enabled.
44 */
45 async toHavePathNameEndingWith(
46 page: Page,
47 expected: string,
48 options?: PollingOptions,
49 ) {
50 let actual: string = new URL(page.url()).pathname;
51 let pass: boolean;
52 try {
53 await expect
54 .poll(() => {
55 actual = new URL(page.url()).pathname;
56 return actual.endsWith(expected);
57 }, options)
58 .toBe(true);
59 pass = true;
60 } catch {
61 pass = false;
62 }
63
64 return {
65 name: "toHavePathNameEndingWith",
66 pass,
67 actual,
68 expected,
69 message: () =>
70 `The page does not have the expected URL pathname.\nExpected a url ${
71 this.isNot ? "not " : ""
72 }ending with: ${this.utils.printExpected(
73 expected,
74 )}\nActual: ${this.utils.printReceived(actual)}`,
75 };
76 },
77});

Callers

nothing calls this directly

Calls 2

urlMethod · 0.65
pollMethod · 0.45

Tested by

no test coverage detected