Skip to content

Commit e151c5d

Browse files
Merge branch 'fix-test-checked-checks'
2 parents a734fac + f808f1b commit e151c5d

File tree

6 files changed

+33
-32
lines changed

6 files changed

+33
-32
lines changed

desktop/packages/mullvad-vpn/test/e2e/installed/state-dependent/daita-settings/daita-settings.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ test.describe('DAITA settings', () => {
3232
await routes.daitaSettings.setEnableDaitaSwitch(false);
3333
const daitaSwitch = routes.daitaSettings.getEnableDaitaSwitch();
3434

35-
await expect(daitaSwitch).toHaveAttribute('aria-checked', 'false');
35+
await expect(daitaSwitch).not.toBeChecked();
3636
});
3737

3838
test('Should enable DAITA when clicking switch', async () => {
3939
await routes.daitaSettings.setEnableDaitaSwitch(true);
4040
const daitaSwitch = routes.daitaSettings.getEnableDaitaSwitch();
4141

42-
await expect(daitaSwitch).toHaveAttribute('aria-checked', 'true');
42+
await expect(daitaSwitch).toBeChecked();
4343
});
4444
});

desktop/packages/mullvad-vpn/test/e2e/installed/state-dependent/multihop-settings/multihop-settings.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ test.describe('Multihop settings', () => {
3131
await routes.multihopSettings.setEnableMultihopSwitch(false);
3232
const multihopSwitch = routes.multihopSettings.getEnableMultihopSwitch();
3333

34-
await expect(multihopSwitch).toHaveAttribute('aria-checked', 'false');
34+
await expect(multihopSwitch).not.toBeChecked();
3535
});
3636

3737
test('Should enable multihop when clicking switch', async () => {
3838
await routes.multihopSettings.setEnableMultihopSwitch(true);
3939
const multihopSwitch = routes.multihopSettings.getEnableMultihopSwitch();
4040

41-
await expect(multihopSwitch).toHaveAttribute('aria-checked', 'true');
41+
await expect(multihopSwitch).toBeChecked();
4242
});
4343
});

