mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-10-17 03:04:08 +00:00
Use screen terminology instead of page as documented by vite-browser-react
This commit is contained in:
@@ -45,38 +45,38 @@ describe('<CreateServer />', () => {
|
||||
it('passes a11y checks', () => checkAccessibility(setUp()));
|
||||
|
||||
it('shows success message when imported is true', async () => {
|
||||
const page = await setUp({ serversImported: true });
|
||||
const screen = await setUp({ serversImported: true });
|
||||
|
||||
await expect
|
||||
.element(page.getByText('Servers properly imported. You can now select one from the list :)'))
|
||||
.element(screen.getByText('Servers properly imported. You can now select one from the list :)'))
|
||||
.toBeInTheDocument();
|
||||
await expect
|
||||
.element(page.getByText('The servers could not be imported. Make sure the format is correct.'))
|
||||
.element(screen.getByText('The servers could not be imported. Make sure the format is correct.'))
|
||||
.not.toBeInTheDocument();
|
||||
await expect.element(page.getByText('ImportServersBtn')).not.toBeInTheDocument();
|
||||
await expect.element(screen.getByText('ImportServersBtn')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows error message when import failed', async () => {
|
||||
const page = await setUp({ importFailed: true });
|
||||
const screen = await setUp({ importFailed: true });
|
||||
|
||||
await expect
|
||||
.element(page.getByText('Servers properly imported. You can now select one from the list :)'))
|
||||
.element(screen.getByText('Servers properly imported. You can now select one from the list :)'))
|
||||
.not.toBeInTheDocument();
|
||||
await expect
|
||||
.element(page.getByText('The servers could not be imported. Make sure the format is correct.'))
|
||||
.element(screen.getByText('The servers could not be imported. Make sure the format is correct.'))
|
||||
.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('creates server data when form is submitted', async () => {
|
||||
const { user, history, store, ...page } = await setUp();
|
||||
const { user, history, store, ...screen } = await setUp();
|
||||
const expectedServerId = 'the_name-the_url.com';
|
||||
|
||||
await user.type(page.getByLabelText(/^Name/), 'the_name');
|
||||
await user.type(page.getByLabelText(/^URL/), 'https://the_url.com');
|
||||
await user.type(page.getByLabelText(/^API key/), 'the_api_key');
|
||||
await user.type(screen.getByLabelText(/^Name/), 'the_name');
|
||||
await user.type(screen.getByLabelText(/^URL/), 'https://the_url.com');
|
||||
await user.type(screen.getByLabelText(/^API key/), 'the_api_key');
|
||||
|
||||
expect(store.getState().servers[expectedServerId]).not.toBeDefined();
|
||||
await user.click(page.getByRole('button', { name: 'Create server' }));
|
||||
await user.click(screen.getByRole('button', { name: 'Create server' }));
|
||||
expect(store.getState().servers[expectedServerId]).toEqual(
|
||||
expect.objectContaining({
|
||||
id: expectedServerId,
|
||||
@@ -87,20 +87,20 @@ describe('<CreateServer />', () => {
|
||||
);
|
||||
|
||||
expect(history.location.pathname).toEqual(`/server/${expectedServerId}`);
|
||||
await expect.element(page.getByRole('dialog')).not.toBeInTheDocument();
|
||||
await expect.element(screen.getByRole('dialog')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('displays dialog when trying to create a duplicated server', async () => {
|
||||
const { user, history, ...page } = await setUp();
|
||||
const { user, history, ...screen } = await setUp();
|
||||
|
||||
await user.type(page.getByLabelText(/^Name/), 'the_name');
|
||||
await user.type(page.getByLabelText(/^URL/), 'https://existing_url.com');
|
||||
await user.type(page.getByLabelText(/^API key/), 'existing_api_key');
|
||||
await user.type(screen.getByLabelText(/^Name/), 'the_name');
|
||||
await user.type(screen.getByLabelText(/^URL/), 'https://existing_url.com');
|
||||
await user.type(screen.getByLabelText(/^API key/), 'existing_api_key');
|
||||
|
||||
await user.click(page.getByRole('button', { name: 'Create server' }));
|
||||
await user.click(screen.getByRole('button', { name: 'Create server' }));
|
||||
|
||||
await expect.element(page.getByRole('dialog')).toBeInTheDocument();
|
||||
await user.click(page.getByRole('button', { name: 'Discard' }));
|
||||
await expect.element(screen.getByRole('dialog')).toBeInTheDocument();
|
||||
await user.click(screen.getByRole('button', { name: 'Discard' }));
|
||||
|
||||
expect(history.location.pathname).toEqual('/foo'); // Goes back to first route from history's initialEntries
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user