Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task: Add responsive tests #2424

Merged
merged 28 commits into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ad3c234
delete previous snapshots
ElinorW Feb 23, 2023
37bb9f0
add browser and viewport configuration
ElinorW Feb 23, 2023
5ba0f79
restore config
ElinorW Feb 23, 2023
9b90408
generate new snapshots
ElinorW Feb 23, 2023
16e8201
Merge branch 'dev' into task/responsive-tests
ElinorW Feb 23, 2023
fd2f85e
disabling check to test on branch
ElinorW Feb 23, 2023
7643277
remove duplicate id
ElinorW Feb 23, 2023
b21124a
run accessibility test on edge
ElinorW Feb 23, 2023
52cb882
remove playright-report
ElinorW Feb 24, 2023
540802e
run one project
ElinorW Feb 24, 2023
ecedc18
disable color-contrast
ElinorW Feb 24, 2023
ce081aa
retry with previous dimensions
ElinorW Feb 27, 2023
b8f8232
update snapshots
ElinorW Feb 27, 2023
19c8f7c
update sidebar tests
ElinorW Feb 27, 2023
1f33970
adjust screen dimensions
ElinorW Feb 28, 2023
b2cb8b1
Add chrome browser test
ElinorW Feb 28, 2023
47078cb
update snapshots
ElinorW Feb 28, 2023
7671317
update snapshots
ElinorW Feb 28, 2023
064867e
update snapshots
ElinorW Feb 28, 2023
821f42e
update snapshot clip
ElinorW Feb 28, 2023
66a44e5
update to use correct query
ElinorW Mar 1, 2023
b581509
add mobile responsive test
ElinorW Mar 1, 2023
8e22641
fix expand overflow
ElinorW Mar 2, 2023
1be0c97
delete unused comment
ElinorW Mar 2, 2023
2199a27
add expand button test
ElinorW Mar 2, 2023
88d741c
Merge branch 'dev' into task/responsive-tests
ElinorW Mar 8, 2023
4fe4db6
return condition
ElinorW Mar 8, 2023
5df25c9
Merge branch 'dev' into task/responsive-tests
Onokaev Mar 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ yarn-error.log*
.idea
.vs
*.xml
playwright-report/index.html
playwright-report
test-results

18 changes: 16 additions & 2 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require('dotenv').config();
import type { PlaywrightTestConfig } from '@playwright/test';
import { PlaywrightTestConfig } from '@playwright/test';

const baseURL = process.env.PLAYWRIGHT_TESTS_BASE_URL!;

