Skip to content

Commit 2aa9e5a

Browse files
Mario Aguiarravichdev
authored andcommitted
Add a disabled snapshot
1 parent b7b5dd9 commit 2aa9e5a

File tree

4 files changed

+142
-16
lines changed

4 files changed

+142
-16
lines changed

plugin/assets/src/settings/components/integrations/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ const Integrations = () => {
8080
type={ UPDATERS[ key ].type }
8181
displayUpdatedOn={ UPDATERS[ key ].displayUpdatedOn }
8282
versionAvailable={ UPDATERS[ key ].versionAvailable }
83+
apiStatus={ state.apiStatus }
8384
/>
8485
) ) }
8586
</div>

plugin/assets/src/settings/components/integrations/updater.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,11 @@ const Updater = ( {
4444
type,
4545
displayUpdatedOn,
4646
versionAvailable,
47+
apiStatus,
4748
} ) => {
4849
const [ id ] = useState( _uniqueId( 'updater-' ) );
4950
const { state, dispatch } = useContext( SettingsContext );
50-
const isDisabled = needsKey && 'ok' !== state.apiStatus;
51+
const isDisabled = needsKey && 'ok' !== apiStatus;
5152
const updatedDate = lastUpdated
5253
? dateI18n( 'M j, Y, h:i A', lastUpdated )
5354
: __( 'never', 'material-design' );

plugin/tests/js/settings/components/integrations/__snapshots__/updater.test.js.snap

Lines changed: 128 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,39 +22,152 @@ exports[`Settings: Updater matches snapshot 1`] = `
2222
<p
2323
class="mdc-typography--body1"
2424
>
25-
To enable Google Fonts updates please
26-
<a
27-
href="https://developers.google.com/fonts/docs/developer_api#APIKey"
28-
rel="noopener noreferrer"
29-
target="_blank"
30-
>
31-
activate Google API Key
32-
</a>
33-
first
25+
Last update on Apr 6, 2021, 11:14 PM
3426
</p>
3527
</div>
3628
<div
3729
class="mdc-layout-grid__cell mdc-layout-grid__cell--span-3 mdc-layout-grid__cell--align-middle material-settings__cell--justify-end"
38-
/>
30+
>
31+
<div
32+
class="material-settings__switch"
33+
>
34+
<div
35+
class="mdc-switch material-wizard-switch mdc-switch--checked"
36+
>
37+
<div
38+
class="mdc-switch__track"
39+
/>
40+
<div
41+
class="mdc-switch__thumb-underlay"
42+
>
43+
<div
44+
class="mdc-switch__thumb"
45+
/>
46+
<input
47+
aria-checked="true"
48+
checked=""
49+
class="mdc-switch__native-control"
50+
id="updater-1"
51+
role="switch"
52+
type="checkbox"
53+
/>
54+
</div>
55+
</div>
56+
<label
57+
for="updater-1"
58+
id="label-updater-1"
59+
>
60+
Auto-updates enabled
61+
</label>
62+
</div>
63+
</div>
3964
<div
4065
class="mdc-layout-grid__cell mdc-layout-grid__cell--span-2 mdc-layout-grid__cell--align-middle material-settings__cell--justify-end"
4166
>
42-
<div
43-
class="material-settings__message material-settings__message--error"
67+
<button
68+
class="mdc-button mdc-button--raised"
69+
disabled=""
4470
>
4571
<i
4672
aria-hidden="true"
4773
class="material-icons mdc-button__icon leading-icon"
4874
>
49-
error
75+
done
5076
</i>
5177
<span
52-
class="material-settings__message-text"
78+
class="mdc-button__label"
5379
>
54-
Updates disabled
80+
Updated
5581
</span>
82+
</button>
83+
</div>
84+
</div>
85+
</div>
86+
</div>
87+
</div>
88+
`;
89+
90+
exports[`Settings: Updater matches snapshot when disabled 1`] = `
91+
<div>
92+
<div
93+
class="material-settings__updater"
94+
>
95+
<div
96+
class="mdc-layout-grid"
97+
>
98+
<div
99+
class="mdc-layout-grid__inner"
100+
>
101+
<div
102+
class="mdc-layout-grid__cell mdc-layout-grid__cell--span-7 mdc-layout-grid__cell--align-middle"
103+
>
104+
<h3
105+
class="mdc-typography--headline6"
106+
>
107+
Google Fonts
108+
</h3>
109+
<p
110+
class="mdc-typography--body1"
111+
>
112+
Last update on Apr 6, 2021, 11:14 PM
113+
</p>
114+
</div>
115+
<div
116+
class="mdc-layout-grid__cell mdc-layout-grid__cell--span-3 mdc-layout-grid__cell--align-middle material-settings__cell--justify-end"
117+
>
118+
<div
119+
class="material-settings__switch"
120+
>
121+
<div
122+
class="mdc-switch material-wizard-switch mdc-switch--checked"
123+
>
124+
<div
125+
class="mdc-switch__track"
126+
/>
127+
<div
128+
class="mdc-switch__thumb-underlay"
129+
>
130+
<div
131+
class="mdc-switch__thumb"
132+
/>
133+
<input
134+
aria-checked="true"
135+
checked=""
136+
class="mdc-switch__native-control"
137+
id="updater-2"
138+
role="switch"
139+
type="checkbox"
140+
/>
141+
</div>
142+
</div>
143+
<label
144+
for="updater-2"
145+
id="label-updater-2"
146+
>
147+
Auto-updates enabled
148+
</label>
56149
</div>
57150
</div>
151+
<div
152+
class="mdc-layout-grid__cell mdc-layout-grid__cell--span-2 mdc-layout-grid__cell--align-middle material-settings__cell--justify-end"
153+
>
154+
<button
155+
class="mdc-button mdc-button--raised"
156+
disabled=""
157+
>
158+
<i
159+
aria-hidden="true"
160+
class="material-icons mdc-button__icon leading-icon"
161+
>
162+
done
163+
</i>
164+
<span
165+
class="mdc-button__label"
166+
>
167+
Updated
168+
</span>
169+
</button>
170+
</div>
58171
</div>
59172
</div>
60173
</div>

plugin/tests/js/settings/components/integrations/updater.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const baseProps = {
3232
lastUpdated: parseInt( Date.now(), 10 ),
3333
needsKey: true,
3434
checked: true,
35+
apiStatus: 'ok',
3536
};
3637

3738
const setup = props => {
@@ -47,4 +48,14 @@ describe( 'Settings: Updater', () => {
4748
const { container } = setup( baseProps );
4849
expect( container ).toMatchSnapshot();
4950
} );
51+
52+
it( 'matches snapshot when disabled', () => {
53+
const props = {
54+
...baseProps,
55+
apiStatus: 'install',
56+
};
57+
58+
const { container } = setup( props );
59+
expect( container ).toMatchSnapshot();
60+
} );
5061
} );

0 commit comments

Comments
 (0)