mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-15 19:45:46 +00:00
apply suggestions from codereview
This commit is contained in:
@ -41,7 +41,7 @@ export type InvenTreeContext = {
|
||||
};
|
||||
|
||||
export const useInvenTreeContext = () => {
|
||||
const host = useLocalState.getState().host;
|
||||
const host = useLocalState((s) => s.host);
|
||||
const navigate = useNavigate();
|
||||
const user = useUserState();
|
||||
const { colorScheme } = useMantineColorScheme();
|
||||
|
@ -42,3 +42,9 @@ export const doLogout = async (page) => {
|
||||
await page.goto(`${baseUrl}/logout/`);
|
||||
await page.waitForURL('**/platform/login');
|
||||
};
|
||||
|
||||
export const createBasicAuthHeader = (username: string, password: string) => {
|
||||
return {
|
||||
Authorization: `Basic ${btoa(`${username}:${password}`)}`
|
||||
};
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { expect, test } from './baseFixtures.js';
|
||||
import { baseUrl, classicUrl } from './defaults.js';
|
||||
import { doQuickLogin } from './login.js';
|
||||
import { createBasicAuthHeader, doQuickLogin } from './login.js';
|
||||
|
||||
/*
|
||||
* Test for label printing.
|
||||
@ -82,13 +82,14 @@ test('PUI - Report Printing', async ({ page }) => {
|
||||
});
|
||||
|
||||
test('PUI - Report Editing', async ({ page }) => {
|
||||
await doQuickLogin(page, 'admin', 'inventree');
|
||||
const [username, password] = ['admin', 'inventree'];
|
||||
await doQuickLogin(page, username, password);
|
||||
|
||||
// activate the sample plugin for this test
|
||||
await page.request.patch(`${classicUrl}/api/plugins/sampleui/activate/`, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Basic YWRtaW46aW52ZW50cmVl`
|
||||
...createBasicAuthHeader(username, password)
|
||||
},
|
||||
data: { active: true }
|
||||
});
|
||||
@ -145,7 +146,7 @@ test('PUI - Report Editing', async ({ page }) => {
|
||||
await page.request.patch(`${classicUrl}/api/plugins/sampleui/activate/`, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Basic YWRtaW46aW52ZW50cmVl`
|
||||
...createBasicAuthHeader(username, password)
|
||||
},
|
||||
data: { active: false }
|
||||
});
|
||||
|
Reference in New Issue
Block a user