Expand All @@ -26,6 +26,20 @@ const config: PlaywrightTestConfig = {
]
],
retries: 1,
timeout: 60000
timeout: 60000,
projects: [
{
name: 'Ms-Edge',
use: {
channel: 'msedge',
viewport: { width: 1920, height: 1080 }}
},
{
name: 'Chrome',
use: {
channel: 'chrome',
viewport: { width: 1365, height: 768 }}
}
]
};
export default config;
4 changes: 2 additions & 2 deletions src/app/services/reducers/dimensions-reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ const initialState: IDimensions = {
height: '50vh'
},
sidebar: {
width: '26%',
width: '28%',
height: ''
},
content: {
width: '74%',
width: '72%',
height: '100%'
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/app/views/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ class App extends Component<IAppProps, IAppState> {

public toggleSidebar = (): void => {
const shouldShowSidebar = this.setSidebarProperties();
this.changeDimensions(shouldShowSidebar ? '26%' : '4%');
this.changeDimensions(shouldShowSidebar ? '28%' : '4%');
telemetry.trackEvent(
eventTypes.BUTTON_CLICK_EVENT,
{
Expand All @@ -285,7 +285,7 @@ class App extends Component<IAppProps, IAppState> {
showSidebar
};
if (showSidebar) {
this.changeDimensions('26%');
this.changeDimensions('28%');
}

// @ts-ignore
Expand Down
2 changes: 2 additions & 0 deletions src/app/views/query-response/QueryResponse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ const QueryResponse = () => {
/>
<Pivot className='pivot-response'
onLinkClick={(pivotItem) => onModalPivotItemClicked(pivotItem)}
overflowBehavior='menu'
overflowAriaLabel={translateMessage('More items')}
selectedKey={currentTab}
styles={modalPivotStyles}>
{GetPivotItems()}
Expand Down
2 changes: 1 addition & 1 deletion src/app/views/query-runner/request/body/RequestBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const RequestBody = ({ handleOnEditorChange }: any) => {
const { dimensions: { request: { height } }, sampleQuery } = useAppSelector((state) => state);

return (
<FocusZone id='request-body-tab'>
<FocusZone>
<Monaco
body={sampleQuery.sampleBody}
height={convertVhToPx(height, 60)}
Expand Down
3 changes: 2 additions & 1 deletion src/tests/accessibility/accessibility.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ test.describe('Accessibility', () => {
'page-has-heading-one',
'landmark-unique',
'aria-allowed-attr',
'aria-required-children'
'aria-required-children',
'color-contrast'
])
.analyze();
accessibilityScan.setLegacyMode(false);
Expand Down
2 changes: 0 additions & 2 deletions src/tests/ui/anonymous-experiences/header.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ test.beforeAll(async ({ browser }) => {
await page.goto('/');
});

// await expect(authenticatedPage).toHaveScreenshot('runQuery.png', { clip: { x: 0, y: 0, width: 1920, height: 400 } });

test.describe('Settings button', () => {
test('should change theme settings', async () => {

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
4 changes: 2 additions & 2 deletions src/tests/ui/anonymous-experiences/request.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ test.describe.serial('Request section', () => {
await page.locator('[placeholder="Key"]').fill('ConsistencyLev');
await page.evaluate(() => document.fonts.ready);
await page.waitForTimeout(200);
expect(await page.screenshot({ clip: { x: 300, y: 0, width: 1920, height: 400 } })).toMatchSnapshot();
expect(await page.screenshot({ clip: { x: 300, y: 0, width: 1365, height: 400 } })).toMatchSnapshot();
await page.locator('button:has-text("Update")').click();
await page.evaluate(() => document.fonts.ready);
await page.waitForTimeout(200);
Expand All @@ -239,7 +239,7 @@ test.describe('Permissions', () => {
await page.evaluate(() => document.fonts.ready);
const permissionsText = page.locator('text=One of the following permissions is required to run the query. Sign in with an a');
expect(permissionsText).toBeDefined();
expect(await page.screenshot({ clip: { x: 0, y: 0, width: 1920, height: 400 } })).toMatchSnapshot();
expect(await page.screenshot()).toMatchSnapshot();
const DirectoryPermission = page.locator('div[role="gridcell"]:has-text("Directory.Read.AllDirectory.Read.All")');
expect(DirectoryPermission).toBeDefined();
})
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
4 changes: 2 additions & 2 deletions src/tests/ui/anonymous-experiences/response.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ test.describe('Response section', () => {
test('should show toolkit component for a valid url', async () => {
const queryInput = page.locator('[aria-label="Query sample input"]');
await queryInput.click();
await queryInput.fill('https://graph.microsoft.com/me');
await queryInput.fill('https://graph.microsoft.com/v1.0/me');
await page.waitForTimeout(200);
expect(await page.screenshot({ clip: { x: 300, y: -200, width: 1920, height: 1080 } })).toMatchSnapshot();
const toolkitTab = page.locator('[aria-label="Toolkit component"]');
Expand All @@ -49,7 +49,7 @@ test.describe('Response section', () => {
test('should show an error message for an invalid url', async () => {
const queryInput = page.locator('[aria-label="Query sample input"]');
await queryInput.click();
await queryInput.fill('https://graph.microsoft.com/me/messages');
await queryInput.fill('https://graph.microsoft.com/v1.0/me/messages');
await page.evaluate(() => document.fonts.ready);
expect(await page.screenshot({ clip: { x: 300, y: -200, width: 1920, height: 1080 } })).toMatchSnapshot();
const toolkitTab = page.locator('[aria-label="Toolkit component"]');
Expand Down
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
10 changes: 3 additions & 7 deletions src/tests/ui/anonymous-experiences/sidebar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,7 @@ test.describe('History tab', () => {
await page.locator('button[role="button"]:has-text("Run query")').click();
await page.evaluate(() => document.fonts.ready);
expect(await page.screenshot()).toMatchSnapshot();
await page.locator('text= Sample queries Resources History >> [aria-label="More items"]').click();
await page.evaluate(() => document.fonts.ready);
expect(await page.screenshot()).toMatchSnapshot();
await page.locator('button[role="menuitem"]:has-text("History")').click();
await page.getByRole('tab', { name: 'History History xx' }).click();
await page.evaluate(() => document.fonts.ready);
expect(await page.screenshot()).toMatchSnapshot();
expect(page.locator('span:has-text("Today")')).toBeDefined();
Expand Down Expand Up @@ -132,12 +129,11 @@ test.describe.serial('Sample Query tab', () => {
await page.evaluate(() => document.fonts.ready);
await page.waitForTimeout(200);
expect(await page.screenshot()).toMatchSnapshot();
await page.locator('[aria-label="OneDrive has 5 results 4 of 5"] [aria-label="expand collapse group"]').click();
await page.getByRole('row', { name: 'OneDrive has 5 results 4 of 6' }).getByRole('button', { name: 'expand collapse group' }).click();
await page.evaluate(() => document.fonts.ready);
expect(await page.screenshot()).toMatchSnapshot();
await page.locator('[aria-label="my recent files"]').click();
await page.getByRole('gridcell', { name: 'my recent files' }).click();
await page.waitForTimeout(200);
await page.evaluate(() => document.fonts.ready);
expect(await page.screenshot()).toMatchSnapshot();
})
})
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
115 changes: 115 additions & 0 deletions src/tests/ui/responsiveness/mobile-responsive.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/* eslint-disable max-len */
import { test, expect, Page } from '@playwright/test';

test.use({
viewport: {
height: 914,
width: 412
}
});

let page: Page;

test.beforeAll(async ({ browser }) => {
page = await browser.newPage();
await page.goto('/');
});


test.describe('Sidebar navigation', () => {
test('should have sample queries tab', async () => {
await page.getByRole('button', { name: 'Minimize sidebar' }).click();
await page.evaluate(() => document.fonts.ready);
await page.waitForTimeout(800);
await page.getByRole('tab', { name: 'Sample queries Sample queries xx' }).click();
expect(page.getByRole('gridcell', { name: 'my profile' }).filter({ hasText: 'my profileGET my profile' })).toBeDefined();
expect(await page.screenshot()).toMatchSnapshot();
await page.getByRole('gridcell', { name: 'my profile' }).filter({ hasText: 'my profileGET my profile' }).click();
await page.getByRole('button', { name: 'Run query' }).click();
})
test('should have resources tab', async () => {
await page.getByRole('button', { name: 'Minimize sidebar' }).click();
await page.getByRole('tab', { name: 'Resources Resources xx' }).click();
await page.evaluate(() => document.fonts.ready);
await page.waitForTimeout(200);
await page.getByRole('button', { name: 'applications (8)' }).click();
page.getByRole('link', { name: 'GET applications More actions' });
expect(await page.screenshot()).toMatchSnapshot();
await page.getByRole('link', { name: 'GET applications More actions' }).click();
})
test('should have history tab', async () => {
await page.getByRole('button', { name: 'Minimize sidebar' }).click();
await page.evaluate(() => document.fonts.ready);
await page.getByRole('tab', { name: 'History History xx' }).click();
await page.evaluate(() => document.fonts.ready);
await page.waitForTimeout(500);
page.getByText('Today');
expect(await page.screenshot()).toMatchSnapshot();
expect(page.locator('span:has-text("Today")')).toBeDefined();
await page.getByRole('button', { name: 'Minimize sidebar' }).click();
})
});

test.describe('Request area navigation', () => {
test('should have permissions tab in overflow menu', async () => {
await page.getByRole('tablist').filter({hasText:'Request body' }).getByRole('button',{name: 'More items'}).click();
await page.getByRole('menuitem', { name: 'Modify permissions' }).click();
await page.evaluate(() => document.fonts.ready);
await page.waitForTimeout(500);
page.locator('span').filter({ hasText: 'Directory.Read.All' });
expect(await page.screenshot()).toMatchSnapshot();
})

test('should have access token tab in overflow menu', async () => {
await page.getByRole('tablist').filter({hasText:'Request body' }).getByRole('button',{name: 'More items'}).click();
await page.getByRole('menuitem', { name: 'Access token' }).click();
page.getByText('To view your access token, sign in to Graph Explorer.');
expect(await page.screenshot()).toMatchSnapshot();
})
});
test.describe('Response area navigation', () => {
test('should have code snippets tab in overflow menu', async () => {
await page.getByRole('tablist').filter({hasText:'Response preview'}).getByRole('button',{name:'More items' }).click();
await page.getByRole('menuitem', { name: 'Code snippets' }).click();
await page.getByRole('tab', { name: 'CSharp CSharp' }).click();
await page.evaluate(() => document.fonts.ready);
await page.waitForTimeout(500);
expect(await page.screenshot()).toMatchSnapshot();
})
test('should have adaptive card tab in overflow menu', async () => {
await page.getByRole('button', { name: 'Minimize sidebar' }).click();
await page.getByRole('tab', { name: 'Sample queries Sample queries xx' }).click();
await page.getByRole('gridcell', { name: 'my profile' }).filter({ hasText: 'my profileGET my profile' }).click();
await page.getByRole('button', { name: 'Run query' }).click();
await page.evaluate(() => document.fonts.ready);
await page.waitForTimeout(1000);
await page.getByRole('tablist').filter({ hasText: 'Response preview' }).getByRole('button', { name: 'More items' }).click();
await page.getByRole('menuitem', { name: 'Adaptive cards' }).click();
await page.getByRole('tabpanel', { name: 'Adaptive cards' }).getByRole('tab', { name: 'Card' }).click();
expect(page.getByText('Megan Bowen')).toBeDefined();
expect(await page.screenshot()).toMatchSnapshot();
await page.getByRole('tab', { name: 'JSON template' }).click();
expect(page.getByText('Get started with adaptive cards on Adaptive Cards Templating SDK and experiment ')).toBeDefined();
await page.waitForTimeout(200);
expect(await page.screenshot()).toMatchSnapshot();
})
test('should have toolkit component tab in overflow menu', async () => {
await page.getByRole('tablist').filter({ hasText: 'Response preview' }).getByRole('button', { name: 'More items' }).click();
await page.getByRole('menuitem', { name: 'Toolkit component' }).click();
await page.waitForTimeout(500);
await page.evaluate(() => document.fonts.ready);
expect(page.locator('text=Open this example in')).toBeDefined();
expect(await page.screenshot()).toMatchSnapshot();
});
test('should have expand component tab in overflow menu', async () => {
await page.getByRole('tablist').filter({ hasText: 'Response preview' }).getByRole('button', { name: 'More items' }).click();
await page.getByRole('menuitem', { name: 'Expand response' }).click();
await page.getByRole('button', { name: 'More items' }).click();
await page.getByRole('menuitem', { name: 'Code snippets' }).click();
await page.getByRole('tab', { name: 'CSharp CSharp' }).click();
await page.evaluate(() => document.fonts.ready);
await page.waitForTimeout(500);
expect(await page.screenshot()).toMatchSnapshot();
await page.getByRole('button', { name: 'Close expanded response area' }).click();
});
});