Skip to content

Commit

Permalink
Add playwright test for repair status.
Browse files Browse the repository at this point in the history
  • Loading branch information
edwh committed Nov 2, 2022
1 parent 3403092 commit 1813a6b
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 5 deletions.
3 changes: 2 additions & 1 deletion playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ const config = {
},

// Flakiness
timeout: 45000
timeout: 5 * 60 * 1000,
navigationTimeout: 30 * 1000
};

module.exports = config;
2 changes: 2 additions & 0 deletions resources/js/components/DeviceRepairStatus.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<multiselect
:disabled="disabled"
v-model="statusValue"
class="repair-outcome"
:placeholder="__('devices.repair_outcome')"
:options="statusOptions"
track-by="id"
Expand Down Expand Up @@ -31,6 +32,7 @@
:disabled="disabled"
v-if="showParts"
v-model="partsValue"
class="spare-parts"
:placeholder="__('devices.spare_parts')"
:options="partsOptions"
:multiple="false"
Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/EventDevice.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
{{ __('devices.delete_device') }}
</b-btn>
<DeviceQuantity v-if="add" :quantity.sync="currentDevice.quantity" class="flex-md-shrink-1 ml-2 mr-2"/>
<b-btn variant="tertiary" class="ml-2" @click="cancel" v-if="cancelButton">
<b-btn variant="tertiary" class="ml-2 cancel" @click="cancel" v-if="cancelButton">
{{ __('partials.cancel') }}
</b-btn>
</div>
Expand Down
4 changes: 2 additions & 2 deletions resources/js/components/EventDeviceSummary.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div :class="badgeClass + ' d-block d-md-none'">
{{ status }}
</div>
<b-img v-if="sparePartsNeeded" src="/images/tick.svg" class="icon" />
<b-img v-if="sparePartsNeeded" src="/images/tick.svg" class="icon spare-parts" />
</div>
</b-td>
<b-td class="d-none d-md-table-cell" v-if="powered">
Expand Down Expand Up @@ -49,7 +49,7 @@
</span>
</b-td>
<b-td class="text-center d-none d-md-table-cell">
<b-img v-if="sparePartsNeeded" src="/images/tick.svg" class="icon" />
<b-img v-if="sparePartsNeeded" src="/images/tick.svg" class="icon spare-parts-tick" />
</b-td>
<b-td v-if="canedit" class="text-right d-none d-md-table-cell">
<div class="d-flex">
Expand Down
22 changes: 22 additions & 0 deletions tests/Integration/device.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
const {test, expect} = require('@playwright/test')
const { login, createGroup, createEvent, approveEvent, addDevice } = require('./utils')

test('Spare parts set as expected', async ({page, baseURL}) => {
await login(page, baseURL)
const groupid = await createGroup(page, baseURL)
const eventid = await createEvent(page, baseURL, groupid, true)
await approveEvent(page, baseURL, eventid)
await addDevice(page, baseURL, eventid, true, false, true, true)

// Should see spare parts tick in summary. Two copies because of mobile view.
await expect(await page.locator('.spare-parts-tick').count()).toEqual(2);
})

test('Spare parts not set unexpectedly', async ({page, baseURL}) => {
await login(page, baseURL)
const groupid = await createGroup(page, baseURL)
const eventid = await createEvent(page, baseURL, groupid, true)
await approveEvent(page, baseURL, eventid)
await addDevice(page, baseURL, eventid, true, false, true)

// Should not see spare parts tick in summary.
await expect(await page.locator('.spare-parts-tick:visible').count()).toEqual(0);
})

test('Can create misc powered device', async ({page, baseURL}) => {
await login(page, baseURL)
const groupid = await createGroup(page, baseURL)
Expand Down
19 changes: 18 additions & 1 deletion tests/Integration/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ exports.approveEvent = async function(page, baseURL, idevents) {
await page.locator('text=Event details updated.')
}

exports.addDevice = async function(page, baseURL, idevents, powered, photo) {
exports.addDevice = async function(page, baseURL, idevents, powered, photo, fixed, spareparts) {
// Go to event edit page.
await page.goto('/party/view/' + idevents)

Expand All @@ -176,6 +176,20 @@ exports.addDevice = async function(page, baseURL, idevents, powered, photo) {
await page.keyboard.press('Tab')
await page.keyboard.press('Enter')

if (fixed) {
// Tab to repair outcome and select fixed (first).
await page.keyboard.press('Tab')
await page.keyboard.press('Tab')
await page.keyboard.press('Tab')
await page.keyboard.press('Tab')
await page.keyboard.press('Enter')
}

if (spareparts) {
await page.locator('.spare-parts').click()
await page.keyboard.press('Enter')
}

if (photo) {
const [fileChooser] = await Promise.all([
page.waitForEvent('filechooser'),
Expand All @@ -202,6 +216,9 @@ exports.addDevice = async function(page, baseURL, idevents, powered, photo) {
// Just dropzone
await expect(page.locator('.device-photos:visible img')).toHaveCount(1)
}

// Close the device edit.
await page.locator('.cancel').click()
}

exports.unfollowGroup = async function(page, idgroups) {
Expand Down

0 comments on commit 1813a6b

Please sign in to comment.