Files
InvenTree/src/frontend/tests/api.ts
T
Matthias Mair 2f139f94b4 feat: Add First Time User Guide and tipp backend data structure (#12978)
* add backend stuff

* update str method

* add to admin

* [FR] Add FTUE
Fixes #2907

* bump deps

* bump api

* add missing ruleset entry

* fix init

* add jumpoff to nav

* try disableing specific test

* fix lookup

* fix mounting

* disable more

* make tour conditional

* only show ftue once

* remove temp disable

* add actual content

* enable using the menu as well

* reorder steps

* finish propagation

* only allow delete

* lower testing runtime for now

* fix nitpicks

* revert frontend debug changes

* fix migration

* patch out ftu behaviour on the backend

* rename to first time use guide

* change tipp (DE) to tip (EN)

* deduplicate notification
2026-10-15 19:46:06 +11:00

43 lines
976 B
TypeScript

import { request } from '@playwright/test';
import { adminuser, apiUrl } from './defaults';
export const createApi = ({
username,
password
}: {
username?: string;
password?: string;
}) =>
request.newContext({
baseURL: apiUrl,
extraHTTPHeaders: {
Authorization: `Basic ${btoa(`${username || adminuser.username}:${password || adminuser.testcred}`)}`
}
});
export const dismissFtu = async ({
username,
password
}: {
username: string;
password: string;
}) => {
const api = await createApi({ username, password });
// find tip and patch out ftu
try {
const response = await api.get('user/me/');
if (!response.ok()) return;
const tip = ((await response.json())?.tips ?? []).find(
(t: any) => t.tip_id === 'org.inventree.i.tip.ftug'
);
if (tip && !tip.finished) {
await api.patch(`user/me/tips/${tip.pk}/`, {
data: { finished: true }
});
}
} finally {
await api.dispose();
}
};