This repository has been archived by the owner on Aug 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Update polaris-spinner to v3.10.0 #308
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ef40a9b
Update polaris-spinner to v3.10.0
tomnez 26a3a9e
Update polaris-spinner tests
tomnez b7c09d9
Merge branch 'update/polaris-v3.10.0' into update/spinner-v3.10.0
tomnez c1567e9
Create map for image paths
tomnez 1d2b3da
Fix broken tests
tomnez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
{{svg-jar | ||
spinnerSource | ||
data-test-spinner=true | ||
{{!-- TODO: replace this with polaris-image when implemented. --}} | ||
<img | ||
alt="" | ||
src={{spinnerSVG}} | ||
class={{spinnerClass}} | ||
draggable="false" | ||
role="status" | ||
id=svgElementId | ||
class=spinnerClass | ||
aria-label=accessibilityLabel | ||
}} | ||
aria-label={{accessibilityLabel}} | ||
data-test-spinner | ||
> | ||
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,132 +1,74 @@ | ||
import { moduleForComponent, test } from 'ember-qunit'; | ||
import { module, test } from 'qunit'; | ||
import { setupRenderingTest } from 'ember-qunit'; | ||
import { render } from '@ember/test-helpers'; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
import { findAll } from 'ember-native-dom-helpers'; | ||
import MockSvgJarComponent from '../../mocks/components/svg-jar'; | ||
|
||
const spinnerSelector = 'svg.Polaris-Spinner'; | ||
const spinnerSelector = '[data-test-spinner]'; | ||
|
||
moduleForComponent( | ||
'polaris-spinner', | ||
'Integration | Component | polaris spinner', | ||
{ | ||
integration: true, | ||
module('Integration | Component | polaris spinner', function(hooks) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🙌 Thanks for doing this! 🙇 |
||
setupRenderingTest(hooks); | ||
|
||
beforeEach() { | ||
this.register( | ||
'component:svg-jar', | ||
MockSvgJarComponent.extend({ | ||
attributeBindings: ['role'], | ||
}) | ||
); | ||
}, | ||
} | ||
); | ||
test('it uses the label as the aria-label for the spinner', async function(assert) { | ||
let label = 'Content is loading'; | ||
|
||
test('renders the correct HTML with default attributes', function(assert) { | ||
this.render(hbs`{{polaris-spinner}}`); | ||
this.set('label', label); | ||
|
||
let spinners = findAll(spinnerSelector); | ||
assert.equal(spinners.length, 1, 'renders one spinner'); | ||
|
||
let spinner = spinners[0]; | ||
assert.equal( | ||
spinner.dataset.iconSource, | ||
'polaris/spinner-large', | ||
'renders spinner-large SVG' | ||
); | ||
assert.ok( | ||
spinner.classList.contains('Polaris-Spinner--sizeLarge'), | ||
'spinner size defaults to large' | ||
); | ||
assert.ok( | ||
spinner.classList.contains('Polaris-Spinner--colorTeal'), | ||
'spinner color defaults to teal' | ||
); | ||
assert.equal( | ||
spinner.getAttribute('role'), | ||
'status', | ||
'has correct role attribute' | ||
); | ||
}); | ||
|
||
test('handles size and color correctly', function(assert) { | ||
// Set unsupported size and color values initially. | ||
this.setProperties({ | ||
size: 'unknown', | ||
color: 'unknown', | ||
await render(hbs` | ||
{{polaris-spinner | ||
accessibilityLabel=label | ||
}} | ||
`); | ||
assert.dom(spinnerSelector).hasAttribute('aria-label', label); | ||
}); | ||
this.render(hbs`{{polaris-spinner size=size color=color}}`); | ||
|
||
let spinners = findAll(spinnerSelector); | ||
assert.equal(spinners.length, 1, 'renders one spinner'); | ||
|
||
// Check the correct defaults were used for size and color. | ||
let spinner = spinners[0]; | ||
assert.equal( | ||
spinner.dataset.iconSource, | ||
'polaris/spinner-large', | ||
'with unsupported size - renders spinner-large SVG' | ||
); | ||
assert.ok( | ||
spinner.classList.contains('Polaris-Spinner--sizeLarge'), | ||
'with unsupported size - spinner size defaults to large' | ||
); | ||
assert.ok( | ||
spinner.classList.contains('Polaris-Spinner--colorTeal'), | ||
'with unsupported color - spinner color defaults to teal' | ||
); | ||
|
||
// Set a color that isn't supported at large size. | ||
this.setProperties({ | ||
size: 'large', | ||
color: 'white', | ||
test('it renders a large spinner by default', async function(assert) { | ||
await render(hbs` | ||
{{polaris-spinner}} | ||
`); | ||
assert.dom(spinnerSelector).hasClass('Polaris-Spinner--sizeLarge'); | ||
}); | ||
|
||
assert.equal( | ||
spinner.dataset.iconSource, | ||
'polaris/spinner-small', | ||
'with unsupported color for large size - renders spinner-small SVG' | ||
); | ||
assert.ok( | ||
spinner.classList.contains('Polaris-Spinner--sizeSmall'), | ||
'with unsupported color for large size - spinner size changes to small' | ||
); | ||
assert.ok( | ||
spinner.classList.contains('Polaris-Spinner--colorWhite'), | ||
'with unsupported color for large size - spinner color is honored' | ||
); | ||
|
||
// Set a color that's supported at large size. | ||
this.setProperties({ | ||
size: 'large', | ||
color: 'inkLightest', | ||
test('it renders a large spinner when size is large', async function(assert) { | ||
await render(hbs` | ||
{{polaris-spinner | ||
size="large" | ||
}} | ||
`); | ||
assert.dom(spinnerSelector).hasClass('Polaris-Spinner--sizeLarge'); | ||
}); | ||
|
||
assert.equal( | ||
spinner.dataset.iconSource, | ||
'polaris/spinner-large', | ||
'with supported color for large size - renders spinner-large SVG' | ||
); | ||
assert.ok( | ||
spinner.classList.contains('Polaris-Spinner--sizeLarge'), | ||
'with supported color for large size - spinner size changes to large' | ||
); | ||
assert.ok( | ||
spinner.classList.contains('Polaris-Spinner--colorInkLightest'), | ||
'with supported color for large size - spinner color is honored' | ||
); | ||
}); | ||
test('it renders a small spinner when size is small', async function(assert) { | ||
await render(hbs` | ||
{{polaris-spinner | ||
size="small" | ||
}} | ||
`); | ||
assert.dom(spinnerSelector).hasClass('Polaris-Spinner--sizeSmall'); | ||
}); | ||
|
||
test('handles `accessibilityLabel` correctly', function(assert) { | ||
this.render(hbs`{{polaris-spinner accessibilityLabel="access granted"}}`); | ||
test('it renders a small spinner when color is white even if size is large', async function(assert) { | ||
await render(hbs` | ||
{{polaris-spinner | ||
color="white" | ||
size="large" | ||
}} | ||
`); | ||
assert.dom(spinnerSelector).hasClass('Polaris-Spinner--sizeSmall'); | ||
}); | ||
|
||
let spinners = findAll(spinnerSelector); | ||
assert.equal(spinners.length, 1, 'renders one spinner'); | ||
test('it renders an inkLightest spinner when color is inkLightest', async function(assert) { | ||
await render(hbs` | ||
{{polaris-spinner | ||
color="inkLightest" | ||
}} | ||
`); | ||
assert.dom(spinnerSelector).hasClass('Polaris-Spinner--colorInkLightest'); | ||
}); | ||
|
||
let spinner = spinners[0]; | ||
assert.equal( | ||
spinner.getAttribute('aria-label'), | ||
'access granted', | ||
'sets the correct aria-label' | ||
); | ||
test('it sets the role to status to denote advisory information to screen readers', async function(assert) { | ||
await render(hbs` | ||
{{polaris-spinner}} | ||
`); | ||
assert.dom(spinnerSelector).hasAttribute('role', 'status'); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this change mean we can remove the
SvgHandling
mixin frompolaris-spinner
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yasss, let's remove that :D