Skip to content

Commit

Permalink
test: fixes to screenshot test (#362)
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare committed Aug 29, 2022
1 parent 6771434 commit beefd71
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/views/Stopwatch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ div
hr

div(v-if="loading")
span.text-muted.center Loading...
span.text-muted.center.aw-loading Loading...
div.row(v-else)
div.col-md-12
h3 Running
Expand Down Expand Up @@ -87,15 +87,15 @@ export default {
return _.groupBy(this.stoppedTimers, e => moment(e.timestamp).format('YYYY-MM-DD'));
},
},
mounted: function () {
mounted: async function () {
// TODO: List all possible timer buckets
//this.getBuckets();
// Create default timer bucket
this.$aw.ensureBucket(this.bucket_id, 'general.stopwatch', 'unknown');
await this.$aw.ensureBucket(this.bucket_id, 'general.stopwatch', 'unknown');
// TODO: Get all timer events
this.getEvents();
await this.getEvents();
setInterval(() => (this.now = moment()), 1000);
},
Expand Down
2 changes: 1 addition & 1 deletion src/views/Timeline.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ div
aw-devonly(reason="Not ready for production, still experimenting")
aw-calendar(:buckets="buckets")
div(v-else)
h1 Loading...
h1.aw-loading Loading...
</template>

<script>
Expand Down
2 changes: 1 addition & 1 deletion src/views/settings/LandingPageSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ div
option(:value="'/activity/' + hostname + '/view/'" v-for="hostname in hostnames") Activity ({{hostname}})
option(value="/timeline") Timeline
span(v-else)
| Loading...
.aw-loading Loading...
small
| The page to open when opening ActivityWatch, or clicking the logo in the top menu.
</template>
Expand Down
2 changes: 1 addition & 1 deletion src/views/settings/Theme.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ div
option(value="light") Light
option(value="dark") Dark
span(v-else)
| Loading...
.aw-loading Loading...
small
| Change color theme of the application (you need to change categories colors manually to be suitable with dark mode).
</template>
Expand Down
2 changes: 1 addition & 1 deletion src/visualizations/TimelineBarChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ div(v-if="datasets && datasets.length > 0")
div.small(v-else-if="datasets === null", style="font-size: 16pt; color: #aaa;")
| No data
div.small(v-else, style="font-size: 16pt; color: #aaa;")
| Loading...
.aw-loading Loading...
</template>

<script lang="ts">
Expand Down
24 changes: 18 additions & 6 deletions test/e2e/screenshot.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,29 @@ async function hide_devonly(t) {
}

async function waitForLoading(t) {
// Waits for all "Loading..." texts to disappear from page.
// If it takes longer than 10s, it will fail.
let $loading;
let matches = 1;

console.log('Waiting for loading to disappear...');
const start = new Date();
do {
console.log('Waiting for loading to disappear...');
await t.wait(500);
$loading = Selector('div', { timeout: 500 }).withText(/Loading[.]{3}/g);
$loading = Selector('.aw-loading, text', { timeout: 500 }).withText(/Loading[.]{3}/g);

// Useful for debugging:
const matches = await $loading.count;
matches = await $loading.count;
if (matches > 0) {
console.log(`Found loading element with contents: ${await $loading.innerText}`);
console.log(`Found ${matches} loading element with contents`); //: ${await $loading.innerText}`);

// If taking >20s, throw an error
if (new Date() - start > 20000) {
throw new Error('Timeout while waiting for loading to disappear');
}
await t.wait(500);
}
} while ((await $loading.count) >= 1);
} while (matches >= 1);

await t.wait(500); // wait an extra 500ms, just in case a visualization is still rendering
console.log('Loading is gone!');
}
Expand Down

1 comment on commit beefd71

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are screenshots of this commit:

Screenshots using aw-server v0.12.0b2 (click to expand)

CML watermark

Please sign in to comment.