desktop/packages/mullvad-vpn/test/e2e/installed/state-dependent/vpn-settings/vpn-settings.spec.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ test.describe('VPN settings', () => {
3939
test.afterEach(async () => {
4040
await routes.vpnSettings.setAutoConnectSwitch(false);
4141
const autoConnectSwitch = routes.vpnSettings.getAutoConnectSwitch();
42-
await expect(autoConnectSwitch).toHaveAttribute('aria-checked', 'false');
42+
await expect(autoConnectSwitch).not.toBeChecked();
4343

4444
await routes.vpnSettings.setLaunchAppOnStartupSwitch(false);
4545
const launchOnStartupSwitch = routes.vpnSettings.getLaunchAppOnStartupSwitch();
46-
await expect(launchOnStartupSwitch).toHaveAttribute('aria-checked', 'false');
46+
await expect(launchOnStartupSwitch).not.toBeChecked();
4747
});
4848

4949
test.describe('Launch app on start-up', () => {
@@ -54,7 +54,7 @@ test.describe('VPN settings', () => {
5454

5555
await routes.vpnSettings.setLaunchAppOnStartupSwitch(true);
5656
const launchOnStartupSwitch = routes.vpnSettings.getLaunchAppOnStartupSwitch();
57-
await expect(launchOnStartupSwitch).toHaveAttribute('aria-checked', 'true');
57+
await expect(launchOnStartupSwitch).toBeChecked();
5858

5959
if (process.platform === 'linux') {
6060
expect(autoStartPathExists()).toBeTruthy();
@@ -73,7 +73,7 @@ test.describe('VPN settings', () => {
7373
test('Should be enabled when switch is clicked', async () => {
7474
await routes.vpnSettings.setAutoConnectSwitch(true);
7575
const autoConnectSwitchChecked = routes.vpnSettings.getAutoConnectSwitch();
76-
await expect(autoConnectSwitchChecked).toHaveAttribute('aria-checked', 'true');
76+
await expect(autoConnectSwitchChecked).toBeChecked();
7777
});
7878

7979
test('Should not enable cli auto-connect when enabled alone', async () => {
@@ -88,38 +88,39 @@ test.describe('VPN settings', () => {
8888
await routes.vpnSettings.setAutoConnectSwitch(true);
8989

9090
const launchOnStartupSwitch = routes.vpnSettings.getLaunchAppOnStartupSwitch();
91-
await expect(launchOnStartupSwitch).toHaveAttribute('aria-checked', 'true');
91+
await expect(launchOnStartupSwitch).toBeChecked();
9292

9393
const autoConnectSwitchChecked = routes.vpnSettings.getAutoConnectSwitch();
94-
await expect(autoConnectSwitchChecked).toHaveAttribute('aria-checked', 'true');
94+
await expect(autoConnectSwitchChecked).toBeChecked();
9595

9696
const cliAutoConnect = execSync('mullvad auto-connect get').toString();
9797
expect(cliAutoConnect).toContain('on');
9898
});
9999
});
100100

101101
test.describe('LAN settings', () => {
102-
const expectLocalNetworkSharing = async (
103-
ariaChecked: 'true' | 'false',
104-
cliState: 'allow' | 'block',
105-
) => {
102+
const expectLocalNetworkSharing = async (checked: boolean, cliState: 'allow' | 'block') => {
106103
const lanSwitch = routes.vpnSettings.getLanSwitch();
107-
await expect(lanSwitch).toHaveAttribute('aria-checked', ariaChecked);
104+
if (checked) {
105+
await expect(lanSwitch).toBeChecked();
106+
} else {
107+
await expect(lanSwitch).not.toBeChecked();
108+
}
108109
const cliStateOutput = execSync('mullvad lan get').toString();
109110
expect(cliStateOutput).toContain(cliState);
110111
};
111112

112113
const expectLocalNetworkSharingEnabled = async () => {
113-
await expectLocalNetworkSharing('true', 'allow');
114+
await expectLocalNetworkSharing(true, 'allow');
114115
};
115116

116117
const expectLocalNetworkSharingDisabled = async () => {
117-
await expectLocalNetworkSharing('false', 'block');
118+
await expectLocalNetworkSharing(false, 'block');
118119
};
119120

120121
const disableLocalNetworkSharing = async () => {
121122
const lanSwitch = routes.vpnSettings.getLanSwitch();
122-
if ((await lanSwitch.getAttribute('aria-checked')) === 'true') {
123+
if (await lanSwitch.isChecked()) {
123124
await lanSwitch.click();
124125
}
125126
await expectLocalNetworkSharingDisabled();

desktop/packages/mullvad-vpn/test/e2e/route-object-models/daita-settings/daita-settings-route-object-model.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ export class DaitaSettingsRouteObjectModel {
1818
return this.selectors.enableDaitaSwitch();
1919
}
2020

21-
async setEnableDaitaSwitch(enabled: boolean) {
21+
async setEnableDaitaSwitch(enable: boolean) {
2222
const enableDaitaSwitch = this.selectors.enableDaitaSwitch();
23-
const ariaChecked = await enableDaitaSwitch.getAttribute('aria-checked');
23+
const checked = await enableDaitaSwitch.isChecked();
2424

25-
if ((enabled && ariaChecked === 'false') || (!enabled && ariaChecked === 'true')) {
25+
if ((enable && !checked) || (!enable && checked)) {
2626
await enableDaitaSwitch.click();
2727
}
2828
}

desktop/packages/mullvad-vpn/test/e2e/route-object-models/multihop-settings/multihop-settings-route-object-model.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ export class MultihopSettingsRouteObjectModel {
1818
return this.selectors.enableMultihopSwitch();
1919
}
2020

21-
async setEnableMultihopSwitch(enabled: boolean) {
21+
async setEnableMultihopSwitch(enable: boolean) {
2222
const enableMultihopSwitch = this.selectors.enableMultihopSwitch();
23-
const ariaChecked = await enableMultihopSwitch.getAttribute('aria-checked');
23+
const checked = await enableMultihopSwitch.isChecked();
2424

25-
if ((enabled && ariaChecked === 'false') || (!enabled && ariaChecked === 'true')) {
25+
if ((enable && !checked) || (!enable && checked)) {
2626
await enableMultihopSwitch.click();
2727
}
2828
}

desktop/packages/mullvad-vpn/test/e2e/route-object-models/vpn-settings/vpn-settings-route-object-model.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ export class VpnSettingsRouteObjectModel extends NavigationObjectModel {
2525
return this.selectors.autoConnectSwitch();
2626
}
2727

28-
async setAutoConnectSwitch(enabled: boolean) {
28+
async setAutoConnectSwitch(enable: boolean) {
2929
const autoConnectSwitch = this.getAutoConnectSwitch();
30-
const ariaChecked = await autoConnectSwitch.getAttribute('aria-checked');
30+
const checked = await autoConnectSwitch.isChecked();
3131

32-
if ((enabled && ariaChecked === 'false') || (!enabled && ariaChecked === 'true')) {
32+
if ((enable && !checked) || (!enable && checked)) {
3333
await autoConnectSwitch.click();
3434
}
3535
}
@@ -38,10 +38,10 @@ export class VpnSettingsRouteObjectModel extends NavigationObjectModel {
3838
return this.selectors.launchAppOnStartupSwitch();
3939
}
4040

41-
async setLaunchAppOnStartupSwitch(enabled: boolean) {
41+
async setLaunchAppOnStartupSwitch(enable: boolean) {
4242
const launchAppOnStartupSwitch = this.getLaunchAppOnStartupSwitch();
43-
const ariaChecked = await launchAppOnStartupSwitch.getAttribute('aria-checked');
44-
if ((enabled && ariaChecked === 'false') || (!enabled && ariaChecked === 'true')) {
43+
const checked = await launchAppOnStartupSwitch.isChecked();
44+
if ((enable && !checked) || (!enable && checked)) {
4545
await launchAppOnStartupSwitch.click();
4646
}
4747
}
@@ -52,9 +52,9 @@ export class VpnSettingsRouteObjectModel extends NavigationObjectModel {
5252

5353
async setLanSwitch(enabled: boolean) {
5454
const lanSwitch = this.getLanSwitch();
55-
const ariaChecked = await lanSwitch.getAttribute('aria-checked');
55+
const checked = await lanSwitch.isChecked();
5656

57-
if ((enabled && ariaChecked === 'false') || (!enabled && ariaChecked === 'true')) {
57+
if ((enabled && !checked) || (!enabled && checked)) {
5858
await lanSwitch.click();
5959
}
6060
}

0 commit comments

Comments
 (0)