mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-11 12:01:07 +00:00
* Add rspack * Remove TransformAsyncModulesPlugin from rspack * Migrate all webpack usage to rspack * Migrate tests to vitest * Fix test suites * Remove chai dependency * Fix compute_state_display tests * Fix resolveTimeZone * Reduces test pipeline * Revert test ci * optimize chunk filtering * Migrate landing-page to rspack * Update rspack dependencies * Add rsdoctor * Fix prod build bundle size * Use rsdoctor for demo stats * Remove unused webpack configs * Update build-scripts/rspack.cjs Co-authored-by: Petar Petrov <MindFreeze@users.noreply.github.com> * Fix eslint * Update rspack * Remove unused code --------- Co-authored-by: Petar Petrov <MindFreeze@users.noreply.github.com>
57 lines
1.5 KiB
TypeScript
57 lines
1.5 KiB
TypeScript
import { assert, describe, it } from "vitest";
|
|
import { createHassioSession } from "../../src/data/hassio/ingress";
|
|
|
|
describe("Create hassio session", () => {
|
|
const hass = {
|
|
config: { version: "1.0.0" },
|
|
callApi: async () => ({
|
|
data: { session: "fhdsu73rh3io4h8f3irhjel8ousafehf8f3yh" },
|
|
}),
|
|
};
|
|
|
|
it("Test create session without HTTPS", async () => {
|
|
// @ts-ignore
|
|
global.document = {};
|
|
// @ts-ignore
|
|
global.location = {};
|
|
// @ts-ignore
|
|
await createHassioSession(hass);
|
|
assert.strictEqual(
|
|
// @ts-ignore
|
|
global.document.cookie,
|
|
"ingress_session=fhdsu73rh3io4h8f3irhjel8ousafehf8f3yh;path=/api/hassio_ingress/;SameSite=Strict"
|
|
);
|
|
});
|
|
it("Test create session with HTTPS", async () => {
|
|
// @ts-ignore
|
|
global.document = {};
|
|
// @ts-ignore
|
|
global.location = { protocol: "https:" };
|
|
// @ts-ignore
|
|
await createHassioSession(hass);
|
|
assert.strictEqual(
|
|
// @ts-ignore
|
|
global.document.cookie,
|
|
"ingress_session=fhdsu73rh3io4h8f3irhjel8ousafehf8f3yh;path=/api/hassio_ingress/;SameSite=Strict;Secure"
|
|
);
|
|
|
|
// Clean up in case they will be used in other tests
|
|
// @ts-ignore
|
|
global.document = {};
|
|
// @ts-ignore
|
|
global.location = {};
|
|
});
|
|
it("Test fail to create", async () => {
|
|
const createSessionPromise = createHassioSession({
|
|
// @ts-ignore
|
|
callApi: async () => {
|
|
// noop
|
|
},
|
|
}).then(
|
|
() => true,
|
|
() => false
|
|
);
|
|
assert.strictEqual(await createSessionPromise, false);
|
|
});
|
|
});
|