Add an e2e test to check the app reloads when a new version is available (#7956)
this includes an update to the puppeteer version to support request.isInterceptResolutionHandled
This commit is contained in:
parent
acd12c38a9
commit
6be61c4693
4 changed files with 130 additions and 51 deletions
|
@ -29,6 +29,7 @@ import { RestSession } from "./rest/session";
|
|||
import { stickerScenarios } from './scenarios/sticker';
|
||||
import { userViewScenarios } from "./scenarios/user-view";
|
||||
import { ssoCustomisationScenarios } from "./scenarios/sso-customisations";
|
||||
import { updateScenarios } from "./scenarios/update";
|
||||
|
||||
export async function scenario(createSession: (s: string) => Promise<ElementSession>,
|
||||
restCreator: RestSessionCreator): Promise<void> {
|
||||
|
@ -71,6 +72,10 @@ export async function scenario(createSession: (s: string) => Promise<ElementSess
|
|||
// stickers for the performance loss of doing this.
|
||||
const ssoSession = await createUser("enterprise_erin");
|
||||
await ssoCustomisationScenarios(ssoSession);
|
||||
|
||||
// Create a new window to test app auto-updating
|
||||
const updateSession = await createSession("update");
|
||||
await updateScenarios(updateSession);
|
||||
}
|
||||
|
||||
async function createRestUsers(restCreator: RestSessionCreator): Promise<RestMultiSession> {
|
||||
|
|
47
test/end-to-end-tests/src/scenarios/update.ts
Normal file
47
test/end-to-end-tests/src/scenarios/update.ts
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
Copyright 2022 The Matrix.org Foundation C.I.C.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { HTTPRequest } from "puppeteer";
|
||||
import { strict as assert } from 'assert';
|
||||
|
||||
import { ElementSession } from "../session";
|
||||
|
||||
async function mockVersionHTTPResponse(session: ElementSession) {
|
||||
// Mock the HTTP response to return a new version to trigger auto-update behaviour
|
||||
await session.page.setRequestInterception(true);
|
||||
session.page.on('request', (request: HTTPRequest) => {
|
||||
if (request.isInterceptResolutionHandled()) return;
|
||||
const url = new URL(request.url());
|
||||
if (url.pathname === "/version") {
|
||||
request.respond({
|
||||
contentType: "text/html",
|
||||
status: 200,
|
||||
body: "some-new-version",
|
||||
});
|
||||
} else {
|
||||
request.continue();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export async function updateScenarios(session: ElementSession) {
|
||||
// Mock the HTTP response to return a newer version, then wait for the page to reload in response
|
||||
await mockVersionHTTPResponse(session);
|
||||
await session.goto(session.url('/'));
|
||||
await session.waitForReload();
|
||||
const newUrl = new URL(session.page.url());
|
||||
assert.equal(newUrl.searchParams.get("updated"), "1");
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue