/// <reference types="jest-playwright-preset" />
/// <reference types="expect-playwright" />

import { elementExists, localHost } from './utils';

const menuSelector = '.js-editor-menu';
const imageMenuButtonSelector = '.js-insert-image-btn';
const hrMenuButtonSelector = '.js-horizontal-rule-btn';
const strikeThroughMenuButtonSelector = '.js-strike-btn';

jest.setTimeout(35 * 1000);

describe('Docs', () => {
	it('should hide menu buttons', async () => {
		await page.goto(`${localHost}/index.html`, { waitUntil: 'load' });
		//unable to use variable for gitHubToken;
		await page.evaluate(
			`window.localStorage.setItem('gitHubToken', 'ghp_PersonalAccessToken01245678900000000')`
		);
		await page.goto(`${localHost}/docs.html`, { waitUntil: 'networkidle' });
		const menu = await elementExists(menuSelector);
		expect(menu).toBeTruthy();
		const strikeThroughMenuButton = await elementExists(strikeThroughMenuButtonSelector);
		expect(strikeThroughMenuButton).toBeFalsy();
		const hrMenuButton = await elementExists(hrMenuButtonSelector);
		expect(hrMenuButton).toBeFalsy();
		const imageMenuButton = await elementExists(imageMenuButtonSelector);
		expect(imageMenuButton).toBeTruthy();
	});
});
